From 18961de36b32d785510e5c9788e8936c37ec150f Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Mon, 23 Mar 2026 17:25:01 +0300 Subject: [PATCH] [tests] Add pre-cleanup, fix port-forward race, fix temp leak - Add pre-cleanup of stale resources to all app E2E tests so retries start fresh instead of patching stuck state - Wait for port-forward to be ready before using it in kubernetes tests (fixes race condition) - Reduce version check sleep from 5s to 1s for faster retries - Clean up temp directory on test failure in cozytest.sh Assisted-By: Claude Signed-off-by: Aleksei Sviridkin --- hack/cozytest.sh | 1 + hack/e2e-apps/bucket.bats | 1 + hack/e2e-apps/clickhouse.bats | 1 + hack/e2e-apps/foundationdb.bats | 1 + hack/e2e-apps/kafka.bats | 1 + hack/e2e-apps/mariadb.bats | 1 + hack/e2e-apps/mongodb.bats | 1 + hack/e2e-apps/openbao.bats | 1 + hack/e2e-apps/postgres.bats | 1 + hack/e2e-apps/qdrant.bats | 1 + hack/e2e-apps/redis.bats | 1 + hack/e2e-apps/run-kubernetes.sh | 4 +++- hack/e2e-apps/vminstance.bats | 2 ++ 13 files changed, 16 insertions(+), 1 deletion(-) diff --git a/hack/cozytest.sh b/hack/cozytest.sh index 363a4d9f..a3955fd1 100755 --- a/hack/cozytest.sh +++ b/hack/cozytest.sh @@ -65,6 +65,7 @@ run_one() { echo "----- captured output -----------------------------------------" grep -v '^__RC__' "$log" echo "$LINE" + rm -rf "$tmp" exit "$rc" fi diff --git a/hack/e2e-apps/bucket.bats b/hack/e2e-apps/bucket.bats index 9239d780..a606bf68 100644 --- a/hack/e2e-apps/bucket.bats +++ b/hack/e2e-apps/bucket.bats @@ -3,6 +3,7 @@ @test "Create and Verify Seeweedfs Bucket" { # Create the bucket resource with readwrite and readonly users name='test' + kubectl -n tenant-test delete bucket.apps.cozystack.io $name --ignore-not-found --timeout=2m || true kubectl apply -f - < /dev/null 2>&1 &' + # Wait for port-forward to be ready before using it + timeout 15 sh -ec 'until curl -sk https://localhost:'"${port}"' >/dev/null 2>&1; do sleep 1; done' # Verify the Kubernetes version matches what we expect (retry for up to 20 seconds) - timeout 20 sh -ec 'until kubectl --kubeconfig tenantkubeconfig-'"${test_name}"' version 2>/dev/null | grep -Fq "Server Version: ${k8s_version}"; do sleep 5; done' + timeout 20 sh -ec 'until kubectl --kubeconfig tenantkubeconfig-'"${test_name}"' version 2>/dev/null | grep -Fq "Server Version: ${k8s_version}"; do sleep 1; done' # Wait for at least 2 nodes to join (timeout after 8 minutes) timeout 8m bash -c ' diff --git a/hack/e2e-apps/vminstance.bats b/hack/e2e-apps/vminstance.bats index 60513e8e..9f32fcc2 100644 --- a/hack/e2e-apps/vminstance.bats +++ b/hack/e2e-apps/vminstance.bats @@ -2,6 +2,8 @@ @test "Create a VM Disk" { name='test' + kubectl -n tenant-test delete vminstances.apps.cozystack.io $name --ignore-not-found --timeout=2m || true + kubectl -n tenant-test delete vmdisks.apps.cozystack.io $name --ignore-not-found --timeout=2m || true kubectl apply -f - <