Skip to content

Commit

Permalink
[US] Modified README to adjust the steps of setting up the load tests
Browse files Browse the repository at this point in the history
  • Loading branch information
usuletw022 committed Nov 3, 2023
1 parent e3e9ba5 commit 8db362e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions loadtests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ xk6 build --with github.com/grafana/xk6-dashboard@latest
```
2. Register a number of charge stations to the CSMS (e.g. cs1, cs2, cs3 etc). Replace 'BASE64_SHA256_PASSWORD' with the base64SHA256Password that was extracted
```bash
curl http://localhost:9410/api/v0/cs/cs1 -H 'content-type: application/json' -d '{"securityProfile":1,"base64SHA256Password":"BASE64_SHA256_PASSWORD"}' &&
curl http://localhost:9410/api/v0/cs/cs2 -H 'content-type: application/json' -d '{"securityProfile":1,"base64SHA256Password":"BASE64_SHA256_PASSWORD"}' &&
curl http://localhost:9410/api/v0/cs/cs3 -H 'content-type: application/json' -d '{"securityProfile":1,"base64SHA256Password":"BASE64_SHA256_PASSWORD"}'
curl http://localhost:9410/api/v0/cs/cs1 -H 'content-type: application/json' -d '{"securityProfile":0,"base64SHA256Password":"BASE64_SHA256_PASSWORD"}' &&
curl http://localhost:9410/api/v0/cs/cs2 -H 'content-type: application/json' -d '{"securityProfile":0,"base64SHA256Password":"BASE64_SHA256_PASSWORD"}' &&
curl http://localhost:9410/api/v0/cs/cs3 -H 'content-type: application/json' -d '{"securityProfile":0,"base64SHA256Password":"BASE64_SHA256_PASSWORD"}'
```

3. Register the contract token to the CSMS
3. Register the contract token to the CSMS. Replace 'UID' with the value of the idTag that is found in loadtests/ws_load_test.js. This is used in the websocket messages: Authorise, StartTransaction and StopTransaction.
```bash
curl -i http://localhost:9410/api/v0/token -H 'content-type: application/json' -d '{"countryCode": "GB","partyId": "TWK","type": "RFID","uid": "38748383L7337848H823","contractId": "GBTWK012345678V","issuer": "Thoughtworks","valid": true,"cacheMode": "ALWAYS"}'
curl -i http://localhost:9410/api/v0/token -H 'content-type: application/json' -d '{"countryCode": "GB","partyId": "TWK","type": "RFID","uid": "UID","contractId": "GBTWK012345678V","issuer": "Thoughtworks","valid": true,"cacheMode": "ALWAYS"}'
```

4. Set the load simulation for ramping virtual users in loadtests/ws_load_test.js. Please refer to https://k6.io/docs/using-k6/scenarios/executors/ramping-vus/ for guidance. Please note that 1 virtual user is the equivalent to 1 charge station.
Expand Down
40 changes: 20 additions & 20 deletions loadtests/ws_load_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ws from 'k6/ws';
import { check } from 'k6';
import {check} from 'k6';
import encoding from 'k6/encoding';
import exec from 'k6/execution';
import { sleep } from 'k6';
import {sleep} from 'k6';

export const options = {
discardResponseBodies: true,
Expand All @@ -11,23 +11,23 @@ export const options = {
executor: 'ramping-vus',
startVUs: 2,
stages: [
{ duration: '5m', target: 50 },
{ duration: '5m', target: 100 },
{ duration: '10m', target: 200 },
{ duration: '10m', target: 300 },
{ duration: '10m', target: 400 },
{ duration: '10m', target: 500 },
{ duration: '10m', target: 600 },
{ duration: '5m', target: 550 },
{ duration: '5m', target: 600 },
{ duration: '5m', target: 550 },
{ duration: '5m', target: 600 },
{ duration: '10m', target: 500 },
{ duration: '10m', target: 400 },
{ duration: '10m', target: 300 },
{ duration: '10m', target: 100 },
{ duration: '5m', target: 50 },
{ duration: '5m', target: 0 }
{duration: '5m', target: 50},
{duration: '5m', target: 100},
{duration: '10m', target: 200},
{duration: '10m', target: 300},
{duration: '10m', target: 400},
{duration: '10m', target: 500},
{duration: '10m', target: 600},
{duration: '5m', target: 550},
{duration: '5m', target: 600},
{duration: '5m', target: 550},
{duration: '5m', target: 600},
{duration: '10m', target: 500},
{duration: '10m', target: 400},
{duration: '10m', target: 300},
{duration: '10m', target: 100},
{duration: '5m', target: 50},
{duration: '5m', target: 0}
],
gracefulRampDown: '0s',
},
Expand Down Expand Up @@ -80,5 +80,5 @@ export default function () {
}
);

check(res, { 'status is 101': (r) => r && r.status === 101 });
check(res, {'status is 101': (r) => r && r.status === 101});
}

0 comments on commit 8db362e

Please sign in to comment.