Skip to content

Commit

Permalink
Add sender scenario and hysteresis workload
Browse files Browse the repository at this point in the history
  • Loading branch information
ausias-armesto committed Aug 9, 2024
1 parent 1687ecc commit 41cde76
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 26 deletions.
2 changes: 1 addition & 1 deletion k6/assets/k6-test-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
parallelism: 1
script:
localFile: /app/hoprnet/constant-traffic.test.js
localFile: /app/hoprnet/send-messages.test.js
separate: true
arguments: --tag testid={{ testid }} --summary-export=/test-results/k6/test-execution-$(date +%Y%m%d-%H%M%S).json
runner:
Expand Down
53 changes: 53 additions & 0 deletions k6/assets/nodes-sender.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"nodes": [
{
"name": "hoprd-core-rotsee-1",
"url": "https://hoprd-core-rotsee-1.core-team.staging.hoprnet.link/",
"isSender": true,
"isRelayer": false,
"routes": [
{ "name": "hoprd-core-rotsee-5" }
]
},
{
"name": "hoprd-core-rotsee-2",
"url": "https://hoprd-core-rotsee-2.core-team.staging.hoprnet.link/",
"isSender": false,
"isRelayer": true,
"routes": [
{ "name": "hoprd-core-rotsee-5" }
]
},
{
"name": "hoprd-core-rotsee-3",
"url": "https://hoprd-core-rotsee-3.core-team.staging.hoprnet.link/",
"isSender": false,
"isRelayer": true,
"routes": [
{ "name": "hoprd-core-rotsee-5" }
]
},
{
"name": "hoprd-core-rotsee-4",
"url": "https://hoprd-core-rotsee-4.core-team.staging.hoprnet.link/",
"isSender": false,
"isRelayer": true,
"routes": [
{ "name": "hoprd-core-rotsee-5" }

]
},
{
"name": "hoprd-core-rotsee-5",
"url": "https://hoprd-core-rotsee-5.core-team.staging.hoprnet.link/",
"isSender": false,
"isRelayer": true,
"routes": [
{ "name": "hoprd-core-rotsee-1" },
{ "name": "hoprd-core-rotsee-2" },
{ "name": "hoprd-core-rotsee-3" },
{ "name": "hoprd-core-rotsee-4" }
]
}
]
}
2 changes: 1 addition & 1 deletion k6/assets/nodes-team-all.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
},
{
"name": "hoprd-michal",
"url": "http://vlabs.ddns.net:3003/",
"url": "http://vlabs.ddns.net:3101/",
"isSender": true,
"isRelayer": true,
"routes": [
Expand Down
2 changes: 1 addition & 1 deletion k6/assets/nodes-team.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
{
"name": "hoprd-michal",
"url": "http://vlabs.ddns.net:3003/",
"url": "http://vlabs.ddns.net:3101/",
"isSender": true,
"isRelayer": true,
"routes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scenario": "receive_messages"
}
},
"send_one_hop": {
"constant_load": {
"executor": "ramping-arrival-rate",
"startTime": "10s",
"timeUnit": "1s",
Expand Down
40 changes: 40 additions & 0 deletions k6/assets/workload-hysteresis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"scenarios": {
"receive_messages": {
"executor": "per-vu-iterations",
"vus": 1,
"iterations": 1,
"maxDuration": "31m10s",
"exec": "receiveMessages",
"tags": {
"scenario": "receive_messages"
}
},
"hysteresis": {
"executor": "ramping-arrival-rate",
"startTime": "10s",
"timeUnit": "1s",
"stages": [
{ "target": 2, "duration": "5s" },
{ "target": 500, "duration": "15m" },
{ "target": 2, "duration": "15m" },
{ "target": 0, "duration": "5s" }
],
"preAllocatedVUs": 100,
"env": {
"HOPS": "1"
},
"exec": "multipleHopMessage",
"tags": {
"scenario": "send_one_hop"
}
}
},
"setupTimeout": "3600000",
"thresholds": {
"hopr_message_requests_succeed": ["rate>0.99"],
"hopr_message_requests_failed": ["rate<0.01"],
"hopr_sent_messages_succeed": ["rate>0.97"],
"hopr_message_latency": ["avg<300", "p(90)<400", "p(95)<500"]
}
}
5 changes: 2 additions & 3 deletions k6/assets/workload-incremental.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
"scenario": "receive_messages"
}
},
"incremental_trhoughput": {
"incremental": {
"executor": "ramping-arrival-rate",
"startTime": "10s",
"timeUnit": "1s",
"stages": [
{ "target": 20, "duration": "1m" },
{ "target": 2, "duration": "5s" },
{ "target": 500, "duration": "30m" },
{ "target": 20, "duration": "1m" },
{ "target": 0, "duration": "1m" }
],
"preAllocatedVUs": 100,
Expand Down
2 changes: 1 addition & 1 deletion k6/assets/workload-sanity-check.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scenario": "receive_messages"
}
},
"send_one_hop": {
"sanity_check": {
"executor": "ramping-arrival-rate",
"startTime": "5s",
"timeUnit": "1s",
Expand Down
12 changes: 7 additions & 5 deletions k6/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@
"docker:build": "docker build --platform linux/amd64 --tag europe-west3-docker.pkg.dev/hoprassociation/docker-images/hoprd-k6:latest .",
"docker:push": "docker push europe-west3-docker.pkg.dev/hoprassociation/docker-images/hoprd-k6:latest",
"test": "npm run test:local",
"test:local": "npm run webpack && K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run ./dist/constant-traffic.test.js",
"test:rotsee": "npm run webpack && NODES=rotsee K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/constant-traffic.test.js",
"test:relayer": "npm run webpack && NODES=relayer K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/constant-traffic.test.js",
"test:team": "npm run webpack && NODES=team K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/constant-traffic.test.js",
"test:dufour": "npm run webpack && NODES=dufour K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/constant-traffic.test.js",
"test:local": "npm run webpack && K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run ./dist/send-messages.test.js",
"test:rotsee": "npm run webpack && NODES=rotsee K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/send-messages.test.js",
"test:sender": "npm run webpack && NODES=sender K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/send-messages.test.js",
"test:relayer": "npm run webpack && NODES=relayer K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/send-messages.test.js",
"test:team": "npm run webpack && NODES=team K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/send-messages.test.js",
"test:dufour": "npm run webpack && NODES=dufour K6_PROMETHEUS_RW_TREND_AS_NATIVE_HISTOGRAM=true K6_OUT=xk6-prometheus-rw K6_PROMETHEUS_RW_SERVER_URL=https://prometheus.staging.hoprnet.link/api/v1/write ./k6 run --summary-export=test-execution-local.json --tag testid=local ./dist/send-messages.test.js",
"test:rotsee:setup": "npm run build && NODES=rotsee node ./dist/setup-environment.js",
"test:sender:setup": "npm run build && NODES=sender node ./dist/setup-environment.js",
"test:relayer:setup": "npm run build && NODES=relayer node ./dist/setup-environment.js",
"test:team:setup": "npm run build && NODES=team node ./dist/setup-environment.js",
"test:dufour:setup": "npm run build && NODES=dufour node ./dist/setup-environment.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,26 @@ const optionsData = JSON.parse(open(`./workload-${workloadName}.json`))
let scenario: keyof typeof optionsData.scenarios;
let scenariosLength = 0;
for (scenario in optionsData.scenarios) {
if (optionsData.scenarios[scenario].exec !== "receiveMessages") {
if (scenario !== "incremental_trhoughput") {
if (scenario !== "receive_messages") {
if (scenario !== "incremental" && scenario !== "hysteresis" ) { // Incremental and Hysteresis scenarios should keep stage 0 target as is
optionsData.scenarios[scenario].stages[0].target = amountOfSenders * (__ENV.SCENARIO_ITERATIONS || optionsData.scenarios[scenario].stages[0].target)
}
optionsData.scenarios[scenario].stages[1].target = amountOfSenders * (__ENV.SCENARIO_ITERATIONS || optionsData.scenarios[scenario].stages[1].target)
if (__ENV.SCENARIO_DURATION) {
optionsData.scenarios[scenario].stages[1].duration = __ENV.SCENARIO_DURATION
if ( scenario === "hysteresis" ) { // Hysteresis scenario should divide the duration in half for stage 1 and 2
let halfDuration = Math.floor(Number(__ENV.SCENARIO_DURATION) / 2);
optionsData.scenarios[scenario].stages[1].duration = halfDuration + 'm'
optionsData.scenarios[scenario].stages[2].duration = halfDuration + 'm'
} else {
optionsData.scenarios[scenario].stages[1].duration = __ENV.SCENARIO_DURATION + 'm'
}
}
optionsData.scenarios[scenario].preAllocatedVUs = Math.floor(amountOfSenders * (Number(__ENV.SCENARIO_ITERATIONS) || optionsData.scenarios[scenario].stages[1].target) / 2)
optionsData.scenarios[scenario].preAllocatedVUs = Math.max(1,Math.floor(amountOfSenders * (Number(__ENV.SCENARIO_ITERATIONS) || optionsData.scenarios[scenario].stages[1].target) / 2))
scenariosLength++
} else {
optionsData.scenarios[scenario].vus = amountOfSenders * 5 // Increasing the probability of opening a websocket connection per sender
if (__ENV.SCENARIO_DURATION) {
let duration = __ENV.SCENARIO_DURATION;
let durationInSeconds = 70;
if (duration.endsWith('m')) {
durationInSeconds += parseInt(duration.slice(0, -1)) * 60;
} else if (duration.endsWith('s')) {
durationInSeconds += parseInt(duration.slice(0, -1));
}
let durationInSeconds = Number(__ENV.SCENARIO_DURATION) * 60 + 70;
optionsData.scenarios[scenario].maxDuration = durationInSeconds + 's';
}
}
Expand Down Expand Up @@ -81,6 +81,8 @@ export function setup() {
}

})
// console.log(`Senders: ${JSON.stringify(senders)}`);
// console.log(`Relayers: ${JSON.stringify(relayers)}`);
return { senders, relayers }
}

Expand Down Expand Up @@ -132,7 +134,7 @@ export function receiveMessages(dataPool: { senders: HoprdNode[], relayers: Hopr
// default function imports the return data from the setup function https://docs.k6.io/docs/test-life-cycle
export function multipleHopMessage(dataPool: { senders: HoprdNode[], relayers: HoprdNode[] }) {
const nodeIndex = Math.ceil(execution.vu.idInInstance % (amountOfSenders * scenariosLength))
// console.log(`idInstance: ${execution.vu.idInInstance} having index : ${nodeIndex} from scenario[${execution.scenario.name}]`)
//console.log(`idInstance: ${execution.vu.idInInstance} having index : ${nodeIndex} from scenario[${execution.scenario.name}]`)
const senderHoprdNode = dataPool.senders[nodeIndex]
if (__ENV.WEBSOCKET_DISCONNECTED === 'true') {
fail(`Node ${senderHoprdNode.name} disconnected from websocket`)
Expand Down
2 changes: 1 addition & 1 deletion k6/src/typescript/setup-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const nodes = process.env.NODES || 'rotsee'
const workloadName = process.env.WORKLOAD_NAME || 'sanity-check'
const testid = process.env.TESTID || 'kubernetes'
const iterations = process.env.SCENARIO_ITERATIONS || 1
const duration = process.env.SCENARIO_DURATION || "10m"
const duration = process.env.SCENARIO_DURATION || "30"
const hoprdNodeThreads = process.env.HOPRD_NODE_THREADS || 1
const nodesData = JSON.parse(fs.readFileSync(`assets/nodes-${nodes}.json`).toString())
const promiseNodes: HoprdNode[] = nodesData.nodes.map(async (node: any) => {
Expand Down

0 comments on commit 41cde76

Please sign in to comment.