Skip to content

Commit 6fd7205

Browse files
committed
Make request timeout a parameter
1 parent d305a2a commit 6fd7205

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.github/workflows/benchmark.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ on:
1919
required: false
2020
default: 10
2121
type: number
22+
request_timeout:
23+
description: 'Request timeout (e.g., "60s", "1m", "90s")'
24+
required: false
25+
default: '60s'
26+
type: string
2227
vus:
2328
description: 'Virtual users for k6'
2429
required: false
@@ -41,6 +46,7 @@ env:
4146
# Benchmark parameters
4247
RATE: ${{ github.event.inputs.rate || '50' }}
4348
DURATION_SEC: ${{ github.event.inputs.duration_sec || '10' }}
49+
REQUEST_TIMEOUT: ${{ github.event.inputs.request_timeout || '60s' }}
4450
VUS: ${{ github.event.inputs.vus || '100' }}
4551
TOOLS: ${{ github.event.inputs.tools || 'fortio,vegeta,k6' }}
4652

spec/performance/bench.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ RATE=${RATE:-50}
1010
VUS=${VUS:-100}
1111
DURATION_SEC=${DURATION_SEC:-10}
1212
DURATION="${DURATION_SEC}s"
13+
# request timeout (duration string like "60s", "1m", "90s")
14+
REQUEST_TIMEOUT=${REQUEST_TIMEOUT:-60s}
1315
# Tools to run (comma-separated)
1416
TOOLS=${TOOLS:-fortio,vegeta,k6}
1517

@@ -26,6 +28,10 @@ if ! { [[ "$DURATION_SEC" =~ ^[0-9]+(\.[0-9]+)?$ ]] && (( $(bc -l <<< "$DURATION
2628
echo "Error: DURATION_SEC must be a positive number (got: '$DURATION_SEC')" >&2
2729
exit 1
2830
fi
31+
if ! [[ "$REQUEST_TIMEOUT" =~ ^([0-9]+(\.[0-9]+)?[smh])+$ ]]; then
32+
echo "Error: REQUEST_TIMEOUT must be a duration like '60s', '1m', '1.5m' (got: '$REQUEST_TIMEOUT')" >&2
33+
exit 1
34+
fi
2935

3036
OUTDIR="bench_results"
3137

@@ -92,14 +98,14 @@ fi
9298
if (( RUN_FORTIO )); then
9399
echo "===> Fortio"
94100
# TODO https://github.com/fortio/fortio/wiki/FAQ#i-want-to-get-the-best-results-what-flags-should-i-pass
95-
fortio load "${FORTIO_ARGS[@]}" -t "$DURATION" -timeout 30s -json "$OUTDIR/fortio.json" "$TARGET" \
101+
fortio load "${FORTIO_ARGS[@]}" -t "$DURATION" -timeout "$REQUEST_TIMEOUT" -json "$OUTDIR/fortio.json" "$TARGET" \
96102
| tee "$OUTDIR/fortio.txt"
97103
fi
98104

99105
if (( RUN_VEGETA )); then
100106
echo
101107
echo "===> Vegeta"
102-
echo "GET $TARGET" | vegeta attack "${VEGETA_ARGS[@]}" -duration="$DURATION" \
108+
echo "GET $TARGET" | vegeta attack "${VEGETA_ARGS[@]}" -duration="$DURATION" -timeout="$REQUEST_TIMEOUT" \
103109
| tee "$OUTDIR/vegeta.bin" \
104110
| vegeta report | tee "$OUTDIR/vegeta.txt"
105111
vegeta report -type=json "$OUTDIR/vegeta.bin" > "$OUTDIR/vegeta.json"
@@ -114,6 +120,9 @@ import { check } from 'k6';
114120
115121
export const options = {
116122
scenarios: $K6_SCENARIOS,
123+
httpReq: {
124+
timeout: '$REQUEST_TIMEOUT',
125+
},
117126
};
118127
119128
export default function () {

0 commit comments

Comments
 (0)