Skip to content

Commit ee13b38

Browse files
authored
feat: parameterize scenarios (#368)
1 parent 05bdeeb commit ee13b38

File tree

4 files changed

+60
-49
lines changed

4 files changed

+60
-49
lines changed

k6/k6-runner/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ config:
88

99
.PHONY: run_job
1010
run_job:
11-
oc -n $(NAMESPACE) process -f ./openshift/k6/dc.yaml -p DB_PASSWORD=$(DB_PASSWORD) -p DB_USER=$(DB_USER) | oc -n $(NAMESPACE) apply -f -
11+
oc -n $(NAMESPACE) process -f ./openshift/k6/dc.yaml -p DB_PASSWORD=$(DB_PASSWORD) -p DB_USER=$(DB_USER) -p SCENARIO=$(SCENARIO) | oc -n $(NAMESPACE) apply -f -
1212

1313
.PHONY: cleanup
1414
cleanup:

k6/k6-runner/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
export DB_USER=
1717
export DB_PASSWORD=
1818

19+
# one of ('peakProfile', 'stressProfile', 'soakProfile')
20+
export SCENARIO=
21+
1922
# create configmap with all the configurations
2023
make config
2124

k6/k6-runner/openshift/k6/dc.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ objects:
2424
env:
2525
- name: K6_OUT
2626
value: 'timescaledb=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}'
27+
- name: SCENARIO
28+
value: ${SCENARIO}
2729
resources:
2830
limits:
2931
cpu: 2
@@ -59,3 +61,6 @@ parameters:
5961
value: 'k6-patroni'
6062
- name: DB_PORT
6163
value: '5432'
64+
- name: SCENARIO
65+
required: true
66+
description: The name of the scenario (peakProfile, stressProfile, and soakProfile) to run

k6/k6-runner/src/tests/constantRateAllFlows.js

Lines changed: 51 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { user, client } from './constants.js';
1313
import exec from 'k6/execution';
1414

1515
let config = JSON.parse(open(__ENV.CONFIG));
16+
let scenario = __ENV.SCENARIO;
1617
const username = config.kcLoadTest.username;
1718
const password = config.kcLoadTest.password;
1819
const clientId = config.kcLoadTest.clientId;
@@ -30,57 +31,59 @@ const formattedDate = `${date.getFullYear()}${('0' + (date.getMonth() + 1)).slic
3031
-2,
3132
)}${date.getHours()}${('0' + date.getMinutes()).slice(-2)}`;
3233

33-
export const options = {
34-
scenarios: {
35-
peakProfile: {
36-
executor: 'constant-arrival-rate',
37-
duration: '2m',
38-
timeUnit: '1m',
39-
rate: 34,
40-
preAllocatedVUs: 5,
41-
tags: {
42-
profile: 'peak-2h-34',
43-
},
34+
const scenarios = {
35+
peakProfile: {
36+
executor: 'constant-arrival-rate',
37+
duration: '2h',
38+
timeUnit: '1m',
39+
rate: 34,
40+
preAllocatedVUs: 5,
41+
tags: {
42+
profile: 'peak',
43+
},
44+
},
45+
stressProfile: {
46+
executor: 'ramping-arrival-rate', //Assure load increase if the system slows
47+
startRate: 0,
48+
timeUnit: '1m',
49+
preAllocatedVUs: 10000,
50+
stages: [
51+
// Ramp in 100 req/sec intervals, and hold 5 mins.
52+
// Each loop runs 3 req/sec, so (target * 3) / 60 = req/sec.
53+
{ duration: '5m', target: 2000 },
54+
{ duration: '5m', target: 2000 },
55+
{ duration: '5m', target: 4000 },
56+
{ duration: '5m', target: 4000 },
57+
{ duration: '5m', target: 6000 },
58+
{ duration: '5m', target: 6000 },
59+
{ duration: '5m', target: 8000 },
60+
{ duration: '5m', target: 8000 },
61+
{ duration: '5m', target: 10000 },
62+
{ duration: '5m', target: 10000 },
63+
],
64+
tags: {
65+
profile: 'stress',
4466
},
45-
// stress: {
46-
// executor: 'ramping-arrival-rate', //Assure load increase if the system slows
47-
// startRate: 0,
48-
// timeUnit: '1m',
49-
// preAllocatedVUs: 10000,
50-
// stages: [
51-
// // Ramp in 100 req/sec intervals, and hold 5 mins.
52-
// // Each loop runs 3 req/sec, so (target * 3) / 60 = req/sec.
53-
// { duration: '5m', target: 2000 },
54-
// { duration: '5m', target: 2000 },
55-
// { duration: '5m', target: 4000 },
56-
// { duration: '5m', target: 4000 },
57-
// { duration: '5m', target: 6000 },
58-
// { duration: '5m', target: 6000 },
59-
// { duration: '5m', target: 8000 },
60-
// { duration: '5m', target: 8000 },
61-
// { duration: '5m', target: 10000 },
62-
// { duration: '5m', target: 10000 },
63-
// ],
64-
// tags: {
65-
// profile: 'stress-5m-2000',
66-
// },
67-
// },
67+
},
6868

69-
// stress: {
70-
// executor: 'ramping-arrival-rate', //Assure load increase if the system slows
71-
// startRate: BASELINE_RATE,
72-
// timeUnit: '1m',
73-
// preAllocatedVUs: 20000,
74-
// stages: [
75-
// { duration: '1m', target: BASELINE_RATE }, // just slowly ramp-up to a HUGE load
76-
// // just slowly ramp-up to an EPIC load.
77-
// { duration: '1h', target: 20000 },
78-
// ],
79-
// tags: {
80-
// profile: 'stress-1h-20000',
81-
// },
82-
// },
69+
soakProfile: {
70+
executor: 'ramping-arrival-rate', //Assure load increase if the system slows
71+
startRate: BASELINE_RATE,
72+
timeUnit: '1m',
73+
preAllocatedVUs: 20000,
74+
stages: [
75+
{ duration: '1m', target: BASELINE_RATE }, // just slowly ramp-up to a HUGE load
76+
// just slowly ramp-up to an EPIC load.
77+
{ duration: '1h', target: 20000 },
78+
],
79+
tags: {
80+
profile: 'soak',
81+
},
8382
},
83+
};
84+
85+
export const options = {
86+
scenarios: { [scenario]: scenarios[scenario] },
8487
thresholds: {
8588
http_req_failed: [
8689
{

0 commit comments

Comments
 (0)