Fix FRE-4928 P1 review findings: setup() data passing, EXIT_CODE capture
- P1#1: Document constant-arrival-rate limitation (no setup() data to scenarios) - P1#2: Capture EXIT_CODE inside each case branch to avoid set -e truncation Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -268,30 +268,25 @@ export function mixedWorkload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Individual endpoint scenarios — each makes exactly 1 HTTP call per iteration
|
// 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() {
|
export function loginOnly() {
|
||||||
testLogin();
|
testLogin();
|
||||||
sleep(0.1);
|
sleep(0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logoutOnly(data) {
|
export function logoutOnly() {
|
||||||
if (data && data.warmupSuccess) {
|
const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)];
|
||||||
testLogout(data.accessToken, data.refreshToken);
|
console.warn('[logoutOnly] Using fake token (constant-arrival-rate does not pass setup() data)');
|
||||||
} else {
|
testLogout(poolEntry.accessToken, poolEntry.refreshToken);
|
||||||
const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)];
|
|
||||||
console.warn('[logoutOnly] Using fake token (warmup skipped or failed)');
|
|
||||||
testLogout(poolEntry.accessToken, poolEntry.refreshToken);
|
|
||||||
}
|
|
||||||
sleep(0.1);
|
sleep(0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function refreshOnly(data) {
|
export function refreshOnly() {
|
||||||
if (data && data.warmupSuccess) {
|
const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)];
|
||||||
testRefresh(data.refreshToken);
|
console.warn('[refreshOnly] Using fake token (constant-arrival-rate does not pass setup() data)');
|
||||||
} else {
|
testRefresh(poolEntry.refreshToken);
|
||||||
const poolEntry = tokenPool[Math.floor(Math.random() * tokenPool.length)];
|
|
||||||
console.warn('[refreshOnly] Using fake token (warmup skipped or failed)');
|
|
||||||
testRefresh(poolEntry.refreshToken);
|
|
||||||
}
|
|
||||||
sleep(0.1);
|
sleep(0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,26 +28,27 @@ echo "Duration: ${DURATION:-300s}"
|
|||||||
echo "Base URL: ${DARKWATCH_BASE_URL:-http://localhost:3000}"
|
echo "Base URL: ${DARKWATCH_BASE_URL:-http://localhost:3000}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
EXIT_CODE=0
|
||||||
case "$SCENARIO" in
|
case "$SCENARIO" in
|
||||||
mixed)
|
mixed)
|
||||||
k6 run darkwatch-auth.js \
|
k6 run darkwatch-auth.js \
|
||||||
--summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \
|
--summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \
|
||||||
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json"
|
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" || EXIT_CODE=$?
|
||||||
;;
|
;;
|
||||||
login)
|
login)
|
||||||
k6 run --scenario login_only darkwatch-auth.js \
|
k6 run --scenario login_only darkwatch-auth.js \
|
||||||
--summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \
|
--summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \
|
||||||
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json"
|
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" || EXIT_CODE=$?
|
||||||
;;
|
;;
|
||||||
logout)
|
logout)
|
||||||
k6 run --scenario logout_only darkwatch-auth.js \
|
k6 run --scenario logout_only darkwatch-auth.js \
|
||||||
--summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \
|
--summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \
|
||||||
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json"
|
--out json="$OUTPUT_DIR/results-${TIMESTAMP}.json" || EXIT_CODE=$?
|
||||||
;;
|
;;
|
||||||
refresh)
|
refresh)
|
||||||
k6 run --scenario refresh_only darkwatch-auth.js \
|
k6 run --scenario refresh_only darkwatch-auth.js \
|
||||||
--summary-export "$OUTPUT_DIR/summary-${TIMESTAMP}.json" \
|
--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"
|
echo "Unknown scenario: $SCENARIO"
|
||||||
@@ -56,8 +57,6 @@ case "$SCENARIO" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
EXIT_CODE=$?
|
|
||||||
|
|
||||||
if [[ $EXIT_CODE -eq 0 ]]; then
|
if [[ $EXIT_CODE -eq 0 ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "✅ All thresholds passed!"
|
echo "✅ All thresholds passed!"
|
||||||
|
|||||||
Reference in New Issue
Block a user