Skip to content

Commit 3ff9ddc

Browse files
committed
tweak: Parallelize insecure-bank, tweak logs storage
1 parent c94c8c9 commit 3ff9ddc

File tree

5 files changed

+93
-75
lines changed

5 files changed

+93
-75
lines changed

.gitlab/benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
name: "reports"
2121
paths:
2222
- reports/
23-
- backup-reports/
23+
- debug-logs/
2424
expire_in: 3 months
2525
variables:
2626
UPSTREAM_PROJECT_ID: $CI_PROJECT_ID # The ID of the current project. This ID is unique across all projects on the GitLab instance.
Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,11 @@
11
{
22
"name": "load_insecure-bank",
33
"setup": "bash -c \"mkdir -p ${OUTPUT_DIR}/${VARIANT}\"",
4-
"service": "bash -c \"${UTILS_DIR}/run-k6-load-test.sh http://localhost:8080/login ${OUTPUT_DIR}/${VARIANT} 'pkill java'\"",
5-
"run": "bash -c \"java ${JAVA_OPTS} -Xms3G -Xmx3G -jar ${INSECURE_BANK} &> ${OUTPUT_DIR}/${VARIANT}/insecure-bank.log\"",
4+
"service": "bash -c \"${CPU_AFFINITY_K6}${UTILS_DIR}/run-k6-load-test.sh http://localhost:8080/login ${OUTPUT_DIR}/${VARIANT} 'pkill java'\"",
5+
"run": "bash -c \"${SCRIPT_DIR}/load/insecure-bank/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-
}
14-
},
15-
"tracing": {
16-
"env": {
17-
"VARIANT": "tracing",
18-
"JAVA_OPTS": "-javaagent:${TRACER}"
19-
}
20-
},
21-
"iast": {
22-
"env": {
23-
"VARIANT": "iast",
24-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.iast.enabled=true"
25-
}
26-
},
27-
"iast_GLOBAL": {
28-
"env": {
29-
"VARIANT": "iast_GLOBAL",
30-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.context.mode=GLOBAL"
31-
}
32-
},
33-
"iast_FULL": {
34-
"env": {
35-
"VARIANT": "iast_FULL",
36-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.detection.mode=FULL"
37-
}
38-
},
39-
"iast_INACTIVE": {
40-
"env": {
41-
"VARIANT": "iast_INACTIVE",
42-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.iast.enabled=inactive"
43-
}
44-
},
45-
"iast_TELEMETRY_OFF": {
46-
"env": {
47-
"VARIANT": "iast_TELEMETRY_OFF",
48-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.telemetry.verbosity=OFF"
49-
}
50-
},
51-
"iast_HARDCODED_SECRET_DISABLED": {
52-
"env": {
53-
"VARIANT": "iast_HARDCODED_SECRET_DISABLED",
54-
"JAVA_OPTS": "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.hardcoded-secret.enabled=false"
55-
}
56-
}
9+
"default": {}
5710
}
5811
}

benchmark/load/insecure-bank/k6.js

Lines changed: 61 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,71 @@
11
import http from 'k6/http';
22
import {checkResponse, isOk, isRedirect} 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+
"iast": {
15+
"APP_URL": 'http://localhost:8083',
16+
},
17+
"iast_GLOBAL": {
18+
"APP_URL": 'http://localhost:8084',
19+
},
20+
"iast_FULL": {
21+
"APP_URL": 'http://localhost:8085',
22+
},
23+
"iast_INACTIVE": {
24+
"APP_URL": 'http://localhost:8086',
25+
},
26+
"iast_TELEMETRY_OFF": {
27+
"APP_URL": 'http://localhost:8087',
28+
},
29+
"iast_HARDCODED_SECRET_DISABLED": {
30+
"APP_URL": 'http://localhost:8088',
31+
},
32+
}
33+
34+
export const options = function (variants) {
35+
let scenarios = {};
36+
for (const variant of Object.keys(variants)) {
37+
scenarios = {
38+
...{
39+
[`load--insecure-bank--${variant}--warmup`]: {
40+
executor: 'constant-vus', // https://grafana.com/docs/k6/latest/using-k6/scenarios/executors/#all-executors
41+
vus: 5,
42+
duration: '10s',
43+
gracefulStop: '2s',
44+
env: { ...variants[variant] }
45+
},
46+
[`load--insecure-bank--${variant}--high_load`]: {
47+
executor: 'constant-vus',
48+
vus: 5,
49+
startTime: '12s',
50+
duration: '20s',
51+
gracefulStop: '2s',
52+
env: { ...variants[variant] }
53+
},
54+
},
55+
...scenarios
56+
};
57+
}
558

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

2565
export default function () {
2666

2767
// login form
28-
const loginResponse = http.post(`${baseUrl}/login`, {
68+
const loginResponse = http.post(`${__ENV.APP_URL}/login`, {
2969
username: 'john',
3070
password: 'test'
3171
}, {
@@ -34,11 +74,11 @@ export default function () {
3474
checkResponse(loginResponse, isRedirect);
3575

3676
// dashboard
37-
const dashboard = http.get(`${baseUrl}/dashboard`);
77+
const dashboard = http.get(`${__ENV.APP_URL}/dashboard`);
3878
checkResponse(dashboard, isOk);
3979

4080
// logout
41-
const logout = http.get(`${baseUrl}/j_spring_security_logout`, {
81+
const logout = http.get(`${__ENV.APP_URL}/j_spring_security_logout`, {
4282
redirects: 0
4383
});
4484
checkResponse(logout, isRedirect);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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} -Xms3G -Xmx3G -jar ${INSECURE_BANK} &> ${OUTPUT_DIR}/${VARIANT}/insecure-bank.log
16+
}
17+
18+
start_server "${NO_AGENT_VARIANT}" "-Dserver.port=8080" "taskset -c 47 " &
19+
start_server "tracing" "-javaagent:${TRACER} -Dserver.port=8081" "taskset -c 46 " &
20+
start_server "profiling" "-javaagent:${TRACER} -Ddd.profiling.enabled=true -Dserver.port=8082" "taskset -c 45 " &
21+
start_server "iast" "-javaagent:${TRACER} -Ddd.iast.enabled=true -Dserver.port=8083" "taskset -c 44 " &
22+
start_server "iast_GLOBAL" "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.context.mode=GLOBAL -Dserver.port=8084" "taskset -c 43 " &
23+
start_server "iast_FULL" "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.detection.mode=FULL -Dserver.port=8085" "taskset -c 42 " &
24+
start_server "iast_INACTIVE" "-javaagent:${TRACER} -Ddd.iast.enabled=inactive -Dserver.port=8086" "taskset -c 41 " &
25+
start_server "iast_TELEMETRY_OFF" "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.telemetry.verbosity=OFF -Dserver.port=8087" "taskset -c 40 " &
26+
start_server "iast_HARDCODED_SECRET_DISABLED" "-javaagent:${TRACER} -Ddd.iast.enabled=true -Ddd.iast.hardcoded-secret.enabled=false -Dserver.port=8088" "taskset -c 39 " &
27+
28+
wait

benchmark/utils/run-sirun-benchmarks.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ run_benchmark() {
2828

2929
message "${type} benchmark: ${app} finished"
3030

31-
mkdir -p "${ARTIFACTS_DIR}/../backup-reports/"
32-
cp -r "${REPORTS_DIR}" "${ARTIFACTS_DIR}/../backup-reports/"
33-
3431
cd ..
3532
fi
3633
}

0 commit comments

Comments
 (0)