Skip to content

Commit

Permalink
[US] Added wait times for the messages during the websocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
usuletw022 committed Sep 29, 2023
1 parent d66606a commit 24d69ac
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions loadtests/ws_load_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ws from 'k6/ws';
import { check } from 'k6';
import encoding from 'k6/encoding';
import exec from 'k6/execution';
import { sleep } from 'k6';

export const options = {
discardResponseBodies: true,
Expand All @@ -10,7 +11,7 @@ export const options = {
executor: 'ramping-vus',
startVUs: 0,
stages: [
{ duration: '1m', target: 5 },
{ duration: '1m', target: 5 }
{ duration: '1m', target: 10 },
{ duration: '1m', target: 15 },
{ duration: '1m', target: 20 },
Expand Down Expand Up @@ -43,16 +44,38 @@ export default function () {
const url = `ws://localhost/ws/cs${vuIdInTest}`;
const res = ws.connect(url, params, function (socket) {
socket.send('[2,"1","BootNotification",{"chargePointModel":"me100","chargePointVendor":"me"}]');
socket.send('[2,"2","BootNotification",{"chargePointModel":"me100","chargePointVendor":"me"}]');
socket.send('[2,"3", "StatusNotification", {"connectorId": 1, "errorCode": "NoError", "status": "Available"}]');
sleep(10)
socket.send('[2,"2", "StatusNotification", {"connectorId": 1, "errorCode": "NoError", "status": "Available"}]');
sleep(10)
socket.send('[2,"3","Heartbeat", {}]');
sleep(10)
socket.send('[2,"4","Heartbeat", {}]');
sleep(10)
socket.send('[2,"5","Heartbeat", {}]');
socket.send('[2,"6","Heartbeat", {}]');
socket.send('[2, "7", "[2, "16", "Authorize", {"idTag": "38748383L7337848H823"}]');
socket.send('[2, "8", "StartTransaction",{"connectorId": 1, "idTag": "38748383L7337848H823", "meterStart": 3, "reservationId": 5, "timestamp":"2023-09-18T08:25:40.20Z"}]');
socket.send('[2, "9", "MeterValues", {"connectorId": 1, "meterValue":[{"timestamp":"2023-09-18T08:25:40.20Z", "sampledValue": [{"value": "5"}]}]}]');
socket.send('[2, "10", "MeterValues", {"connectorId": 1, "meterValue":[{"timestamp":"2023-09-18T08:25:40.20Z", "sampledValue": [{"value": "5"}]}]}]');
socket.send('[2, "11", "StopTransaction", {"idTag": "38748383L7337848H823", "meterStop": 3, "timestamp": "2023-09-18T08:25:40.20Z", "transactionId": 3}]');
sleep(10)
socket.send('[2,"6", "[2, "16", "Authorize", {"idTag": "38748383L7337848H823"}]');
sleep(10)
socket.send('[2,"7", "StatusNotification", {"connectorId": 1, "errorCode": "NoError", "status": "Preparing"}]');
sleep(10)
socket.send('[2,"8", "StartTransaction",{"connectorId": 1, "idTag": "38748383L7337848H823", "meterStart": 3, "reservationId": 5, "timestamp":"2023-09-18T08:25:40.20Z"}]');
sleep(300)
socket.send('[2,"9","Heartbeat", {}]');
sleep(60)
socket.send('[2,"10","Heartbeat", {}]');
sleep(60)
socket.send('[2,"11","Heartbeat", {}]');
sleep(60)
sleep(300)
socket.send('[2,"12", "MeterValues", {"connectorId": 1, "meterValue":[{"timestamp":"2023-09-18T08:25:40.20Z", "sampledValue": [{"value": "5"}]}]}]');
sleep(60)
socket.send('[2,"13", "MeterValues", {"connectorId": 1, "meterValue":[{"timestamp":"2023-09-18T08:25:40.20Z", "sampledValue": [{"value": "5"}]}]}]');
sleep(60)
socket.send('[2,"14", "StopTransaction", {"idTag": "38748383L7337848H823", "meterStop": 3, "timestamp": "2023-09-18T08:25:40.20Z", "transactionId": 3}]');
sleep(10)
socket.send('[2,"15", "StatusNotification", {"connectorId": 1, "errorCode": "NoError", "status": "Finishing"}]');
sleep(10)
socket.send('[2,"16", "StatusNotification", {"connectorId": 1, "errorCode": "NoError", "status": "Available"}]');
sleep(10)
socket.close()
}
);
Expand Down

0 comments on commit 24d69ac

Please sign in to comment.