-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mojaloop/3471): added no callback scenario (#23)
* feat: added no callback scenario * feat; added new config files for new scenarios
- Loading branch information
Showing
8 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"scenarios": { | ||
"fspiopTransfers": { | ||
"executor": "shared-iterations", | ||
"exec": "fspiopTransfersScenarios", | ||
"env": { | ||
"UNIDIRECTIONAL": "false" | ||
}, | ||
"vus": 1, | ||
"iterations": 1 | ||
} | ||
}, | ||
"thresholds": { | ||
"iteration_duration": [ "p(95)<1000" ], | ||
"http_req_failed": [ "rate<0.01" ], | ||
"http_req_duration": [ "p(95)<1000" ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"scenarios": { | ||
"fspiopTransfers": { | ||
"executor": "shared-iterations", | ||
"exec": "fspiopTransfersNoCallbackScenarios", | ||
"env": { | ||
"UNIDIRECTIONAL": "false" | ||
}, | ||
"vus": 1, | ||
"iterations": 5000 | ||
} | ||
}, | ||
"thresholds": { | ||
"iteration_duration": [ "p(95)<1000" ], | ||
"http_req_failed": [ "rate<0.01" ], | ||
"http_req_duration": [ "p(95)<1000" ] | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
packages/k6-tests/config/fspiopTransfersNoCallbackConstantRate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"scenarios": { | ||
"fspiopTransfers": { | ||
"executor": "constant-arrival-rate", | ||
"exec": "fspiopTransfersNoCallbackScenarios", | ||
"env": { | ||
"UNIDIRECTIONAL": "false" | ||
}, | ||
"preAllocatedVUs": 1, | ||
"timeUnit": "1s", | ||
"duration": "1m", | ||
"rate": 300 | ||
} | ||
}, | ||
"thresholds": { | ||
"iteration_duration": [ "p(95)<1000" ], | ||
"http_req_failed": [ "rate<0.01" ], | ||
"http_req_duration": [ "p(95)<1000" ] | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/k6-tests/config/fspiopTransfersNoCallbackRampingRate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"scenarios": { | ||
"fspiopTransfers": { | ||
"executor": "ramping-arrival-rate", | ||
"exec": "fspiopTransfersNoCallbackScenarios", | ||
"env": { | ||
"UNIDIRECTIONAL": "false" | ||
}, | ||
"preAllocatedVUs": 1, | ||
"timeUnit": "1s", | ||
"startRate": 30, | ||
"stages": [ | ||
{ "target": 50, "duration": "2m" }, | ||
{ "target": 100, "duration": "2m" }, | ||
{ "target": 150, "duration": "2m" }, | ||
{ "target": 150, "duration": "2m" }, | ||
{ "target": 200, "duration": "15m" } | ||
] | ||
} | ||
}, | ||
"thresholds": { | ||
"iteration_duration": [ "p(95)<1000" ], | ||
"http_req_failed": [ "rate<0.01" ], | ||
"http_req_duration": [ "p(95)<1000" ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"scenarios": { | ||
"fspiopTransfers": { | ||
"executor": "ramping-arrival-rate", | ||
"exec": "fspiopTransfersScenarios", | ||
"env": { | ||
"UNIDIRECTIONAL": "false" | ||
}, | ||
"preAllocatedVUs": 50, | ||
"timeUnit": "1s", | ||
"startRate": 10, | ||
"stages": [ | ||
{ "target": 100, "duration": "5m" }, | ||
{ "target": 200, "duration": "5m" }, | ||
{ "target": 300, "duration": "10m" } | ||
] | ||
} | ||
}, | ||
"thresholds": { | ||
"iteration_duration": [ "p(95)<1000" ], | ||
"http_req_failed": [ "rate<0.01" ], | ||
"http_req_duration": [ "p(95)<1000" ] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { postTransfersNoCallback } from "../scripts/postTransfersNoCallback.js"; | ||
|
||
|
||
export function fspiopTransfersNoCallbackScenarios() { | ||
postTransfersNoCallback(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import http from 'k6/http'; | ||
import { crypto } from "k6/experimental/webcrypto"; | ||
import { check, fail, sleep, group } from 'k6'; | ||
import { Trace } from "../common/trace.js"; | ||
import { getTwoItemsFromArray } from "../common/utils.js"; | ||
|
||
console.log(`Env Vars --> | ||
K6_SCRIPT_FSPIOP_TRANSFERS_ENDPOINT_URL=${__ENV.K6_SCRIPT_FSPIOP_TRANSFERS_ENDPOINT_URL}, | ||
K6_SCRIPT_FSPIOP_FSP_POOL=${__ENV.K6_SCRIPT_FSPIOP_FSP_POOL} | ||
`); | ||
|
||
const fspList = JSON.parse(__ENV.K6_SCRIPT_FSPIOP_FSP_POOL) | ||
|
||
const ilpPacket = __ENV.K6_SCRIPT_FSPIOP_TRANSFERS_ILPPACKET | ||
const condition = __ENV.K6_SCRIPT_FSPIOP_TRANSFERS_CONDITION | ||
const amount = __ENV.K6_SCRIPT_FSPIOP_TRANSFERS_AMOUNT.toString() | ||
const currency = __ENV.K6_SCRIPT_FSPIOP_TRANSFERS_CURRENCY | ||
|
||
export function postTransfersNoCallback() { | ||
group("Post Transfers", function () { | ||
let payerFsp | ||
let payeeFsp | ||
|
||
if (__ENV.UNIDIRECTIONAL === "true" || __ENV.UNIDIRECTIONAL === "TRUE") { | ||
payerFsp = fspList[0] | ||
payeeFsp = fspList[1] | ||
} else { | ||
const selectedFsps = getTwoItemsFromArray(fspList) | ||
payerFsp = selectedFsps[0] | ||
payeeFsp = selectedFsps[1] | ||
} | ||
|
||
const startTs = Date.now(); | ||
const transferId = crypto.randomUUID(); | ||
const payerFspId = payerFsp['fspId']; | ||
const payeeFspId = payeeFsp['fspId']; | ||
const traceParent = Trace(); | ||
const traceId = traceParent.traceId; | ||
|
||
const params = { | ||
tags: { | ||
payerFspId, | ||
payeeFspId | ||
}, | ||
headers: { | ||
'Accept': 'application/vnd.interoperability.transfers+json;version=1.1', | ||
'Content-Type': 'application/vnd.interoperability.transfers+json;version=1.1', | ||
'FSPIOP-Source': payerFspId, | ||
'FSPIOP-Destination': payeeFspId, | ||
'Date': (new Date()).toUTCString(), | ||
'traceparent': traceParent.toString(), | ||
'tracestate': `tx_end2end_start_ts=${startTs}` | ||
}, | ||
}; | ||
|
||
const body = { | ||
"transferId": transferId, | ||
"payerFsp": payerFspId, | ||
"payeeFsp": payeeFspId, | ||
"amount": { | ||
amount, | ||
currency | ||
}, | ||
"expiration": "2030-01-01T00:00:00.000Z", | ||
ilpPacket, | ||
condition | ||
} | ||
|
||
// Lets send the FSPIOP POST /transfers request | ||
const res = http.post(`${__ENV.K6_SCRIPT_FSPIOP_TRANSFERS_ENDPOINT_URL}/transfers`, JSON.stringify(body), params); | ||
check(res, { 'TRANSFERS_FSPIOP_POST_TRANSFERS_RESPONSE_IS_202' : (r) => r.status == 202 }); | ||
|
||
}); | ||
} |