@@ -10,6 +10,8 @@ RATE=${RATE:-50}
1010VUS=${VUS:- 100}
1111DURATION_SEC=${DURATION_SEC:- 10}
1212DURATION=" ${DURATION_SEC} s"
13+ # request timeout (duration string like "60s", "1m", "90s")
14+ REQUEST_TIMEOUT=${REQUEST_TIMEOUT:- 60s}
1315# Tools to run (comma-separated)
1416TOOLS=${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
2830fi
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
3036OUTDIR=" bench_results"
3137
9298if (( 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"
97103fi
98104
99105if (( 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
115121export const options = {
116122 scenarios: $K6_SCENARIOS ,
123+ httpReq: {
124+ timeout: '$REQUEST_TIMEOUT ',
125+ },
117126};
118127
119128export default function () {
0 commit comments