Skip to content

Commit c94c8c9

Browse files
committed
tweak: Parallelize load tests
1 parent 6939ad5 commit c94c8c9

File tree

5 files changed

+89
-72
lines changed

5 files changed

+89
-72
lines changed

benchmark/load/insecure-bank/k6.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ export const options = {
99
[`load--insecure-bank--${__ENV.VARIANT}--warmup`]: {
1010
executor: 'constant-vus', // https://grafana.com/docs/k6/latest/using-k6/scenarios/executors/#all-executors
1111
vus: 5,
12-
duration: '15s',
13-
gracefulStop: '5s',
12+
duration: '10s',
13+
gracefulStop: '2s',
1414
},
1515
[`load--insecure-bank--${__ENV.VARIANT}--high_load`]: {
1616
executor: 'constant-vus',
1717
vus: 5,
18-
startTime: '15s',
18+
startTime: '12s',
1919
duration: '20s',
20-
gracefulStop: '5s',
20+
gracefulStop: '2s',
2121
},
2222
}
2323
};

benchmark/load/petclinic/benchmark.json

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,10 @@
22
"name": "load_petclinic",
33
"setup": "bash -c \"mkdir -p ${OUTPUT_DIR}/${VARIANT}\"",
44
"service": "bash -c \"${CPU_AFFINITY_K6}${UTILS_DIR}/run-k6-load-test.sh http://localhost:8080 ${OUTPUT_DIR}/${VARIANT} 'pkill java'\"",
5-
"run": "bash -c \"${CPU_AFFINITY_APP}java ${JAVA_OPTS} -Xms2G -Xmx2G -jar ${PETCLINIC} &> ${OUTPUT_DIR}/${VARIANT}/petclinic.log\"",
5+
"run": "bash -c \"${SCRIPT_DIR}/load/petclinic/start-servers.sh\"",
66
"timeout": 150,
77
"iterations": 1,
88
"variants": {
9-
"${NO_AGENT_VARIANT}": {
10-
"env": {
11-
"VARIANT": "${NO_AGENT_VARIANT}",
12-
"JAVA_OPTS": "",
13-
"CPU_AFFINITY_K6": "taskset -c 24-30 ",
14-
"CPU_AFFINITY_APP": "taskset -c 31-32 "
15-
}
16-
},
17-
"tracing": {
18-
"env": {
19-
"VARIANT": "tracing",
20-
"JAVA_OPTS": "-javaagent:${TRACER}",
21-
"CPU_AFFINITY_K6": "taskset -c 24-30 ",
22-
"CPU_AFFINITY_APP": "taskset -c 33-34 "
23-
}
24-
},
25-
"profiling": {
26-
"env": {
27-
"VARIANT": "profiling",
28-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.profiling.enabled=true",
29-
"CPU_AFFINITY_K6": "taskset -c 24-30 ",
30-
"CPU_AFFINITY_APP": "taskset -c 35-36 "
31-
}
32-
},
33-
"appsec": {
34-
"env": {
35-
"VARIANT": "appsec",
36-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.appsec.enabled=true",
37-
"CPU_AFFINITY_K6": "taskset -c 24-30 ",
38-
"CPU_AFFINITY_APP": "taskset -c 37-38 "
39-
}
40-
},
41-
"iast": {
42-
"env": {
43-
"VARIANT": "iast",
44-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.iast.enabled=true",
45-
"CPU_AFFINITY_K6": "taskset -c 24-30 ",
46-
"CPU_AFFINITY_APP": "taskset -c 39-40 "
47-
}
48-
},
49-
"code_origins": {
50-
"env": {
51-
"VARIANT": "code_origins",
52-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.code.origin.for.spans.enabled=true",
53-
"CPU_AFFINITY_K6": "taskset -c 24-30 ",
54-
"CPU_AFFINITY_APP": "taskset -c 41-42 "
55-
}
56-
}
9+
"default": {}
5710
}
5811
}

benchmark/load/petclinic/k6.js

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,61 @@
11
import http from 'k6/http';
22
import {checkResponse, isOk} from "../../utils/k6.js";
33

4-
const baseUrl = 'http://localhost:8080';
4+
const variants = {
5+
"no_agent": {
6+
"APP_URL": 'http://localhost:8080',
7+
},
8+
"tracing": {
9+
"APP_URL": 'http://localhost:8081',
10+
},
11+
"profiling": {
12+
"APP_URL": 'http://localhost:8082',
13+
},
14+
"appsec": {
15+
"APP_URL": 'http://localhost:8083',
16+
},
17+
"iast": {
18+
"APP_URL": 'http://localhost:8084',
19+
},
20+
"code_origins": {
21+
"APP_URL": 'http://localhost:8085',
22+
}
23+
}
24+
25+
export const options = function (variants) {
26+
let scenarios = {};
27+
for (const variant of Object.keys(variants)) {
28+
scenarios = {
29+
...{
30+
[`load--petclinic--${variant}--warmup`]: {
31+
executor: 'constant-vus', // https://grafana.com/docs/k6/latest/using-k6/scenarios/executors/#all-executors
32+
vus: 5,
33+
duration: '10s',
34+
gracefulStop: '2s',
35+
env: { ...variants[variant] }
36+
},
37+
[`load--petclinic--${variant}--high_load`]: {
38+
executor: 'constant-vus',
39+
vus: 5,
40+
startTime: '12s',
41+
duration: '20s',
42+
gracefulStop: '2s',
43+
env: { ...variants[variant] }
44+
},
45+
},
46+
...scenarios
47+
};
48+
}
549

6-
export const options = {
7-
discardResponseBodies: true,
8-
scenarios: {
9-
[`load--petclinic--${__ENV.VARIANT}--warmup`]: {
10-
executor: 'constant-vus', // https://grafana.com/docs/k6/latest/using-k6/scenarios/executors/#all-executors
11-
vus: 5,
12-
duration: '15s',
13-
gracefulStop: '5s',
14-
},
15-
[`load--petclinic--${__ENV.VARIANT}--high_load`]: {
16-
executor: 'constant-vus',
17-
vus: 5,
18-
startTime: '15s',
19-
duration: '20s',
20-
gracefulStop: '5s',
21-
},
50+
return {
51+
discardResponseBodies: true,
52+
scenarios,
2253
}
23-
};
54+
}(variants);
2455

2556
export default function () {
2657

2758
// find owner
28-
const ownersList = http.get(`${baseUrl}/owners?lastName=`);
59+
const ownersList = http.get(`${__ENV.APP_URL}/owners?lastName=`);
2960
checkResponse(ownersList, isOk);
3061
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
start_server() {
5+
local VARIANT=$1
6+
local JAVA_OPTS=$2
7+
8+
if [ -n "$CI_JOB_TOKEN" ]; then
9+
# Inside BP, so we can assume 24 CPU cores available and set CPU affinity
10+
CPU_AFFINITY_APP=$3
11+
else
12+
CPU_AFFINITY_APP=""
13+
fi
14+
15+
${CPU_AFFINITY_APP}java ${JAVA_OPTS} -Xms2G -Xmx2G -jar ${PETCLINIC} &> ${OUTPUT_DIR}/${VARIANT}/petclinic.log
16+
}
17+
18+
start_server "${NO_AGENT_VARIANT}" "-Dserver.port=8080" "taskset -c 31-32 " &
19+
start_server "tracing" "-javaagent:${TRACER} -Dserver.port=8081" "taskset -c 33-34 " &
20+
start_server "profiling" "-javaagent:${TRACER} -Ddd.profiling.enabled=true -Dserver.port=8082" "taskset -c 35-36 " &
21+
start_server "appsec" "-javaagent:${TRACER} -Ddd.appsec.enabled=true -Dserver.port=8083" "taskset -c 37-38 " &
22+
start_server "iast" "-javaagent:${TRACER} -Ddd.iast.enabled=true -Dserver.port=8084" "taskset -c 39-40 " &
23+
start_server "code_origins" "-javaagent:${TRACER} -Ddd.code.origin.for.spans.enabled=true -Dserver.port=8085" "taskset -c 41-42 " &
24+
25+
wait

benchmark/load/run.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22
set -eu
33

44
source "${UTILS_DIR}/update-java-version.sh" 17
5+
6+
if [ -n "$CI_JOB_TOKEN" ]; then
7+
# Inside BP, so we can assume 24 CPU cores available and set CPU affinity
8+
export CPU_AFFINITY_K6="taskset -c 24-30 "
9+
else
10+
export CPU_AFFINITY_K6=""
11+
fi
12+
513
"${UTILS_DIR}/run-sirun-benchmarks.sh" "$@"

0 commit comments

Comments
 (0)