🧪 test: implement per-scenario state isolation and enhance validate-test-suite.sh
- Add pkg/bdd/steps/scenario_state.go with thread-safe per-scenario state manager - Update auth_steps.go, jwt_retention_steps.go to use per-scenario state accessors - Add LastSecret and LastError fields to ScenarioState for JWT retention testing - Update steps.go with SetScenarioKeyForAllSteps function - Update suite.go to generate scenario keys and clear state properly - Mark config hot-reload scenarios as @flaky (timing-sensitive) - Fix validate-test-suite.sh: add -p 1 flag for sequential execution, filter JSON logs, add --count flag - Add CONFIG_SCHEMA.md documenting configuration architecture - Split greet tests into v1/v2 sub-tests with explicit v2 enable/disable Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -2,13 +2,55 @@
|
||||
|
||||
# Test Suite Validation Script
|
||||
# Runs tests N times with separate unit and BDD test phases
|
||||
# Usage: ./scripts/validate-test-suite.sh [N]
|
||||
# Usage: ./scripts/validate-test-suite.sh [N] [OPTIONS]
|
||||
# N - Number of times to run tests (default: 20)
|
||||
# OPTIONS:
|
||||
# --parallel - Run feature tests in parallel
|
||||
# --count=C - Override -count flag for go test (default: same as N)
|
||||
# --quick - Run only core tests (skip @flaky)
|
||||
# --features=X - Test specific features only (comma-separated)
|
||||
|
||||
set -e
|
||||
|
||||
# Default values
|
||||
RUN_COUNT=${1:-20}
|
||||
GOTEST_COUNT=""
|
||||
PARALLEL=false
|
||||
QUICK=false
|
||||
FEATURES_FILTER=""
|
||||
|
||||
# Parse arguments
|
||||
shift
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--parallel)
|
||||
PARALLEL=true
|
||||
shift
|
||||
;;
|
||||
--count=*)
|
||||
GOTEST_COUNT="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--quick)
|
||||
QUICK=true
|
||||
shift
|
||||
;;
|
||||
--features=*)
|
||||
FEATURES_FILTER="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Use GOTEST_COUNT if set, otherwise use RUN_COUNT
|
||||
if [ -z "$GOTEST_COUNT" ]; then
|
||||
GOTEST_COUNT=$RUN_COUNT
|
||||
fi
|
||||
|
||||
SCRIPTS_DIR=$(dirname "$(realpath "${BASH_SOURCE[0]}")")
|
||||
|
||||
# Colors for output
|
||||
@@ -86,9 +128,36 @@ for (( run=1; run<=$RUN_COUNT; run++ )); do
|
||||
|
||||
export BDD_SCHEMA_ISOLATION=true
|
||||
|
||||
# Build feature test arguments
|
||||
FEATURE_PACKAGES=("config" "auth" "greet" "health" "jwt")
|
||||
|
||||
# Filter features if specified
|
||||
if [ -n "$FEATURES_FILTER" ]; then
|
||||
IFS=',' read -ra FILTERED_FEATURES <<< "$FEATURES_FILTER"
|
||||
ALL_FEATURES=("config" "auth" "greet" "health" "jwt")
|
||||
FEATURE_PACKAGES=()
|
||||
for feat in "${FILTERED_FEATURES[@]}"; do
|
||||
if [[ " ${ALL_FEATURES[@]} " =~ " ${feat} " ]]; then
|
||||
FEATURE_PACKAGES+=("$feat")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# Build go test command for features
|
||||
FEATURE_TESTS=""
|
||||
for feat in "${FEATURE_PACKAGES[@]}"; do
|
||||
FEATURE_TESTS+="./features/$feat "
|
||||
done
|
||||
|
||||
# Set tags for quick mode
|
||||
if [ "$QUICK" = true ]; then
|
||||
export GODOG_TAGS="~@flaky && ~@todo && ~@skip"
|
||||
fi
|
||||
|
||||
set +e # Temporarily disable exit on error
|
||||
BDD_OUTPUT=$(go test ./features/config ./features/auth ./features/greet ./features/health ./features/jwt -v 2>&1)
|
||||
BDD_EXIT_CODE=$?
|
||||
# Force sequential package testing and use fixed port to prevent race conditions
|
||||
FIXED_TEST_PORT=true BDD_SCHEMA_ISOLATION=true go test ${FEATURE_TESTS} -count=$GOTEST_COUNT -v -p 1 2>&1 | tee /tmp/bdd_raw_$$.txt | grep -v '^{"level"' > /tmp/bdd_output_$$.txt && BDD_OUTPUT=$(cat /tmp/bdd_output_$$.txt) && rm -f /tmp/bdd_output_$$.txt /tmp/bdd_raw_$$.txt || true
|
||||
BDD_EXIT_CODE=${PIPESTATUS[0]}
|
||||
set -e # Re-enable exit on error
|
||||
|
||||
if [ $BDD_EXIT_CODE -eq 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user