Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parameterize scenarios #368

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion k6/k6-runner/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ config:

.PHONY: run_job
run_job:
oc -n $(NAMESPACE) process -f ./openshift/k6/dc.yaml -p DB_PASSWORD=$(DB_PASSWORD) -p DB_USER=$(DB_USER) | oc -n $(NAMESPACE) apply -f -
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 -

.PHONY: cleanup
cleanup:
Expand Down
3 changes: 3 additions & 0 deletions k6/k6-runner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
export DB_USER=
export DB_PASSWORD=

# one of ('peakProfile', 'stressProfile', 'soakProfile')
export SCENARIO=

# create configmap with all the configurations
make config

Expand Down
5 changes: 5 additions & 0 deletions k6/k6-runner/openshift/k6/dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ objects:
env:
- name: K6_OUT
value: 'timescaledb=postgresql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}'
- name: SCENARIO
value: ${SCENARIO}
resources:
limits:
cpu: 2
Expand Down Expand Up @@ -59,3 +61,6 @@ parameters:
value: 'k6-patroni'
- name: DB_PORT
value: '5432'
- name: SCENARIO
required: true
description: The name of the scenario (peakProfile, stressProfile, and soakProfile) to run
99 changes: 51 additions & 48 deletions k6/k6-runner/src/tests/constantRateAllFlows.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { user, client } from './constants.js';
import exec from 'k6/execution';

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

export const options = {
scenarios: {
peakProfile: {
executor: 'constant-arrival-rate',
duration: '2m',
timeUnit: '1m',
rate: 34,
preAllocatedVUs: 5,
tags: {
profile: 'peak-2h-34',
},
const scenarios = {
peakProfile: {
executor: 'constant-arrival-rate',
duration: '2h',
timeUnit: '1m',
rate: 34,
preAllocatedVUs: 5,
tags: {
profile: 'peak',
},
},
stressProfile: {
executor: 'ramping-arrival-rate', //Assure load increase if the system slows
startRate: 0,
timeUnit: '1m',
preAllocatedVUs: 10000,
stages: [
// Ramp in 100 req/sec intervals, and hold 5 mins.
// Each loop runs 3 req/sec, so (target * 3) / 60 = req/sec.
{ duration: '5m', target: 2000 },
{ duration: '5m', target: 2000 },
{ duration: '5m', target: 4000 },
{ duration: '5m', target: 4000 },
{ duration: '5m', target: 6000 },
{ duration: '5m', target: 6000 },
{ duration: '5m', target: 8000 },
{ duration: '5m', target: 8000 },
{ duration: '5m', target: 10000 },
{ duration: '5m', target: 10000 },
],
tags: {
profile: 'stress',
},
// stress: {
// executor: 'ramping-arrival-rate', //Assure load increase if the system slows
// startRate: 0,
// timeUnit: '1m',
// preAllocatedVUs: 10000,
// stages: [
// // Ramp in 100 req/sec intervals, and hold 5 mins.
// // Each loop runs 3 req/sec, so (target * 3) / 60 = req/sec.
// { duration: '5m', target: 2000 },
// { duration: '5m', target: 2000 },
// { duration: '5m', target: 4000 },
// { duration: '5m', target: 4000 },
// { duration: '5m', target: 6000 },
// { duration: '5m', target: 6000 },
// { duration: '5m', target: 8000 },
// { duration: '5m', target: 8000 },
// { duration: '5m', target: 10000 },
// { duration: '5m', target: 10000 },
// ],
// tags: {
// profile: 'stress-5m-2000',
// },
// },
},

// stress: {
// executor: 'ramping-arrival-rate', //Assure load increase if the system slows
// startRate: BASELINE_RATE,
// timeUnit: '1m',
// preAllocatedVUs: 20000,
// stages: [
// { duration: '1m', target: BASELINE_RATE }, // just slowly ramp-up to a HUGE load
// // just slowly ramp-up to an EPIC load.
// { duration: '1h', target: 20000 },
// ],
// tags: {
// profile: 'stress-1h-20000',
// },
// },
soakProfile: {
executor: 'ramping-arrival-rate', //Assure load increase if the system slows
startRate: BASELINE_RATE,
timeUnit: '1m',
preAllocatedVUs: 20000,
stages: [
{ duration: '1m', target: BASELINE_RATE }, // just slowly ramp-up to a HUGE load
// just slowly ramp-up to an EPIC load.
{ duration: '1h', target: 20000 },
],
tags: {
profile: 'soak',
},
},
};

export const options = {
scenarios: { [scenario]: scenarios[scenario] },
thresholds: {
http_req_failed: [
{
Expand Down