Skip to content

Commit b35a6d2

Browse files
committed
test: make soak cleanup timeout configurable and explicit
Add CLEANUP_TIMEOUT_SECONDS support to soak cleanup waits, surface timeout diagnostics with remaining resources, and abort unsafe continuation when deletes are still pending. Made-with: Cursor
1 parent 36837b7 commit b35a6d2

2 files changed

Lines changed: 60 additions & 3 deletions

File tree

.github/workflows/soak-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ on:
2323
description: "Max allowed RSS growth in kB (default: 5120 = 5 MB)"
2424
required: false
2525
default: "5120"
26+
cleanup_timeout_seconds:
27+
description: "Cleanup wait timeout in seconds (default: 120)"
28+
required: false
29+
default: "120"
2630
schedule:
2731
- cron: "0 2 * * 6" # Every Saturday at 02:00 UTC
2832

@@ -130,6 +134,7 @@ jobs:
130134
OPERATOR_NAMESPACE: ${{ env.OPERATOR_NAMESPACE }}
131135
SOAK_DURATION: ${{ github.event.inputs.soak_duration || '3600' }}
132136
THRESHOLD_KB: ${{ github.event.inputs.threshold_kb || '5120' }}
137+
CLEANUP_TIMEOUT_SECONDS: ${{ github.event.inputs.cleanup_timeout_seconds || '120' }}
133138
TEST_NAMESPACE: soak-test
134139
RESULTS_FILE: /tmp/soak-memory.log
135140
run: bash scripts/soak-test.sh

scripts/soak-test.sh

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ THRESHOLD_KB=5120 # 5 MB growth limit
1717
NODE_COUNT=100
1818
TEST_NAMESPACE="${TEST_NAMESPACE:-soak-test}"
1919
RESULTS_FILE="${RESULTS_FILE:-/tmp/soak-memory.log}"
20+
CLEANUP_DONE=false
21+
CLEANUP_TIMEOUT_SECONDS="${CLEANUP_TIMEOUT_SECONDS:-120}"
2022

2123
# ── Helpers ──────────────────────────────────────────────────────────────────
2224

@@ -58,14 +60,63 @@ delete_nodes() {
5860
kubectl delete stellarnode "soak-node-${i}" -n "$TEST_NAMESPACE" \
5961
--ignore-not-found --wait=false
6062
done
61-
# Wait for all to be gone before the next wave
62-
kubectl wait stellarnode \
63+
# Wait for all to be gone before the next wave.
64+
if kubectl wait stellarnode \
6365
--for=delete \
6466
--all \
6567
-n "$TEST_NAMESPACE" \
66-
--timeout=120s 2>/dev/null || true
68+
--timeout="${CLEANUP_TIMEOUT_SECONDS}s" 2>/dev/null; then
69+
echo "Cleanup finished within ${CLEANUP_TIMEOUT_SECONDS}s"
70+
return 0
71+
fi
72+
73+
local remaining
74+
remaining=$(kubectl get stellarnode -n "$TEST_NAMESPACE" --no-headers 2>/dev/null | wc -l | tr -d ' ')
75+
echo "WARN: Cleanup timeout reached after ${CLEANUP_TIMEOUT_SECONDS}s with ${remaining} resource(s) still present."
76+
echo "Aborting soak loop because it is unsafe to proceed with leftover resources."
77+
return 1
78+
}
79+
80+
cleanup_resources() {
81+
local reason="${1:-exit}"
82+
if [[ "$CLEANUP_DONE" == "true" ]]; then
83+
echo "[cleanup] Already completed (reason: ${reason})"
84+
return
85+
fi
86+
CLEANUP_DONE=true
87+
88+
echo "[cleanup] Starting cleanup (reason: ${reason})..."
89+
delete_nodes || true
90+
kubectl delete namespace "$TEST_NAMESPACE" --ignore-not-found --wait=false >/dev/null 2>&1 || true
91+
echo "[cleanup] Cleanup finished for namespace: ${TEST_NAMESPACE}"
6792
}
6893

94+
handle_exit() {
95+
local exit_code=$?
96+
cleanup_resources "exit"
97+
if [[ $exit_code -ne 0 ]]; then
98+
echo "[cleanup] Exiting with failure code: ${exit_code}"
99+
else
100+
echo "[cleanup] Exiting successfully"
101+
fi
102+
exit "$exit_code"
103+
}
104+
105+
handle_signal() {
106+
local signal_name="$1"
107+
local signal_code=1
108+
case "$signal_name" in
109+
INT) signal_code=130 ;;
110+
TERM) signal_code=143 ;;
111+
esac
112+
echo "[cleanup] Received ${signal_name}; requesting graceful shutdown..."
113+
exit "$signal_code"
114+
}
115+
116+
trap 'handle_signal INT' INT
117+
trap 'handle_signal TERM' TERM
118+
trap 'handle_exit' EXIT
119+
69120
# ── Setup ─────────────────────────────────────────────────────────────────────
70121

71122
kubectl create namespace "$TEST_NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
@@ -76,6 +127,7 @@ if [[ -z "$OPERATOR_POD" ]]; then
76127
exit 1
77128
fi
78129
echo "Operator pod: $OPERATOR_POD"
130+
echo "Cleanup timeout: ${CLEANUP_TIMEOUT_SECONDS}s"
79131

80132
# Baseline — let the operator settle for one sample interval first
81133
sleep "$SAMPLE_INTERVAL"

0 commit comments

Comments
 (0)