Skip to content

Commit

Permalink
K6 floating point test visa
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruben committed Jan 7, 2025
1 parent c563a77 commit 7d24524
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion k6/models/initalize-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class InitializePaymentModel {
paymentId,
maxTimeoutAttempts,
minPassRatePercentage,
amount,
) {
// reset db
resetPage.resetDB(resetScript);
Expand All @@ -33,7 +34,7 @@ export default class InitializePaymentModel {
// Change status of all PAs to included and check response
programsPage.updateRegistrationStatusAndLog(programId, 'included');

paymentsPage.createPayment(programId);
paymentsPage.createPayment(programId, amount);
// Monitor that 10% of payments is successful and then stop the test
return paymentsPage.getPaymentResults(
programId,
Expand Down
4 changes: 2 additions & 2 deletions k6/models/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ const { baseUrl } = config;

export default class paymentsModel {
constructor() {}
createPayment(programId) {
createPayment(programId, amount) {
const url = `${baseUrl}api/programs/${programId}/payments`;
const payload = JSON.stringify({
payment: 3,
amount: 10,
amount,
});
const params = {
headers: {
Expand Down
2 changes: 2 additions & 0 deletions k6/tests/payment100kRegistrationOCW.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const programId = 3;
const paymentId = 3;
const maxTimeoutAttempts = 200;
const minPassRatePercentage = 10;
const amount = 11.11; // Using an amount with cents. To ensure we handle javascript floating point precision issues

export const options = {
thresholds: {
Expand All @@ -30,6 +31,7 @@ export default function () {
paymentId,
maxTimeoutAttempts,
minPassRatePercentage,
amount,
);
check(monitorPayment, {
'Payment progressed successfully status 200': (r) => {
Expand Down

0 comments on commit 7d24524

Please sign in to comment.