diff --git a/load-tests/darkwatch-auth/darkwatch-auth.js b/load-tests/darkwatch-auth/darkwatch-auth.js index a0831c9..00dcae7 100644 --- a/load-tests/darkwatch-auth/darkwatch-auth.js +++ b/load-tests/darkwatch-auth/darkwatch-auth.js @@ -268,30 +268,25 @@ export function mixedWorkload() { } // Individual endpoint scenarios — each makes exactly 1 HTTP call per iteration +// NOTE: constant-arrival-rate executor does not pass setup() data to scenario functions. +// Standalone runs always use fake tokens (expected 401/403). For real-token testing, +// run as part of the mixedWorkload scenario or switch to vus executor. export function loginOnly() { testLogin(); sleep(0.1); } -export function logoutOnly(data) { - if (data && data.warmupSuccess) { - testLogout(data.accessToken, data.refreshToken); - } else { - const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)]; - console.warn('[logoutOnly] Using fake token (warmup skipped or failed)'); - testLogout(poolEntry.accessToken, poolEntry.refreshToken); - } +export function logoutOnly() { + const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)]; + console.warn('[logoutOnly] Using fake token (constant-arrival-rate does not pass setup() data)'); + testLogout(poolEntry.accessToken, poolEntry.refreshToken); sleep(0.1); } -export function refreshOnly(data) { - if (data && data.warmupSuccess) { - testRefresh(data.refreshToken); - } else { - const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)]; - console.warn('[refreshOnly] Using fake token (warmup skipped or failed)'); - testRefresh(poolEntry.refreshToken); - } +export function refreshOnly() { + const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)]; + console.warn('[refreshOnly] Using fake token (constant-arrival-rate does not pass setup() data)'); + testRefresh(poolEntry.refreshToken); sleep(0.1); } diff --git a/load-tests/darkwatch-auth/run.sh b/load-tests/darkwatch-auth/run.sh index ec96980..8f8dff7 100755 --- a/load-tests/darkwatch-auth/run.sh +++ b/load-tests/darkwatch-auth/run.sh @@ -28,26 +28,27 @@ echo "Duration: ${DURATION:-300s}" echo "Base URL: ${DARKWATCH_BASE_URL:-http://localhost:3000}" echo "" +EXIT_CODE=0 case "$SCENARIO" in mixed) k6 run darkwatch-auth.js \ --summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \ - --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" + --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" || EXIT_CODE=$? ;; login) k6 run --scenario login_only darkwatch-auth.js \ --summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \ - --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" + --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" || EXIT_CODE=$? ;; logout) k6 run --scenario logout_only darkwatch-auth.js \ --summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \ - --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" + --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" || EXIT_CODE=$? ;; refresh) k6 run --scenario refresh_only darkwatch-auth.js \ --summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \ - --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" + --out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" || EXIT_CODE=$? ;; *) echo "Unknown scenario: $SCENARIO" @@ -56,8 +57,6 @@ case "$SCENARIO" in ;; esac -EXIT_CODE=$? - if [[ $EXIT_CODE -eq 0 ]]; then echo "" echo "✅ All thresholds passed!"