Skip to content

Commit 89b6532

Browse files
authored
Merge branch 'main' into fix/474-make-soak-cleanup-timeout-configurable-and-visible
2 parents 7db1b20 + 46cd9d3 commit 89b6532

2 files changed

Lines changed: 37 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Please do not delete the template sections. PRs with empty descriptions or unche
117117

118118
- **Formatting**: Always run `cargo fmt` before committing.
119119
- **Linting**: We use Clippy. Ensure `cargo clippy --all-targets --all-features -- -D warnings` passes.
120+
- **Shell scripts**: We lint scripts under `scripts/` with ShellCheck. Run `find scripts -type f -name "*.sh" -print0 | xargs -0 shellcheck -S error` locally.
120121
- **Security**: All dependencies must be audited. We resolve all `RUSTSEC` advisories immediately.
121122
- **Error Handling**: Prefer the `Result<T>` type defined in `src/error.rs` using `thiserror`.
122123

scripts/soak-test.sh

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ TEST_NAMESPACE="${TEST_NAMESPACE:-soak-test}"
1919
RESULTS_FILE="${RESULTS_FILE:-/tmp/soak-memory.log}"
2020
CLEANUP_DONE=false
2121
CLEANUP_TIMEOUT_SECONDS="${CLEANUP_TIMEOUT_SECONDS:-120}"
22+
RETRY_DELAY_SECONDS="${RETRY_DELAY_SECONDS:-15}"
2223

2324
# ── Helpers ──────────────────────────────────────────────────────────────────
2425

@@ -28,6 +29,36 @@ get_operator_pid() {
2829
-o jsonpath='{.items[0].metadata.name}' 2>/dev/null
2930
}
3031

32+
validate_positive_integer() {
33+
local name="$1"
34+
local value="$2"
35+
if ! [[ "$value" =~ ^[0-9]+$ ]]; then
36+
echo "ERROR: ${name} must be an integer, got '${value}'"
37+
exit 1
38+
fi
39+
if [[ "$value" -lt 1 ]]; then
40+
echo "ERROR: ${name} must be >= 1, got '${value}'"
41+
exit 1
42+
fi
43+
}
44+
45+
get_operator_pid_with_retry() {
46+
local max_attempts="${1:-5}"
47+
local attempt=1
48+
local pod_name=""
49+
while [[ "$attempt" -le "$max_attempts" ]]; do
50+
pod_name=$(get_operator_pid)
51+
if [[ -n "$pod_name" ]]; then
52+
echo "$pod_name"
53+
return 0
54+
fi
55+
echo "Operator pod not found (attempt ${attempt}/${max_attempts}); retrying in ${RETRY_DELAY_SECONDS}s..."
56+
sleep "$RETRY_DELAY_SECONDS"
57+
attempt=$(( attempt + 1 ))
58+
done
59+
return 1
60+
}
61+
3162
get_rss_kb() {
3263
local pod="$1"
3364
# Read /proc/1/status from inside the container (PID 1 = operator process)
@@ -121,7 +152,10 @@ trap 'handle_exit' EXIT
121152

122153
kubectl create namespace "$TEST_NAMESPACE" --dry-run=client -o yaml | kubectl apply -f -
123154

124-
OPERATOR_POD=$(get_operator_pid)
155+
validate_positive_integer "RETRY_DELAY_SECONDS" "$RETRY_DELAY_SECONDS"
156+
echo "Retry delay: ${RETRY_DELAY_SECONDS}s"
157+
158+
OPERATOR_POD=$(get_operator_pid_with_retry 5)
125159
if [[ -z "$OPERATOR_POD" ]]; then
126160
echo "ERROR: No stellar-operator pod found in namespace $OPERATOR_NAMESPACE"
127161
exit 1
@@ -151,7 +185,7 @@ while [[ $ELAPSED -lt $SOAK_DURATION ]]; do
151185
delete_nodes
152186

153187
# Sample memory after each wave (and on the fixed interval)
154-
OPERATOR_POD=$(get_operator_pid)
188+
OPERATOR_POD=$(get_operator_pid_with_retry 5)
155189
CURRENT_KB=$(get_rss_kb "$OPERATOR_POD")
156190
GROWTH_KB=$(( CURRENT_KB - BASELINE_KB ))
157191
NOW=$(date +%s)

0 commit comments

Comments
 (0)