Skip to content

Commit

Permalink
refactor: build xline operator docker image
Browse files Browse the repository at this point in the history
Signed-off-by: Phoeniix Zhao <[email protected]>
  • Loading branch information
Phoenix500526 committed Feb 5, 2024
1 parent 2dcba82 commit ac5306f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 36 deletions.
42 changes: 14 additions & 28 deletions tests/e2e/cases/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -186,44 +186,30 @@ function test::ci::_clean_pv() {
}

function test::ci::_start() {
test::ci::stop_controller
test::ci::_install_CRD
test::ci::start_controller
log::info "create xline auth key pairs"
log::info "starting controller manager"
pushd ${CODE_BASE_DIR}
IMG=${OPERATOR_IMG} make deploy 2>/dev/null
if ! KUBECTL_NAMESPACE=${OPERATOR_NS} k8s::kubectl wait --for=condition=available deployment/xline-operator-controller-manager --timeout=300s; then
log::fatal "Failed to wait for xline-operator-controller-manager to be ready"
fi
popd
log::info "controller manager started"
log::info "creating xline auth key pairs..."
k8s::kubectl apply -f "$(dirname "${BASH_SOURCE[0]}")/manifests/auth-cred.yaml" >/dev/null 2>&1
k8s::kubectl::wait_resource_creation secret $_TEST_CI_SECRET_NAME
test::ci::_prepare_pv
log::info "starting xline cluster"
log::info "starting xline cluster..."
k8s::kubectl apply -f "$(dirname "${BASH_SOURCE[0]}")/manifests/cluster.yaml" >/dev/null 2>&1
k8s::kubectl::wait_resource_creation sts $_TEST_CI_STS_NAME
}

function test::ci::start_controller() {
log::info "starting controller"
pushd $(dirname "${BASH_SOURCE[0]}")/../../../
make run >/dev/null 2>&1 &
popd
sleep 5
if kill -0 $!; then
log::info "Controller started"
else
log::error "Controller cannot failed"
fi
}

function test::ci::stop_controller() {
controller_pid=$(lsof -i:8081 | grep main | awk '{print $2}')
if [ -n "$controller_pid" ]; then
kill -9 $controller_pid
fi
}


function test::ci::_teardown() {
log::info "stopping controller"
test::ci::_uninstall_CRD
test::ci::stop_controller
k8s::kubectl delete -f "$(dirname "${BASH_SOURCE[0]}")/manifests/cluster.yaml" >/dev/null 2>&1
log::info "stopping controller manager..."
pushd ${CODE_BASE_DIR}
IMG=${OPERATOR_IMG} make undeploy 2>/dev/null
popd
test::ci::wait_all_xline_pod_deleted 3
test::ci::_clean_pvc 3
test::ci::_clean_pv
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ set -euo pipefail
__ABS_PATH__=$(realpath ${BASH_SOURCE[0]})
export E2E_TEST_DIR=$(dirname ${__ABS_PATH__})
export CODE_BASE_DIR=$(dirname $(dirname ${E2E_TEST_DIR}))
export OPERATOR_IMG="ghcr.io/xline-kv/xline-operator:$(git rev-parse --short HEAD)"
export OPERATOR_NS="xline-operator-system"

source "${E2E_TEST_DIR}/common/common.sh"
source "${E2E_TEST_DIR}/testenv/testenv.sh"
Expand Down
19 changes: 11 additions & 8 deletions tests/e2e/testenv/testenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ function testenv::k8s::delete() {
}

function testenv::k8s::load_images() {
# xline image
log::info "Loading images"
xline_image="phoenix500526/xline:v0.6.1"
docker pull "$xline_image" 2>/dev/null
testenv::k8s::kind::load_image "$xline_image"
# etcdctl image
etcdctl_image="ghcr.io/xline-kv/etcdctl:v3.5.9"
docker pull "$etcdctl_image" 2>/dev/null
testenv::k8s::kind::load_image "$etcdctl_image"
# xline operator image
pushd ${CODE_BASE_DIR}
IMG=${OPERATOR_IMG} make docker-build 2>/dev/null
popd
testenv::k8s::kind::load_image "$OPERATOR_IMG"

remote_images=("phoenix500526/xline:v0.6.1" "ghcr.io/xline-kv/etcdctl:v3.5.9" "quay.io/brancz/kube-rbac-proxy:v0.15.0")
for img in "${remote_images[@]}"; do
docker pull "$img" 2>/dev/null
testenv::k8s::kind::load_image "$img"
done
}

0 comments on commit ac5306f

Please sign in to comment.