Skip to content

Commit 8316350

Browse files
committed
Create hyperfoil yaml rather than running wrk directly
1 parent 820d67b commit 8316350

File tree

2 files changed

+123
-25
lines changed

2 files changed

+123
-25
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# =============================================================================
2+
# Hyperfoil Load Test Configuration
3+
# =============================================================================
4+
#
5+
# This configuration file defines a load test scenario for the application
6+
# endpoint. It includes a warmup phase followed by a main load test phase,
7+
# both targeting the same HTTP endpoint.
8+
#
9+
# Configurable Parameters:
10+
# ----------------------------------
11+
# PROTOCOL - HTTP protocol to use (default: http)
12+
# Options: http, https
13+
# HOST - Target server hostname (default: localhost)
14+
# PORT - Target server port (default: 8080)
15+
# SHARED_CONNECTIONS - Number of shared HTTP connections in the pool (default: 100)
16+
# PATH - HTTP endpoint path to test (default: /fruits)
17+
# WARMUP_USERS - Number of concurrent users during warmup phase (default: 2)
18+
# WARMUP_DURATION - Duration of the warmup phase (default: 2m)
19+
# LOAD_USERS - Number of concurrent users during main load test (default: 2)
20+
# LOAD_DURATION - Duration of the main load test phase (default: 30s)
21+
#
22+
# Usage:
23+
# ------
24+
# Override parameters using: -P PARAM_NAME=value
25+
# Example: jbang run@hyperfoil -PHOST=example.com -PPORT=443 -PPROTOCOL=https app-load-test.hf.yml
26+
#
27+
# =============================================================================
28+
29+
name: app-load-test
30+
http:
31+
- protocol: !param PROTOCOL http
32+
host: !param HOST localhost
33+
port: !param PORT 8080
34+
sharedConnections: !param SHARED_CONNECTIONS 100
35+
36+
phases:
37+
- loadTest:
38+
always:
39+
users: !param LOAD_USERS 50
40+
duration: !param LOAD_DURATION 30s
41+
startAfter: warmup
42+
scenario:
43+
- loadTest: &loadTest
44+
- httpRequest:
45+
GET: !param PATH /fruits
46+
headers:
47+
accept: application/json
48+
49+
- warmup:
50+
always:
51+
users: !param WARMUP_USERS 50
52+
duration: !param WARMUP_DURATION 2m
53+
scenario:
54+
- loadTest: *loadTest
55+

scripts/perf-lab/main.yml

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ scripts:
120120
- sh: echo $(realpath ~)
121121
- set-state: RUN.BASE_DIR
122122
- set-state: RUN.REPO_DIR ${{BASE_DIR}}/spring-quarkus-perf-comparison
123+
- set-state: RUN.HYPERFOIL_LOGS_DIR ${{REPO_DIR}}/logs/hyperfoil
123124
- set-state: RUN.PROJ_REPO_DIR ${{REPO_DIR}}/${{PROJ_REPO_NAME}}
124125
- set-state: RUN.SCRIPTS_DIR ${{PROJ_REPO_DIR}}/scripts/perf-lab
125126
- set-state: RUN.HELPER_SCRIPTS_DIR ${{SCRIPTS_DIR}}/scripts
@@ -134,6 +135,7 @@ scripts:
134135
"ENV: ${{env}}"
135136
"BASE_DIR: ${{BASE_DIR}}"
136137
"REPO_DIR: ${{REPO_DIR}}"
138+
"HYPERFOIL_LOGS_DIR: ${{HYPERFOIL_LOGS_DIR}}"
137139
"SCRIPTS_DIR: ${{SCRIPTS_DIR}}"
138140
"SPRING3_BOOT_DIR: ${{SPRING3_BOOT_DIR}}"
139141
"SPRING4_BOOT_DIR: ${{SPRING4_BOOT_DIR}}"
@@ -155,6 +157,7 @@ scripts:
155157
with:
156158
command: rm -Rf ${{REPO_DIR}}/logs
157159
- sh: mkdir -p ${{REPO_DIR}}/logs
160+
- sh: mkdir -p ${{HYPERFOIL_LOGS_DIR}}
158161

159162
clone-repo:
160163
- script: sudo
@@ -381,6 +384,7 @@ scripts:
381384
- log: Running workload
382385
- sh: cd ${{RUNTIME.dir}}
383386
- sh: ${{RUNTIME.buildCmd}}
387+
- queue-download: ${{HYPERFOIL_LOGS_DIR}}
384388
- set-state:
385389
key: APP_LOG_REGEX
386390
value: ${{RUNTIME.logFileStartedRegex}}
@@ -390,9 +394,9 @@ scripts:
390394
key: LOG_FILE
391395
value: ${{REPO_DIR}}/logs/load-test-${{RUNTIME.name}}-${{ITERATION}}.log
392396
- sh: touch ${{LOG_FILE}}
393-
- queue-download: ${{REPO_DIR}}/logs/wrk-warmup-${{RUNTIME.name}}-${{ITERATION}}.log
397+
- sh: mkdir -p ${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}}
398+
- queue-download: ${{REPO_DIR}}/logs/hf-${{RUNTIME.name}}-${{ITERATION}}.log
394399
- queue-download: ${{LOG_FILE}}
395-
- queue-download: ${{REPO_DIR}}/logs/wrk-${{RUNTIME.name}}-${{ITERATION}}.log
396400
- script: start-test-services
397401
- script: sync-drop-fs-cache
398402
- set-signal: LOAD_STEADY_STATE_START 1
@@ -431,39 +435,78 @@ scripts:
431435
log_file: ${{LOG_FILE}}
432436
log_regex: ${{APP_LOG_REGEX}}
433437
- wait-for: LOG_REGEX_REACHED
434-
- sh: ${{RUN.WRK_BIN}} -t 2 -c 100 -d 2m --timeout 2m ${{TARGET_URL}} 2>&1 >${{REPO_DIR}}/logs/wrk-warmup-${{RUNTIME.name}}-${{ITERATION}}.log
435-
- regex: unable to connect
436-
then:
437-
- abort: unable to connect to target application
438-
- sleep: 30s # Wait for the app to complete warmup
439438
- signal: LOAD_STEADY_STATE_START
440-
- sh: ${{RUN.WRK_BIN}} -t 2 -c 100 -d 30s --timeout 30s ${{TARGET_URL}} 2>&1 >${{REPO_DIR}}/logs/wrk-${{RUNTIME.name}}-${{ITERATION}}.log
441-
- sh: cat ${{REPO_DIR}}/logs/wrk-${{RUNTIME.name}}-${{ITERATION}}.log | grep "Requests/sec" | awk '{print $2}'
439+
- sh: |
440+
${{LOAD_GEN_CMD_PREFIX}} jbang \
441+
-Dio.hyperfoil.rootdir=${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}} \
442+
-R \
443+
-XX:+UseNUMA \
444+
run@hyperfoil \
445+
-d ${{RUNTIME.name}}-${{ITERATION}} \
446+
-o ${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}} \
447+
${{SCRIPTS_DIR}}/app-load-test.hf.yml 2>&1 >${{REPO_DIR}}/logs/hf-${{RUNTIME.name}}-${{ITERATION}}.log
448+
- sh: cat ${{REPO_DIR}}/logs/hf-${{RUNTIME.name}}-${{ITERATION}}.log | grep "Started run" | awk '{print $3}'
442449
then:
443-
- set-state: THROUGHPUT
444-
- script: state-array-push
445-
with:
446-
array: RUN.output.results.${{RUNTIME.name}}.load.throughput
447-
value: ${{THROUGHPUT}}
448-
- sh: cat ${{REPO_DIR}}/logs/wrk-${{RUNTIME.name}}-${{ITERATION}}.log | grep "Socket errors:" | sed -E 's/.*connectionErrors ([0-9]+).*/\1/'
450+
- set-state:
451+
key: RUN_NUM
452+
autoConvert: false
453+
454+
- sh: cat ${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}}/run/${{RUN_NUM}}/all.json
455+
then:
456+
- set-state: HF_OUTPUT
457+
- read-state: ${{HF_OUTPUT}}
449458
then:
450-
- regex: ^$
459+
- json: $.info.startTime
451460
then:
452-
- set-state: CONNECTION_ERRORS 0
461+
- set-state: START_TIME
453462
else:
463+
- abort: Unable to find startTime in ${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}}/run/${{RUN_NUM}}/all.json
464+
- read-state: ${{HF_OUTPUT}}
465+
then:
466+
- json: $.info.terminateTime
467+
then:
468+
- set-state: TERMINATE_TIME
469+
else:
470+
- abort: Unable to find terminateTime in ${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}}/run/${{RUN_NUM}}/all.json
471+
- read-state: ${{HF_OUTPUT}}
472+
then:
473+
- json: $.stats[?(@.phase == 'loadTest')].total.summary
474+
then:
475+
- set-state: SUMMARY
476+
else:
477+
- abort: Unable to find summary in ${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}}/run/${{RUN_NUM}}/all.json
478+
- read-state: ${{SUMMARY}}
479+
then:
480+
- json: $.requestCount
481+
then:
482+
- set-state: REQUEST_COUNT
483+
else:
484+
- abort: Unable to find request count in ${{HYPERFOIL_LOGS_DIR}}/${{RUNTIME.name}}-${{ITERATION}}/run/${{RUN_NUM}}/all.json
485+
- read-state: ${{SUMMARY}}
486+
then:
487+
- json: $.connectionErrors
488+
then:
454489
- set-state: CONNECTION_ERRORS
490+
else:
491+
- set-state: CONNECTION_ERRORS 0
492+
- read-state: ${{SUMMARY}}
493+
then:
494+
- json: $.requestTimeouts
495+
then:
496+
- set-state: REQUEST_TIMEOUTS
497+
else:
498+
- set-state: REQUEST_TIMEOUTS 0
499+
- set-state:
500+
key: THROUGHPUT
501+
value: ${{= ${{REQUEST_COUNT}}/((${{TERMINATE_TIME}}-${{START_TIME}})/1000) }}
502+
- script: state-array-push
503+
with:
504+
array: RUN.output.results.${{RUNTIME.name}}.load.throughput
505+
value: ${{THROUGHPUT}}
455506
- script: state-array-push
456507
with:
457508
array: RUN.output.results.${{RUNTIME.name}}.load.connectionErrors
458509
value: ${{CONNECTION_ERRORS}}
459-
460-
- sh: cat ${{REPO_DIR}}/logs/wrk-${{RUNTIME.name}}-${{ITERATION}}.log | grep "Socket errors:" | sed -E 's/.*requestTimeouts ([0-9]+)/\1/'
461-
then:
462-
- regex: ^$
463-
then:
464-
- set-state: REQUEST_TIMEOUTS 0
465-
else:
466-
- set-state: REQUEST_TIMEOUTS
467510
- script: state-array-push
468511
with:
469512
array: RUN.output.results.${{RUNTIME.name}}.load.requestTimeouts

0 commit comments

Comments
 (0)