@@ -6,8 +6,10 @@ set -euo pipefail
66TARGET=" http://${BASE_URL:- localhost: 3001} /${ROUTE:- server_side_hello_world_hooks} "
77# requests per second; if "max" will get maximum number of queries instead of a fixed rate
88RATE=${RATE:- 50}
9- # virtual users for k6
10- VUS=${VUS:- 100}
9+ # concurrent connections/virtual users
10+ CONNECTIONS=${CONNECTIONS:- 10}
11+ # maximum connections/virtual users
12+ MAX_CONNECTIONS=${MAX_CONNECTIONS:- $CONNECTIONS }
1113DURATION_SEC=${DURATION_SEC:- 10}
1214DURATION=" ${DURATION_SEC} s"
1315# request timeout (duration string like "60s", "1m", "90s")
@@ -20,8 +22,12 @@ if ! { [ "$RATE" = "max" ] || { [[ "$RATE" =~ ^[0-9]+(\.[0-9]+)?$ ]] && (( $(bc
2022 echo " Error: RATE must be 'max' or a positive number (got: '$RATE ')" >&2
2123 exit 1
2224fi
23- if ! { [[ " $VUS " =~ ^[0-9]+$ ]] && [ " $VUS " -gt 0 ]; }; then
24- echo " Error: VUS must be a positive integer (got: '$VUS ')" >&2
25+ if ! { [[ " $CONNECTIONS " =~ ^[0-9]+$ ]] && [ " $CONNECTIONS " -gt 0 ]; }; then
26+ echo " Error: CONNECTIONS must be a positive integer (got: '$CONNECTIONS ')" >&2
27+ exit 1
28+ fi
29+ if ! { [[ " $MAX_CONNECTIONS " =~ ^[0-9]+$ ]] && [ " $MAX_CONNECTIONS " -gt 0 ]; }; then
30+ echo " Error: MAX_CONNECTIONS must be a positive integer (got: '$MAX_CONNECTIONS ')" >&2
2531 exit 1
2632fi
2733if ! { [[ " $DURATION_SEC " =~ ^[0-9]+ (\. [0-9]+)? $ ]] && (( $(bc - l <<< "$DURATION_SEC > 0 ") )) ; }; then
@@ -70,27 +76,31 @@ echo "Warm-up complete"
7076mkdir -p " $OUTDIR "
7177
7278if [ " $RATE " = " max" ]; then
73- FORTIO_ARGS=(-qps 0)
74- VEGETA_ARGS=(-rate=infinity)
79+ if [ " $CONNECTIONS " != " $MAX_CONNECTIONS " ]; then
80+ echo " For RATE=max, CONNECTIONS (got $CONNECTIONS ) and MAX_CONNECTIONS (got $MAX_CONNECTIONS ) should be the same"
81+ exit 1
82+ fi
83+ FORTIO_ARGS=(-qps 0 -c " $CONNECTIONS " )
84+ VEGETA_ARGS=(-rate=infinity --workers=" $CONNECTIONS " --max-workers=" $CONNECTIONS " )
7585 K6_SCENARIOS=" {
7686 max_rate: {
7787 executor: 'shared-iterations',
78- vus: $VUS ,
79- iterations: $(( VUS * DURATION_SEC * 10 )) ,
88+ vus: $CONNECTIONS ,
89+ iterations: $(( CONNECTIONS * DURATION_SEC * 10 )) ,
8090 maxDuration: '$DURATION '
8191 }
8292 }"
8393else
84- FORTIO_ARGS=(-qps " $RATE " -uniform)
85- VEGETA_ARGS=(-rate=" $RATE " )
94+ FORTIO_ARGS=(-qps " $RATE " -uniform -c " $CONNECTIONS " )
95+ VEGETA_ARGS=(-rate=" $RATE " --workers= " $CONNECTIONS " --max-workers= " $MAX_CONNECTIONS " )
8696 K6_SCENARIOS=" {
8797 constant_rate: {
8898 executor: 'constant-arrival-rate',
8999 rate: $RATE ,
90100 timeUnit: '1s',
91101 duration: '$DURATION ',
92- preAllocatedVUs: $VUS ,
93- maxVUs: $(( VUS * 10 ))
102+ preAllocatedVUs: $CONNECTIONS ,
103+ maxVUs: $MAX_CONNECTIONS
94104 }
95105 }"
96106fi
0 commit comments