diff --git a/docker/k6/.env b/docker/k6/.env deleted file mode 100644 index 2991fcaa..00000000 --- a/docker/k6/.env +++ /dev/null @@ -1,4 +0,0 @@ -ACCOUNT_LOOKUP_SERVICE_HOST=account-lookup-service -ACCOUNT_LOOKUP_SERVICE_PORT=4002 -CALLBACK_HANDLER_SERVICE_WS_HOST=callback-handler-svc -CALLBACK_HANDLER_SERVICE_WS_PORT=3002 diff --git a/docker/k6/scripts/test-ws.js b/docker/k6/scripts/test-ws.js deleted file mode 100644 index 072787d7..00000000 --- a/docker/k6/scripts/test-ws.js +++ /dev/null @@ -1,112 +0,0 @@ -import http from 'k6/http'; -import { check, sleep } from 'k6'; -import crypto from "k6/crypto"; -import { WebSocket } from 'k6/experimental/websockets'; -// import { Trend, Rate } from 'k6/metrics'; - -// const myTrend = new Trend('waiting_time', isTime=true); -// const myTrend = new Trend('waiting_time', true); - -// const myRate = new Trend('rate_time'); - -export const options = { - vus: 30, - duration: '5m', - batch: 20, - batchPerHost: 6, - noConnectionReuse: false, - noVUConnectionReuse: false, - // stages: [ - // { duration: '5m', target: 30 }, - // // { duration: '1m30s', target: 10 }, - // // { duration: '20s', target: 0 }, - // ], - tags: { - testid: `${Date.now()}`, - }, - thresholds: { // Ref: https://k6.io/docs/using-k6/workaround-to-calculate-iteration_duration/ - 'iteration_duration{scenario:default}': [`max>=0`], - 'iteration_duration{group:::setup}': [`max>=0`], - 'iteration_duration{group:::teardown}': [`max>=0`], - 'http_req_duration{scenario:default}': [`max>=0`], - }, -}; - -console.log(`Env Vars --> - ACCOUNT_LOOKUP_SERVICE_HOST=${__ENV.ACCOUNT_LOOKUP_SERVICE_HOST}, - ACCOUNT_LOOKUP_SERVICE_PORT=${__ENV.ACCOUNT_LOOKUP_SERVICE_PORT} -`); - -// Precomputed Hex Octets w/ for Loop (Fastest/Baseline) -const byteToHex = []; -for (let n = 0; n <= 0xff; ++n) -{ - const hexOctet = n.toString(16).padStart(2, "0"); - byteToHex.push(hexOctet); -} -function hex(arrayBuffer) -{ - const buff = new Uint8Array(arrayBuffer); - const hexOctets = []; // new Array(buff.length) is even faster (preallocates necessary array size), then use hexOctets[i] instead of .push() - - for (let i = 0; i < buff.length; ++i) - hexOctets.push(byteToHex[buff[i]]); - - return hexOctets.join(""); -} - -// Trace utilities -class TraceParent { - traceId; - parentId; - traceFlags; - constructor () { - // Ref: https://github.com/mojaloop/mojaloop-specification/blob/master/fspiop-api/documents/Tracing%20v1.0.md#table-2--data-model-for-tracing-values - this.traceId = hex(crypto.randomBytes(16)); - this.parentId = hex(crypto.randomBytes(8)); - this.traceFlags = '01'; - } - - toString () { - return `00-${this.traceId}-${this.parentId}-${this.traceFlags}`; - }; - -} - -export default function () { - const startTs = Date.now(); - - const payeeId = '19012345002'; - const traceParent = new TraceParent(); - const wsChannel = `${traceParent.traceId}/PUT/parties/MSISDN/${payeeId}`; - // const ws = new WebSocket(`ws://${__ENV.CALLBACK_HANDLER_SERVICE_WS_HOST}:${__ENV.CALLBACK_HANDLER_SERVICE_WS_PORT}/${wsChannel}`); - // TODO: Need to parameterize the following. The above line is not working somehow and need to investigate - const ws = new WebSocket(`ws://callback-handler-svc:3002/${wsChannel}`); - - ws.onmessage = (event) => { - // const deltaTs = Date.now() - startTs - // myTrend.add(deltaTs); - // myRate.add(deltaTs) - console.log(`WS message received: ${event.data}`); - check(event.data, { 'Success Callback should be received': (cbMessage) => cbMessage == 'SUCCESS_CALLBACK_RECEIVED' }); - // console.log(deltaTs); - ws.close(); - // sleep(1); - }; - - ws.onopen = () => { - const params = { - headers: { - 'Accept': 'application/vnd.interoperability.parties+json;version=1.1', - 'Content-Type': 'application/vnd.interoperability.parties+json;version=1.1', - 'FSPIOP-Source': 'perffsp1', - 'Date': (new Date()).toUTCString(), - 'traceparent': traceParent.toString(), - 'tracestate': `tx_end2end_start_ts=${startTs}` - }, - }; - - const res = http.get(`http://${__ENV.ACCOUNT_LOOKUP_SERVICE_HOST}:${__ENV.ACCOUNT_LOOKUP_SERVICE_PORT}/parties/MSISDN/${payeeId}`, params); - check(res, { 'http sync response status is 202': (r) => r.status == 202 }); - }; -} diff --git a/docker/k6/scripts/test.js b/docker/k6/scripts/test.js deleted file mode 100644 index dc60a323..00000000 --- a/docker/k6/scripts/test.js +++ /dev/null @@ -1,43 +0,0 @@ -import http from 'k6/http'; -import { check, sleep, crypto } from 'k6'; -// import { Trace } from './utils' - -export const options = { - stages: [ - { duration: '2m', target: 20, vus: 1 }, - // { duration: '1m30s', target: 10 }, - // { duration: '20s', target: 0 }, - ], - tags: { - testid: `${Date.now()}`, - }, - // Ref: https://k6.io/docs/using-k6/k6-options/reference/#no-connection-reuse - noConnectionReuse: false, -}; - -console.log(`Env Vars --> - ACCOUNT_LOOKUP_SERVICE_HOST=${__ENV.ACCOUNT_LOOKUP_SERVICE_HOST}, - ACCOUNT_LOOKUP_SERVICE_PORT=${__ENV.ACCOUNT_LOOKUP_SERVICE_PORT} -`); - -const generateTrace = () => { - // Ref: https://github.com/mojaloop/mojaloop-specification/blob/master/fspiop-api/documents/Tracing%20v1.0.md#table-2--data-model-for-tracing-values - return `00-${crypto.randomBytes(16)}-${crypto.randomBytes(8)}-${crypto.randomBytes(1)}` -} - -export default function () { - const params = { - headers: { - 'Accept': 'application/vnd.interoperability.parties+json;version=1.1', - 'Content-Type': 'application/vnd.interoperability.parties+json;version=1.1', - 'FSPIOP-Source': 'perffsp1', - 'Date': (new Date()).toUTCString(), - // 'traceParent': Trace.generateTraceParent(), - 'traceState': `tx_end2end_start_ts=${Date.now()}` - }, - }; - - const res = http.get(`http://${__ENV.ACCOUNT_LOOKUP_SERVICE_HOST}:${__ENV.ACCOUNT_LOOKUP_SERVICE_PORT}/parties/MSISDN/19012345002`, params); - check(res, { 'status was 200': (r) => r.status == 200 }); - sleep(1); -} diff --git a/docker/k6/scripts/utils.js b/docker/k6/scripts/utils.js deleted file mode 100644 index bc86823f..00000000 --- a/docker/k6/scripts/utils.js +++ /dev/null @@ -1,7 +0,0 @@ - - -export const Trace = { - generateTraceParent: () => { - return `00-${crypto.randomBytes(16)}-${crypto.randomBytes(8)}-${crypto.randomBytes(1)}` - } -} diff --git a/packages/k6-tests/config/test.js b/packages/k6-tests/config/test.js index 2ea53bd3..0bc78bed 100644 --- a/packages/k6-tests/config/test.js +++ b/packages/k6-tests/config/test.js @@ -1,35 +1,29 @@ // Main configuration for Scripts const config = { - "scenarios": { // define scenarios - // warm-up - "accountLookup": { // original scenario for accountLookup + // # define scenarios + "scenarios": { + "accountLookup": { // # original scenario for accountLookup "executor": "ramping-vus", "exec": "accountLookupScenarios", "startVUs": 1, "stages": [ - { "duration": "2m", "target": 1 }, - { "duration": "15m", "target": 1 }, + { "duration": "2m", "target": 6 }, + { "duration": "5m", "target": 6 }, { "duration": "2m", "target": 0 } ] }, + // # Example using "ramping-arrival-rate" executor // "accountLookup": { // "executor": "ramping-arrival-rate", // "exec": "accountLookupScenarios", - // "preAllocatedVUs": 1, + // "preAllocatedVUs": 10, // "timeUnit": "1s", // "startRate": 1, // "stages": [ - // { "target": 1, "duration": "30s" }, - // // { "target": 200, "duration": "30s" }, - // // { "target": 200, "duration": "1m" }, - // // { "target": 0, "duration": "30s"}, - // // { "target": 300, "duration": "30s" }, - // // { "target": 0, "duration": "30s"}, - // // { "target": 100, "duration": "30s" }, - // // { "target": 100, "duration": "2m" }, - // // { "target": 0, "duration": "30s"}, - // // { "target": 10000, "duration": "10m" } + // { "target": 400, "duration": "2m" }, + // { "target": 400, "duration": "15m" }, + // { "target": 0, "duration": "2m"}, // ] // } },