mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-02-18 00:17:39 +01:00
Add comprehensive soak testing capabilities: **Runtime Instrumentation:** - Periodic sampling of heap, stack, goroutines, GC count - Sample every 10s during harness runs - HarnessReport includes full RuntimeSamples history - Detect memory leaks (>10% sustained growth) - Detect goroutine leaks (>20 leaked goroutines) **Soak Test:** - TestAdaptiveSchedulerSoak with 15min+ duration - Skip unless -soak flag or HARNESS_SOAK_MINUTES set - 80 synthetic instances (60 healthy, 15 transient, 5 permanent) - Configurable duration via env var - Validates: heap growth <10%, goroutines stable, queue depth bounded - Staleness threshold: 45s for long-running tests **Wrapper Script:** - testing-tools/run_adaptive_soak.sh for easy execution - Accepts duration in minutes: ./run_adaptive_soak.sh 30 - Logs to tmp/adaptive_soak_<timestamp>.log - Sets proper timeout (duration + 5min buffer) **Test Results (2-minute validation):** - 80 instances, 17 samples - Heap: 2.3MB → 3.1MB (healthy) - Goroutines: 16 → 6 (no leak, actually decreased) - Circuit breakers: correctly blocking transient failures Run with: go test -tags=integration ./internal/monitoring -run TestAdaptiveSchedulerSoak -soak -timeout 20m Part of Phase 2 Task 9 (Integration/Soak Testing)
30 lines
917 B
Bash
Executable File
30 lines
917 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
|
|
|
if [[ ${1-} ]]; then
|
|
export HARNESS_SOAK_MINUTES="$1"
|
|
elif [[ -z "${HARNESS_SOAK_MINUTES-}" ]]; then
|
|
export HARNESS_SOAK_MINUTES=15
|
|
fi
|
|
|
|
SOAK_MINUTES="${HARNESS_SOAK_MINUTES}"
|
|
if ! [[ "$SOAK_MINUTES" =~ ^[0-9]+$ ]]; then
|
|
echo "HARNESS_SOAK_MINUTES must be an integer number of minutes" >&2
|
|
exit 1
|
|
fi
|
|
|
|
TIMEOUT_MINUTES=$(( SOAK_MINUTES + 5 ))
|
|
LOG_DIR="${REPO_ROOT}/tmp"
|
|
mkdir -p "${LOG_DIR}"
|
|
LOG_FILE="${LOG_DIR}/adaptive_soak_$(date +%Y%m%d_%H%M%S).log"
|
|
|
|
echo "Running adaptive polling soak test for ${SOAK_MINUTES} minute(s)..."
|
|
set -o pipefail
|
|
go test -tags=integration ./internal/monitoring -run TestAdaptiveSchedulerSoak -soak -timeout "${TIMEOUT_MINUTES}m" 2>&1 | tee "${LOG_FILE}"
|
|
STATUS=${PIPESTATUS[0]}
|
|
echo "Soak test log saved to ${LOG_FILE}"
|
|
exit ${STATUS}
|