Skip to content

Commit

Permalink
chore: add discovery and agreement onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
kleyow committed Nov 23, 2023
1 parent bce7cf1 commit dbaa724
Show file tree
Hide file tree
Showing 12 changed files with 415 additions and 11 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,23 +355,23 @@ For executing performance test scenarios against a Mojaloop deployment, follow t

3. **Run Simulators and TTK Provisioning:**
```bash
docker-compose --project-name simulators -f docker-compose-perf.yml --profile 8dfsp --profile testing-toolkit --profile ttk-provisioning-remote-k8s up -d
docker compose --project-name simulators -f docker-compose-perf.yml --profile 8dfsp --profile testing-toolkit --profile ttk-provisioning-remote-k8s --profile oracle up -d
```

4. **Run Monitoring Services:**
```bash
docker-compose --project-name monitoring --profile transfers-test -f docker-compose-monitoring.yml up -d
docker compose --project-name monitoring --profile transfers-test -f docker-compose-monitoring.yml up -d
```

5. **Execute Single Transfer Test Case:**
```bash
env K6_SCRIPT_CONFIG_FILE_NAME=fspiopSingleTransfer.json docker-compose --project-name load -f docker-compose-load.yml up
env K6_SCRIPT_CONFIG_FILE_NAME=fspiopSingleTransfer.json docker compose --project-name load -f docker-compose-load.yml up
```

6. **Stop Services:**
```bash
docker-compose --project-name simulators -f docker-compose-perf.yml --profile 8dfsp --profile testing-toolkit --profile ttk-provisioning-remote-k8s down -v
docker-compose --project-name monitoring --profile transfers-test -f docker-compose-monitoring.yml down -v
docker compose --project-name simulators -f docker-compose-perf.yml --profile 8dfsp --profile testing-toolkit --profile ttk-provisioning-remote-k8s down -v
docker compose --project-name monitoring --profile transfers-test -f docker-compose-monitoring.yml down -v
```

> **Note:** The `-v` argument is optional and will delete any volume data created by the monitoring Docker Compose.
Expand Down
7 changes: 4 additions & 3 deletions docker-compose-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ services:
command:
- sh
- -c
- 'sed -e "s~K6_CALLBACK_FQDN~$$K6_CALLBACK_FQDN~g" -e "s~K6_SCRIPT_ADMIN_ENDPOINT_URL~$$K6_SCRIPT_ADMIN_ENDPOINT_URL~g" -e "s~K6_SCRIPT_ALS_ADMIN_ENDPOINT_URL~$$K6_SCRIPT_ALS_ADMIN_ENDPOINT_URL~g" -e "s~K6_SCRIPT_ALS_ENDPOINT_URL~$$K6_SCRIPT_ALS_ENDPOINT_URL~g" environments/remote-k8s-env.json > /tmp/env.json && npm run cli -- -u http://mojaloop-testing-toolkit:5050 -l 2 -i collections/provisioning -e /tmp/env.json --report-format html --report-target file://reports/ttk-provisioning-report.html'
- 'sed -e "s~K6_CALLBACK_FQDN~$$K6_CALLBACK_FQDN~g" -e "s~K6_SCRIPT_ADMIN_ENDPOINT_URL~$$K6_SCRIPT_ADMIN_ENDPOINT_URL~g" -e "s~K6_SCRIPT_ALS_ADMIN_ENDPOINT_URL~$$K6_SCRIPT_ALS_ADMIN_ENDPOINT_URL~g" -e "s~K6_SCRIPT_FSPIOP_ALS_ENDPOINT_URL~$$K6_SCRIPT_FSPIOP_ALS_ENDPOINT_URL~g" -e "s~K6_SCRIPT_FSPIOP_QUOTES_ENDPOINT_URL~$$K6_SCRIPT_FSPIOP_QUOTES_ENDPOINT_URL~g" -e "s~K6_SCRIPT_ORACLE_ENDPOINT_URL~$$K6_SCRIPT_ORACLE_ENDPOINT_URL~g" environments/remote-k8s-env.json > /tmp/env.json && npm run cli -- -u http://mojaloop-testing-toolkit:5050 -l 2 -i collections/provisioning -e /tmp/env.json --report-format html --report-target file://reports/ttk-provisioning-report.html'
user: root
profiles:
- ttk-provisioning-remote-k8s
Expand Down Expand Up @@ -881,8 +881,8 @@ services:
context: ./packages/callback-handler-svc
cache_from:
- mojaloop/callback-handler-svc:${TEST_CALLBACK_HAND_SVC_VERSION}
# ports:
# - "3001:3001"
ports:
- "30000:3001"
networks:
- mojaloop-net
volumes:
Expand All @@ -901,6 +901,7 @@ services:
- callback-handler
- all-services
- als-test
- oracle

callback-handler-svc-cl-sim:
image: mojaloop/callback-handler-svc:${TEST_CALLBACK_HAND_SVC_VERSION}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"inputValues": {
"HOST_ACCOUNT_LOOKUP_SERVICE": "K6_SCRIPT_ALS_ENDPOINT_URL",
"HOST_ACCOUNT_LOOKUP_SERVICE": "K6_SCRIPT_FSPIOP_ALS_ENDPOINT_URL",
"HOST_ACCOUNT_LOOKUP_ADMIN": "K6_SCRIPT_ALS_ADMIN_ENDPOINT_URL",
"HOST_CENTRAL_LEDGER": "K6_SCRIPT_ADMIN_ENDPOINT_URL",
"HOST_QUOTING_SERVICE": "K6_SCRIPT_FSPIOP_QUOTES_ENDPOINT_URL",
"HOST_SIMULATOR": "K6_SCRIPT_ORACLE_ENDPOINT_URL",
"accept": "application/vnd.interoperability.parties+json;version=1.0",
"acceptParticipants": "application/vnd.interoperability.participants+json;version=1.0",
"acceptQuotes": "application/vnd.interoperability.quotes+json;version=1.0",
Expand Down
21 changes: 21 additions & 0 deletions packages/k6-tests/config/fspiopParallel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"scenarios": {
"fspiopParallel": {
"executor": "ramping-vus",
"exec": "fspiopParallelScenarios",
"env": {
"UNIDIRECTIONAL": "false"
},
"startVUs": 1,
"stages": [
{ "duration": "30s", "target": 1 },
{ "duration": "5m", "target": 1 }
]
}
},
"thresholds": {
"iteration_duration": [ "p(95)<1000" ],
"http_req_failed": [ "rate<0.01" ],
"http_req_duration": [ "p(95)<1000" ]
}
}
20 changes: 20 additions & 0 deletions packages/k6-tests/config/fspiopQuotesNoCallbackConstantRate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"scenarios": {
"fspiopQuotesNoCallbackConstantRate": {
"executor": "constant-arrival-rate",
"exec": "fspiopQuotesNoCallbackConstantRateScenarios",
"env": {
"UNIDIRECTIONAL": "false"
},
"preAllocatedVUs": 200,
"timeUnit": "1s",
"duration": "5m",
"rate": 1000
}
},
"thresholds": {
"iteration_duration": [ "p(95)<1000" ],
"http_req_failed": [ "rate<0.01" ],
"http_req_duration": [ "p(95)<1000" ]
}
}
4 changes: 2 additions & 2 deletions packages/k6-tests/config/fspiopTransfers.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"startVUs": 1,
"stages": [
{ "duration": "30s", "target": 30 },
{ "duration": "5m", "target": 30 }
{ "duration": "30s", "target": 10 },
{ "duration": "5m", "target": 10 }
]
}
},
Expand Down
1 change: 1 addition & 0 deletions packages/k6-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export { fspiopDiscoveryScenarios } from './scenarios/fspiopDiscovery.js';
export { fspiopTransfersScenarios } from './scenarios/fspiopTransfers.js';
export { fspiopTransfersNoCallbackScenarios } from './scenarios/fspiopTransfersNoCallback.js';
export { fspiopQuotesScenarios } from './scenarios/fspiopQuotes.js';
export { fspiopParallelScenarios } from './scenarios/fspiopParallel.js';

const configFile = __ENV.K6_SCRIPT_CONFIG_FILE_NAME ? './config/' + __ENV.K6_SCRIPT_CONFIG_FILE_NAME : './config/test.json';
const testConfig = JSON.parse(open(configFile));
Expand Down
5 changes: 5 additions & 0 deletions packages/k6-tests/scenarios/fspiopParallel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { parallelRequests } from "../scripts/parallelRequests.js";

export function fspiopParallelScenarios() {
parallelRequests();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { postQuotesNoCallbackConstantRate } from "../scripts/postQuotesNoCallbackConstantRate.js";

export function fspiopQuotesNoCallbackConstantRateScenarios() {
postQuotesNoCallbackConstantRate();
}
204 changes: 204 additions & 0 deletions packages/k6-tests/scripts/parallelRequests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import http from 'k6/http';
import { check, group } from 'k6';
import { Trace } from "../common/trace.js";
import { getTwoItemsFromArray } from "../common/utils.js";
import { crypto } from "k6/experimental/webcrypto";


// K6_SCRIPT_FSPIOP_ALS_PAYEE_PARTYID=${__ENV.K6_SCRIPT_FSPIOP_ALS_PAYEE_PARTYID},
// K6_SCRIPT_FSPIOP_PAYER_FSP_ID=${__ENV.K6_SCRIPT_FSPIOP_PAYER_FSP_ID},
// K6_SCRIPT_FSPIOP_PAYEE_FSP_ID=${__ENV.K6_SCRIPT_FSPIOP_PAYEE_FSP_ID},
// K6_SCRIPT_CALLBACK_HANDLER_SERVICE_WS_URL=${__ENV.K6_SCRIPT_CALLBACK_HANDLER_SERVICE_WS_URL},

console.log(`Env Vars -->
K6_SCRIPT_WS_TIMEOUT_MS=${__ENV.K6_SCRIPT_WS_TIMEOUT_MS},
K6_SCRIPT_FSPIOP_ALS_ENDPOINT_URL=${__ENV.K6_SCRIPT_FSPIOP_ALS_ENDPOINT_URL},
K6_SCRIPT_ADMIN_ENDPOINT_URL=${__ENV.K6_SCRIPT_ADMIN_ENDPOINT_URL},
K6_SCRIPT_ORACLE_ENDPOINT_URL=${__ENV.K6_SCRIPT_ORACLE_ENDPOINT_URL},
K6_SCRIPT_FSPIOP_FSP_POOL=${__ENV.K6_SCRIPT_FSPIOP_FSP_PAYER_POOL}
`);

const fspList = JSON.parse(__ENV.K6_SCRIPT_FSPIOP_FSP_POOL)
const amount = __ENV.K6_SCRIPT_FSPIOP_QUOTES_AMOUNT.toString()
const currency = __ENV.K6_SCRIPT_FSPIOP_QUOTES_CURRENCY
const ilpPacket = __ENV.K6_SCRIPT_FSPIOP_TRANSFERS_ILPPACKET
const condition = __ENV.K6_SCRIPT_FSPIOP_TRANSFERS_CONDITION

export function parallelRequests() {
group("parallelRequests", 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 payeeId = payeeFsp['partyId'];
const payerFspId = payerFsp['fspId'];
const payeeFspId = payeeFsp['fspId'];

const partiesStartTs = Date.now();
const partiesTraceParent = Trace();
const partiesParams = {
tags: {
payerFspId,
payeeFspId
},
headers: {
'Accept': 'application/vnd.interoperability.parties+json;version=1.1',
'Content-Type': 'application/vnd.interoperability.parties+json;version=1.1',
'FSPIOP-Source': payerFspId,
'Date': (new Date()).toUTCString(),
'traceparent': partiesTraceParent.toString(),
'tracestate': `tx_end2end_start_ts=${partiesStartTs}`
},
};

const quotesStartTs = Date.now();
const quotesTraceParent = Trace();
const quoteId = crypto.randomUUID();
const transactionId = crypto.randomUUID();

const quotesParams = {
tags: {
payerFspId,
payeeFspId
},
headers: {
'accept': 'application/vnd.interoperability.quotes+json;version=1.0',
'Content-Type': 'application/vnd.interoperability.quotes+json;version=1.0',
'FSPIOP-Source': payerFspId,
'FSPIOP-Destination': payeeFspId,
'Date': (new Date()).toUTCString(),
'traceparent': quotesTraceParent.toString(),
'tracestate': `tx_end2end_start_ts=${quotesStartTs}`
},
};

const quotesBody = {
"quoteId": quoteId,
"transactionId": transactionId,
"payer": {
"partyIdInfo": {
"partyIdType": "MSISDN",
"partyIdentifier": `${payerFsp['partyId']}`,
"fspId": payerFspId,
"extensionList": {
"extension": [
{
"key": "test1",
"value": "test1"
},
{
"key": "test2",
"value": "test2"
}
]
}
},
"personalInfo": {
"complexName": {
"firstName": "Alice",
"middleName": "A",
"lastName": "Alison"
},
"dateOfBirth": "1970-01-01"
}
},
"payee": {
"partyIdInfo": {
"partyIdType": "MSISDN",
"partyIdentifier": `${payeeFsp['partyId']}`,
"fspId": payeeFspId,
"extensionList": {
"extension": [
{
"key": "test3",
"value": "test3"
},
{
"key": "test4",
"value": "test4"
}
]
}
},
"personalInfo": {
"complexName": {
"firstName": "Bob",
"middleName": "B",
"lastName": "Bloggs"
},
"dateOfBirth": "1970-01-01"
}
},
"amountType": "SEND",
"amount": {
"amount": `${amount}`,
"currency": `${currency}`
},
"transactionType": {
"scenario": "TRANSFER",
"initiator": "PAYER",
"initiatorType": "CONSUMER"
},
"extensionList": {
"extension": [
{
"key": "quoteExtension1",
"value": "quoteExtension1"
},
{
"key": "quoteExtension2",
"value": "quoteExtension2"
}
]
}
}


const transfersStartTs = Date.now();
const transferId = crypto.randomUUID();
const transfersTraceParent = Trace();
const transfersParams = {
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': transfersTraceParent.toString(),
'tracestate': `tx_end2end_start_ts=${transfersStartTs}`
},
};

const transfersBody = {
"transferId": transferId,
"payerFsp": payerFspId,
"payeeFsp": payeeFspId,
"amount": {
amount,
currency
},
"expiration": "2030-01-01T00:00:00.000Z",
ilpPacket,
condition
}

const res = http.batch([
['GET', `${__ENV.K6_SCRIPT_FSPIOP_ALS_ENDPOINT_URL}/parties/MSISDN/${payeeId}`, null, partiesParams],
['POST', `${__ENV.K6_SCRIPT_FSPIOP_QUOTES_ENDPOINT_URL}/quotes`, JSON.stringify(quotesBody), quotesParams],
['POST', `${__ENV.K6_SCRIPT_FSPIOP_TRANSFERS_ENDPOINT_URL}/transfers`, JSON.stringify(transfersBody), transfersParams]
])
check(res[0], { 'ALS_FSPIOP_GET_PARTIES_RESPONSE_IS_202' : (r) => r.status == 202 });
check(res[1], { 'QUOTES_FSPIOP_POST_QUOTES_RESPONSE_IS_202' : (r) => r.status == 202 });
check(res[2], { 'TRANSFERS_FSPIOP_POST_TRANSFERS_RESPONSE_IS_202' : (r) => r.status == 202 });
});
}
Loading

0 comments on commit dbaa724

Please sign in to comment.