Skip to content

Commit 66888c9

Browse files
test(e2e-apps): replace fixed sleeps with HelmRelease existence backstop
The app bats files all share the pattern: kubectl apply -f - <<EOF ... EOF sleep 5 kubectl wait hr <name> --for=condition=ready The fixed sleep guesses how long the cozystack-operator needs to translate the app CR into a HelmRelease. On a noisy CI runner or after a cold install that wait is sometimes too short, so the immediately-following `kubectl wait hr ...` fails because the HR object does not exist yet (`kubectl wait` errors out instantly on a missing resource). Replace each `sleep 5` (and the one outlier `sleep 15` in foundationdb that was paying for the same risk) with an event-driven backstop that polls for the HR's existence and exits the moment it appears, capped at 60s. The downstream `kubectl wait --for=condition=ready` is unchanged, preserving the original total budget. Same shape as the LINSTOR fix in commit eb87413 on feat/e2e-optimization: wait for the actual prerequisite (the HelmRelease the operator creates), not on a downstream artefact whose existence depends on it. Files: postgres, mariadb, kafka, mongodb, clickhouse, redis, qdrant, harbor, openbao, external-dns (both tests), vminstance (both tests, with the existence backstop hoisted before the downstream vmi-ip poll), and foundationdb. Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent dcc8718 commit 66888c9

12 files changed

Lines changed: 42 additions & 14 deletions

‎hack/e2e-apps/clickhouse.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ spec:
3535
resources: {}
3636
resourcesPreset: "nano"
3737
EOF
38-
sleep 5
38+
# Wait for the operator to materialise the HelmRelease before kubectl wait
39+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
40+
timeout 60 sh -ec "until kubectl -n tenant-test get hr clickhouse-$name >/dev/null 2>&1; do sleep 2; done"
3941
kubectl -n tenant-test wait hr clickhouse-$name --timeout=20s --for=condition=ready
4042
timeout 180 sh -ec "until kubectl -n tenant-test get svc chendpoint-clickhouse-$name -o jsonpath='{.spec.ports[*].port}' | grep -q '8123 9000'; do sleep 10; done"
4143
kubectl -n tenant-test wait statefulset.apps/chi-clickhouse-$name-clickhouse-0-0 --timeout=120s --for=jsonpath='{.status.replicas}'=1

‎hack/e2e-apps/external-dns.bats‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ spec:
1818
- example.com
1919
EOF
2020

21-
sleep 5
21+
# Wait for the operator to materialise the HelmRelease before kubectl wait
22+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
23+
timeout 60 sh -ec "until kubectl -n tenant-test get hr ${name} >/dev/null 2>&1; do sleep 2; done"
2224
kubectl -n tenant-test wait hr ${name} --timeout=120s --for=condition=ready
2325
kubectl -n tenant-test wait hr ${name}-system --timeout=120s --for=condition=ready
2426
timeout 60 sh -ec "until kubectl -n tenant-test get deploy -l app.kubernetes.io/instance=${name}-system -o jsonpath='{.items[0].status.readyReplicas}' | grep -q '1'; do sleep 5; done"
@@ -41,7 +43,9 @@ spec:
4143
- example.org
4244
EOF
4345

44-
sleep 5
46+
# Wait for the operator to materialise the HelmRelease before kubectl wait
47+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
48+
timeout 60 sh -ec "until kubectl -n tenant-test get hr ${name} >/dev/null 2>&1; do sleep 2; done"
4549
kubectl -n tenant-test wait hr ${name} --timeout=120s --for=condition=ready
4650
kubectl -n tenant-test wait hr ${name}-system --timeout=120s --for=condition=ready
4751
timeout 60 sh -ec "until kubectl -n tenant-test get deploy -l app.kubernetes.io/instance=${name}-system -o jsonpath='{.items[0].status.readyReplicas}' | grep -q '1'; do sleep 5; done"

‎hack/e2e-apps/foundationdb.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ spec:
4242
imageType: "unified"
4343
automaticReplacements: true
4444
EOF
45-
sleep 15
45+
# Wait for the operator to materialise the HelmRelease before kubectl wait
46+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
47+
timeout 60 sh -ec "until kubectl -n tenant-test get hr foundationdb-$name >/dev/null 2>&1; do sleep 2; done"
4648

4749
# Wait for HelmRelease to be ready
4850
kubectl -n tenant-test wait hr foundationdb-$name --timeout=300s --for=condition=ready

‎hack/e2e-apps/harbor.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ spec:
3838
size: 1Gi
3939
replicas: 1
4040
EOF
41-
sleep 5
41+
# Wait for the operator to materialise the HelmRelease before kubectl wait
42+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
43+
timeout 60 sh -ec "until kubectl -n tenant-test get hr $release >/dev/null 2>&1; do sleep 2; done"
4244
kubectl -n tenant-test wait hr $release --timeout=60s --for=condition=ready
4345

4446
# Wait for COSI to provision bucket

‎hack/e2e-apps/kafka.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ spec:
3939
partitions: 1
4040
replicas: 2
4141
EOF
42-
sleep 5
42+
# Wait for the operator to materialise the HelmRelease before kubectl wait
43+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
44+
timeout 60 sh -ec "until kubectl -n tenant-test get hr kafka-$name >/dev/null 2>&1; do sleep 2; done"
4345
kubectl -n tenant-test wait hr kafka-$name --timeout=30s --for=condition=ready
4446
kubectl wait kafkas -n tenant-test test --timeout=300s --for=condition=ready
4547
timeout 60 sh -ec "until kubectl -n tenant-test get pvc data-kafka-$name-zookeeper-0; do sleep 10; done"

‎hack/e2e-apps/mariadb.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ spec:
3535
resources: {}
3636
resourcesPreset: "nano"
3737
EOF
38-
sleep 5
38+
# Wait for the operator to materialise the HelmRelease before kubectl wait
39+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
40+
timeout 60 sh -ec "until kubectl -n tenant-test get hr mariadb-$name >/dev/null 2>&1; do sleep 2; done"
3941
kubectl -n tenant-test wait hr mariadb-$name --timeout=30s --for=condition=ready
4042
timeout 80 sh -ec "until kubectl -n tenant-test get svc mariadb-$name -o jsonpath='{.spec.ports[0].port}' | grep -q '3306'; do sleep 10; done"
4143
timeout 80 sh -ec "until kubectl -n tenant-test get endpoints mariadb-$name -o jsonpath='{.subsets[*].addresses[*].ip}' | grep -q '[0-9]'; do sleep 10; done"

‎hack/e2e-apps/mongodb.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ spec:
2626
backup:
2727
enabled: false
2828
EOF
29-
sleep 5
29+
# Wait for the operator to materialise the HelmRelease before kubectl wait
30+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
31+
timeout 60 sh -ec "until kubectl -n tenant-test get hr mongodb-$name >/dev/null 2>&1; do sleep 2; done"
3032
# Wait for HelmRelease
3133
kubectl -n tenant-test wait hr mongodb-$name --timeout=60s --for=condition=ready
3234
# Wait for MongoDB service (port 27017)

‎hack/e2e-apps/openbao.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ spec:
1818
external: false
1919
ui: true
2020
EOF
21-
sleep 5
21+
# Wait for the operator to materialise the HelmRelease before kubectl wait
22+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
23+
timeout 60 sh -ec "until kubectl -n tenant-test get hr openbao-$name >/dev/null 2>&1; do sleep 2; done"
2224
kubectl -n tenant-test wait hr openbao-$name --timeout=60s --for=condition=ready
2325
kubectl -n tenant-test wait hr openbao-$name-system --timeout=120s --for=condition=ready
2426

‎hack/e2e-apps/postgres.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ spec:
4040
resources: {}
4141
resourcesPreset: "nano"
4242
EOF
43-
sleep 5
43+
# Wait for the operator to materialise the HelmRelease before kubectl wait
44+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
45+
timeout 60 sh -ec "until kubectl -n tenant-test get hr postgres-$name >/dev/null 2>&1; do sleep 2; done"
4446
kubectl -n tenant-test wait hr postgres-$name --timeout=100s --for=condition=ready
4547
kubectl -n tenant-test wait job.batch postgres-$name-init-job --timeout=50s --for=condition=Complete
4648
timeout 40 sh -ec "until kubectl -n tenant-test get svc postgres-$name-r -o jsonpath='{.spec.ports[0].port}' | grep -q '5432'; do sleep 10; done"

‎hack/e2e-apps/qdrant.bats‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ spec:
1717
resources: {}
1818
external: false
1919
EOF
20-
sleep 5
20+
# Wait for the operator to materialise the HelmRelease before kubectl wait
21+
# kicks in (kubectl wait errors immediately if the object does not exist yet).
22+
timeout 60 sh -ec "until kubectl -n tenant-test get hr qdrant-$name >/dev/null 2>&1; do sleep 2; done"
2123
kubectl -n tenant-test wait hr qdrant-$name --timeout=60s --for=condition=ready
2224
kubectl -n tenant-test wait hr qdrant-$name-system --timeout=120s --for=condition=ready
2325
kubectl -n tenant-test wait sts qdrant-$name --timeout=90s --for=jsonpath='{.status.readyReplicas}'=1

0 commit comments

Comments
 (0)