diff --git a/loadtests/ws_load_test.js b/loadtests/ws_load_test.js index 45f050a..9b83a12 100644 --- a/loadtests/ws_load_test.js +++ b/loadtests/ws_load_test.js @@ -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, @@ -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 }, @@ -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() } );