diff --git a/tests/e2e/cases/ci.sh b/tests/e2e/cases/ci.sh index 4e6421b..2903bd6 100644 --- a/tests/e2e/cases/ci.sh +++ b/tests/e2e/cases/ci.sh @@ -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 diff --git a/tests/e2e/e2e.sh b/tests/e2e/e2e.sh index 3c09aee..6f5667a 100755 --- a/tests/e2e/e2e.sh +++ b/tests/e2e/e2e.sh @@ -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" diff --git a/tests/e2e/testenv/testenv.sh b/tests/e2e/testenv/testenv.sh index ddf6c41..ccf771e 100644 --- a/tests/e2e/testenv/testenv.sh +++ b/tests/e2e/testenv/testenv.sh @@ -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 }