Skip to content

Commit

Permalink
[US] Added base64 encoding and iteration per vu load simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
usuletw022 committed Sep 26, 2023
1 parent 399c3d3 commit d89bcb6
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions loadtests/ws_load_test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
import ws from 'k6/ws';
import { check } from 'k6';
import encoding from 'k6/encoding';

export const options = {
vus: 1,
duration: '10s',
discardResponseBodies: true,
scenarios: {
contacts: {
executor: 'per-vu-iterations',
vus: 5,
iterations: 5,
maxDuration: '20s',
},
},
};

const csIds = [ 1, 2, 3, 4, 5];
const csIds = [1, 2, 3, 4, 5];
let csId = csIds[Math.floor(Math.random()*csIds.length)];
let data = `cs00${csId}:fiddlesticks_fishsticks`;
let base64data = encoding.b64encode(data)

export default function () {
let csId = csIds[Math.floor(Math.random()*csIds.length)];
const params = {
headers: {'Sec-WebSocket-Protocol': 'ocpp1.6', 'Authorization': 'Basic Y3MwMDE6ZmlkZGxlc3RpY2tzX2Zpc2hzdGlja3M='}
headers: {'Sec-WebSocket-Protocol': 'ocpp1.6', 'Authorization': `Basic ${base64data}`}
};

const url = `ws://localhost/ws/cs00${csId}`;
const res = ws.connect(url, params, function (socket) {
socket.send('[2,"1","BootNotification",{"chargePointModel":"me100","chargePointVendor":"me"}]');
Expand Down

0 comments on commit d89bcb6

Please sign in to comment.