From 4f551156a82ba8cd71ab86d8e8341675a91d1d87 Mon Sep 17 00:00:00 2001 From: noobwei Date: Mon, 29 Jul 2024 15:43:01 +0100 Subject: [PATCH] Enable cleanup in e2e Signed-off-by: noobwei --- test/e2e/run_test.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/e2e/run_test.sh b/test/e2e/run_test.sh index bd4e2ed2c..29e568c27 100755 --- a/test/e2e/run_test.sh +++ b/test/e2e/run_test.sh @@ -184,6 +184,21 @@ function install_dependencies() { rm -rf istio-${ISTIO_VERSION} } +function cleanup_kind_cluster() { + local NAME="${1:-kmesh-testing}" + echo "Deleting KinD cluster with name=${NAME}" + kind delete cluster --name="${NAME}" + echo "KinD cluster ${NAME} cleaned up" +} + +function cleanup_docker_registry() { + echo "Stopping Docker registry named '${KIND_REGISTRY_NAME}'..." + docker stop "${KIND_REGISTRY_NAME}" || echo "Failed to stop or no such registry '${KIND_REGISTRY_NAME}'." + + echo "Removing Docker registry named '${KIND_REGISTRY_NAME}'..." + docker rm "${KIND_REGISTRY_NAME}" || echo "Failed to remove or no such registry '${KIND_REGISTRY_NAME}'." +} + PARAMS="" while (( "$#" )); do @@ -210,6 +225,11 @@ while (( "$#" )); do IPV6=true shift ;; + --cleanup) + CLEANUP_KIND=true + CLEANUP_REGISTRY=true + shift + ;; --select-cases) PARAMS+="-test.run \"$2\"" shift 2 @@ -243,3 +263,11 @@ fi cmd="go test -v -tags=integ $ROOT_DIR/test/e2e/... -count=1 $PARAMS" bash -c "$cmd" + +if [[ -n "${CLEANUP_KIND}" ]]; then + cleanup_kind_cluster +fi + +if [[ -n "${CLEANUP_REGISTRY}" ]]; then + cleanup_docker_registry +fi \ No newline at end of file