Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix-Env-TC] Fix ephemeral flaky TCs #294

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ jobs:
export CALLBACK_URL="https://$NGROK_PUBLIC_URL"
echo -n "Public url ."
echo $CALLBACK_URL
./gradlew test -Dcucumber.filter.tags="@gov"
./gradlew test -Dcucumber.filter.tags="@Bulk"
echo -n "Test execution is completed, kill ngrok"
pkill ngrok
- store_test_results:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void setProgramId(String programId) {

@When("I call the batch summary API with expected status of {int} with total {int} txns")
public void callBatchSummaryAPI(int expectedStatus, int totalTxns) {
await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
await().atMost(100, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
if (authEnabled) {
requestSpec.header("Authorization", "Bearer " + scenarioScopeState.accessToken);
Expand Down Expand Up @@ -212,7 +212,7 @@ public void checkIfCreatedAtIsNotNull(String status) {

@When("I call the batch details API with expected status of {int} with total {int} txns")
public void callBatchDetailsAPI(int expectedStatus, int totalTxns) {
await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
await().atMost(100, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
RequestSpecification requestSpec = Utils.getDefaultSpec(scenarioScopeState.tenant);
if (authEnabled) {
requestSpec.header("Authorization", "Bearer " + scenarioScopeState.accessToken);
Expand Down Expand Up @@ -364,7 +364,10 @@ public void iFetchBatchIDFromBatchTransactionAPISResponse() {

@Then("I check for result file URL validity")
public void iCheckForResultFileURLValidity() {
assertThat(isValidURL(scenarioScopeState.batchAndSubBatchSummaryResponse.getFile())).isTrue();
await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
logger.info("batch summary file response is : {}", scenarioScopeState.batchAndSubBatchSummaryResponse.getFile());
assertThat(isValidURL(scenarioScopeState.batchAndSubBatchSummaryResponse.getFile())).isTrue();
});
}

boolean isValidURL(String url) {
Expand Down Expand Up @@ -603,16 +606,19 @@ public void iCallTheBatchSummaryAPIForSubBatchSummaryWithExpectedStatusOf(int ex

@Then("I am able to parse sub batch summary response")
public void iAmAbleToParseSubBatchSummaryResponse() {
scenarioScopeState.batchAndSubBatchSummaryResponse = null;
assertThat(scenarioScopeState.response).isNotNull();
assertThat(scenarioScopeState.response).isNotEmpty();
try {
scenarioScopeState.batchAndSubBatchSummaryResponse = objectMapper.readValue(scenarioScopeState.response,
BatchAndSubBatchSummaryResponse.class);
} catch (Exception e) {
logger.error("Error parsing the batch summary response", e);
}
assertThat(scenarioScopeState.batchAndSubBatchSummaryResponse).isNotNull();
await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
scenarioScopeState.batchAndSubBatchSummaryResponse = null;
assertThat(scenarioScopeState.response).isNotNull();
assertThat(scenarioScopeState.response).isNotEmpty();
try {
scenarioScopeState.batchAndSubBatchSummaryResponse = objectMapper.readValue(scenarioScopeState.response,
BatchAndSubBatchSummaryResponse.class);
} catch (Exception e) {
logger.error("Error parsing the batch summary response", e);
}
assertThat(scenarioScopeState.batchAndSubBatchSummaryResponse).isNotNull();
assertThat(scenarioScopeState.batchAndSubBatchSummaryResponse.getFile()).isNotNull();
});
}

@And("I call the sub batch summary API for sub batch summary with expected status of {int} and total count {int}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,11 @@ public void redeemVoucherFailureUsingAnnotation() {

@Then("I check for redeem voucher failure")
public void redeemVoucherFailure() {
iCanCreateAnRedeemVoucherRequestDTOForVoucherRedemption();
iCallTheRedeemVoucherAPIWithExpectedStatusOf(200);
assertUnsuccessfulRedemption();
await().atMost(awaitMost, SECONDS).pollDelay(pollDelay, SECONDS).pollInterval(pollInterval, SECONDS).untilAsserted(() -> {
iCanCreateAnRedeemVoucherRequestDTOForVoucherRedemption();
iCallTheRedeemVoucherAPIWithExpectedStatusOf(200);
assertUnsuccessfulRedemption();
});
}

@After("@redeemVoucherSuccess")
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/resources/authentication.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Authentication test for services routed through kong & keycloak

@keycloak-user-setup @keycloak-user-teardown @kong-teardown
Scenario: Unauthorized channel-connector test
Scenario: CCT-001 Unauthorized channel-connector test
Given I have tenant as "paymentBB2"
And I can mock TransactionChannelRequestDTO
And I register channel service using config
Expand All @@ -12,7 +12,7 @@ Feature: Authentication test for services routed through kong & keycloak
Then I should get non empty response

@keycloak-user-setup @keycloak-user-teardown @kong-teardown
Scenario: Authorized channel-connector test
Scenario: CCT-002 Authorized channel-connector test
Given I have tenant as "paymentBB2"
And I can mock TransactionChannelRequestDTO
And I register channel service using config
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/resources/batch.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@Bulk
Feature: Batch Details API test

@gov @batch-teardown
Expand Down Expand Up @@ -295,7 +296,7 @@ Feature: Batch Details API test
When I make the "POST" request to "/callback" endpoint with expected status of 200
Then I should be able to extract response body from callback for batch
And I can stop mock server
@gov @batch-teardown
@gov @batch-teardown @Bulk
Scenario: BD-019 Batch summary response result file URL Test
Given I have the demo csv file "ph-ee-bulk-demo-6.csv"
And I have tenant as "paymentBB2"
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/resources/billPay.feature
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ Feature: Bill Payment P2G Test
And I can call the biller RTP status API with expected status of 200 until I get the rtpStatus as "ACCEPTED"

@gov
Scenario: Unsupported header validation for Bill Payments API
Scenario: BP-006 Unsupported header validation for Bill Payments API
Given I have tenant as "paymentBB2"
And I generate clientCorrelationId
And I have bill id as "001"
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/resources/bulkPayment.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@gov @ext
Feature: Test ability to make payment to individual with bank account

Scenario: Input CSV file using the batch transaction API and poll batch summary API till we get completed status
Scenario: BT-002 Input CSV file using the batch transaction API and poll batch summary API till we get completed status
Given I have tenant as "paymentbb1"
And I have the demo csv file "bulk_payment.csv"
And I create a list of payee identifiers from csv file
Expand All @@ -25,7 +25,7 @@ Feature: Test ability to make payment to individual with bank account
And Status of transaction is "COMPLETED"
And I should have matching total txn count and successful txn count in response

Scenario: Bulk Transfer with ClosedLoop and Mojaloop
Scenario: BT-002 Bulk Transfer with ClosedLoop and Mojaloop
Given I have tenant as "paymentbb2"
And I have the demo csv file "bulk_payment_closedl_mock_mojaloop.csv"
And I create a list of payee identifiers from csv file
Expand All @@ -49,7 +49,7 @@ Feature: Test ability to make payment to individual with bank account
And Status of transaction is "COMPLETED"
And My total txns 8 and successful txn count in response should Match

Scenario: Bulk Transfer with ClosedLoop and GSMA
Scenario: BT-001 Bulk Transfer with ClosedLoop and GSMA
#payer 1 creation
Given I have Fineract-Platform-TenantId as "payerfsp2"
And I initialize the payee list
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/resources/identityMapperTest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Feature: Identity Account Mapper Api Test
# Then I will sleep for 3000 millisecond
Then I should be able to verify that the "PUT" method to "/updateBeneficiaryApiTest" endpoint received a request with required parameter in body
@gov
Scenario: Update a single beneficiary with Banking Institution Code
Scenario: UB-001 Update a single beneficiary with Banking Institution Code
When I create an IdentityMapperDTO for 1 Register Beneficiary with payment modality as "ACCOUNT_ID"
When I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiaryApiTest"
When I create an IdentityMapperDTO for 1 update Beneficiary with banking institution code as "lion"
Expand Down Expand Up @@ -228,14 +228,14 @@ Feature: Identity Account Mapper Api Test
And I should be able to verify that the "PUT" method to "/accountLookupTest" endpoint received a request with validation

@gov
Scenario: Fetch Beneficiaries API Test
Scenario: FB-001 Fetch Beneficiaries API Test
Given I create an IdentityMapperDTO for Register Beneficiary
When I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiaryApiTest"
# And I will sleep for 3000 millisecond
Then I will call the fetch beneficiary API with expected status of 200
And I will assert the fields from fetch beneficiary response
@gov @ext
Scenario: Batch Account Lookup Integration Test
Scenario: BAL-001 Batch Account Lookup Integration Test
Given I create an IdentityMapperDTO for Register Beneficiary from csv file
When I call the register beneficiary API with expected status of 202 and stub "/registerBeneficiaryApiTest"
# And I will sleep for 3000 millisecond
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/resources/mockFlowTest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Mock Flow Test

@ext
Scenario: Test for minimal mock fund transfer account lookup flow
Scenario: MFT-003 Test for minimal mock fund transfer account lookup flow
Given I have Fineract-Platform-TenantId as "payeefsp1"
When I call the create payer client endpoint
Then I call the create savings product endpoint
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/resources/mojaloop.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@gov @ext
Feature: Mojaloop test

Scenario: ML connector partial payee party lookup test
Scenario: MLT-001 ML connector partial payee party lookup test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payee"
When I call the create client endpoint for "payee"
Expand All @@ -18,7 +18,7 @@ Feature: Mojaloop test
Then I should be able to verify the callback for lookup
Then I can stop mock server

Scenario: ML connector partial payee quotation test
Scenario: MLT-002 ML connector partial payee quotation test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payee"
When I call the create client endpoint for "payee"
Expand All @@ -35,7 +35,7 @@ Feature: Mojaloop test
Then I should be able to verify the callback for quotation
Then I can stop mock server

Scenario: ML connector partial payee transfer test
Scenario: MLT-003 ML connector partial payee transfer test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payee"
When I call the create client endpoint for "payee"
Expand All @@ -56,7 +56,7 @@ Feature: Mojaloop test
Then I should be able to verify the callback for transfer
Then I can stop mock server

Scenario: Payer Fund Transfer Flow test
Scenario: PFT-001 Payer Fund Transfer Flow test
Given I am setting up Mojaloop
Given I have Fineract-Platform-TenantId for "payer"
When I call the create client endpoint for "payer"
Expand Down Expand Up @@ -101,7 +101,7 @@ Feature: Mojaloop test
Then I assert "payer" balance to be 11
Then I assert "payee" balance to be 11

Scenario: Bulk Transfer with Mojaloop
Scenario: BTM-001 Bulk Transfer with Mojaloop
Given I am setting up Mojaloop
When I create and setup a "payer" with account balance of 12
When I create and setup a "payee" with account balance of 10
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/resources/operationsBatch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Operations APP related feature

@gov @ops-batch-setup @ops-batch-teardown
Scenario: Batches API no filter test
Scenario: OBA-001 Batches API no filter test
Given I have tenant as "paymentBB2"
When I call the operations-app auth endpoint with username: "mifos" and password: "password"
Then I should get a valid token
Expand All @@ -11,7 +11,7 @@ Feature: Operations APP related feature
And I am able to parse batch paginated response into DTO

@gov @ext @ops-batch-setup @ops-batch-teardown
Scenario: Batches API batchId filter test
Scenario: OBA-002 Batches API batchId filter test
Given I have tenant as "paymentBB2"
And I have the demo csv file "payerIdentifier-resolution-using-budgetAccount.csv"
And I have the registeringInstituteId "123"
Expand All @@ -37,7 +37,7 @@ Feature: Operations APP related feature
# assert single batch is returned
# set offset to 1 and limit to 1
@gov @ops-batch-setup @ops-batch-teardown
Scenario: Batches API pagination test
Scenario: OBA-003 Batches API pagination test
# Batch 1 call
Given I have tenant as "paymentBB2"
And I have the demo csv file "payerIdentifier-resolution-using-budgetAccount.csv"
Expand Down Expand Up @@ -76,7 +76,7 @@ Feature: Operations APP related feature
# calculate endTime
# query using startTime and endTime ->> then I should get 5 txn
@gov @ext @ops-batch-setup @ops-batch-teardown
Scenario: Batches API date filter test
Scenario: OBA-004 Batches API date filter test
# Given I will sleep for 5000 millisecond
And I have tenant as "paymentBB2"
And I store this time as start time
Expand Down
22 changes: 11 additions & 11 deletions src/test/java/resources/voucherManagementTest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Feature: Voucher Management Api Test

@gov
Scenario: Create Voucher Api Test
Scenario: VCR-001 Create Voucher Api Test
When I can inject MockServer
Then I can start mock server
And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200
Expand All @@ -11,19 +11,19 @@ Feature: Voucher Management Api Test
Then I should be able to extract response body from callback

@gov @createVoucher
Scenario: Activate Voucher Api Test
Scenario: VA-001 Activate Voucher Api Test
Given I can create a voucher
Given I can create an VoucherRequestDTO for voucher activation
And I can register the stub with "/activateVoucher" endpoint for "PUT" request with status of 200
When I call the activate voucher API with expected status of 202 and stub "/activateVoucher"
Then I should be able to assert response body from callback on "/activateVoucher"

@gov @createAndActivateVoucher
Scenario: Redeem Voucher API Test
Scenario: VR-001 Redeem Voucher API Test
Then I check for redeem voucher success

@gov @createAndActivateVoucher
Scenario: Reactivate Voucher Api Test
Scenario: VRE-001 Reactivate Voucher Api Test
Given I can create an VoucherRequestDTO for voucher suspension
And I can register the stub with "/suspendVoucher" endpoint for "PUT" request with status of 200
When I call the suspend voucher API with expected status of 202 and stub "/suspendVoucher"
Expand All @@ -33,7 +33,7 @@ Feature: Voucher Management Api Test
Then I check for redeem voucher success

@gov @createAndActivateVoucher
Scenario: Validity Check Voucher Api Test
Scenario: VVA-001 Validity Check Voucher Api Test
When I can register the stub with "/validity" endpoint for "PUT" request with status of 200
And I call the validity check API with expected status of 202 and stub "/validity"
Then I can extract result from validation callback and assert if validation is successful on "/validity"
Expand All @@ -53,7 +53,7 @@ Feature: Voucher Management Api Test
Then I check for redeem voucher failure

@gov @createAndActivateVoucher
Scenario: Fetch Voucher Api Test
Scenario: VF-001 Fetch Voucher Api Test
Then I will call the fetch voucher API with expected status of 200
And I will assert the fields from fetch voucher response
And I can stop mock server
Expand All @@ -78,18 +78,18 @@ Feature: Voucher Management Api Test
Then I check for redeem voucher failure

@gov
Scenario: Unsupported Parameter Validation for Create Voucher API test
Scenario: VCR-002 Unsupported Parameter Validation for Create Voucher API test
Given I can create an VoucherRequestDTO for voucher creation with unsupported parameter parameter
When I call the create voucher API with expected status of 400 and stub "/createVoucher"
Then I should be able to assert the create voucher validation for negative response

@gov @createAndActivateVoucher
Scenario: Conflicting/unique data validations check for Create Voucher API
Scenario: VCR-003 Conflicting/unique data validations check for Create Voucher API
Then I will call the fetch voucher API with expected status of 200
When I call the create voucher API with expected status of 409 and stub "/createVoucher"

@gov
Scenario: Unsupported header validation for Create Voucher Api Test
Scenario: VCR-004 Unsupported header validation for Create Voucher Api Test
Given I can create an VoucherRequestDTO for voucher creation
When I call the create voucher API having invalid header with expected status of 400 and stub "/createVoucher"
Then I should get non empty response
Expand All @@ -104,7 +104,7 @@ Feature: Voucher Management Api Test
When I call the create, Activate voucher API and store it in "vouchertest/loadTest_demo.csv"

@gov
Scenario: Voucher Status Check for inactive voucher, active voucher and redeemed voucher
Scenario: VS-001 Voucher Status Check for inactive voucher, active voucher and redeemed voucher
When I can inject MockServer
Then I can start mock server
And I can register the stub with "/createVoucher" endpoint for "PUT" request with status of 200
Expand All @@ -127,7 +127,7 @@ Feature: Voucher Management Api Test


@createAndActivateVoucher @gov
Scenario: Voucher Status Check for inactive voucher, active voucher, suspended and cancelled voucher
Scenario: VS-002 Voucher Status Check for inactive voucher, active voucher, suspended and cancelled voucher
Given I can create an VoucherRequestDTO for voucher suspension
And I can register the stub with "/suspendVoucher" endpoint for "PUT" request with status of 200
When I call the suspend voucher API with expected status of 202 and stub "/suspendVoucher"
Expand Down