diff --git a/.github/workflows/qa.yaml b/.github/workflows/qa.yaml index 33b243fad..d6a5affe0 100644 --- a/.github/workflows/qa.yaml +++ b/.github/workflows/qa.yaml @@ -4,13 +4,13 @@ on: workflow_dispatch: inputs: environment: - description: 'Environment to run tests against' + description: 'Environment where tests will be run' required: true type: environment testSuite: description: 'Choose the test suite to run' required: false - default: NrtTest + default: InteropTracingTest type: string defaults: @@ -34,39 +34,30 @@ jobs: echo "- branch name: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY echo "- testSuite: \`${{ inputs.testSuite }}\`" >> $GITHUB_STEP_SUMMARY - create_runner: - name: Create Self-Hosted Runner + run_test: + name: Run Cucumber Test Suite runs-on: ubuntu-22.04 environment: ${{ inputs.environment }} + env: + ENVIRONMENT: ${{ inputs.environment }} + ST_VERBOSE_MODE: ${{ vars.ST_VERBOSE_MODE }} steps: - - name: Start GitHub Runner - id: start_runner - uses: pagopa/interop-github-runner-aws-create-action@main + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v3 with: - environment: ${{ inputs.environment }} - aws_region: ${{ secrets.AWS_REGION }} - iam_role_arn: ${{ secrets.ECS_IAM_ROLE_ARN }} - ecs_cluster_name: ${{ secrets.ECS_CLUSTER_NAME }} - ecs_task_definition: ${{ secrets.ECS_TASK_DEFINITION }} - ecs_container_name: ${{ vars.ECS_TASK_CONTAINER_NAME }} - ecs_task_max_duration_seconds: ${{ vars.ECS_TASK_MAX_DURATION_SECONDS }} - ecs_task_subnet_id: ${{ secrets.SUBNET_ID }} - ecs_task_sec_group: ${{ secrets.SEC_GROUP_ID }} - pat_token: ${{ secrets.BOT_TOKEN }} + role-to-assume: ${{ vars.ECS_IAM_ROLE_ARN }} + role-session-name: pn-b2b-client-${{ github.job }}-${{ github.run_id }} + aws-region: eu-south-1 - run_test: - name: Run Cucumber Test Suite - needs: create_runner - runs-on: [self-hosted, "run_id:${{ inputs.environment }}-${{ github.run_id }}"] - environment: ${{ inputs.environment }} - env: - ENVIRONMENT: qa - ST_VERBOSE_MODE: ${{ vars.ST_VERBOSE_MODE }} + - name: Set up Maven + uses: s4u/setup-maven-action@6d44c18d67d9e1549907b8815efa5e4dada1801b # v1.12.0 + with: + java-version: 17 + maven-version: 3.9.8 - steps: - - name: Clone QA test repo - id: clone_qa_repo + - name: Clone the pn-b2b-client repo + id: clone_pn-b2b-client uses: actions/checkout@v2 with: ref: ${{ github.ref_name }} # Branch name to clone @@ -76,23 +67,7 @@ jobs: id: run_qa_tests shell: bash run: | - echo "Run test" - ( cd ./pn-b2b-client/interop-qa-tests && ./mvnw -Dtest=it.pagopa.pn.interop.cucumber.${{ inputs.testSuite }} clean verify ) + set -uo pipefail + echo "Running tests..." + cd ./interop-qa-tests && mvn -Dtest=it.pagopa.pn.interop.cucumber.InteropTracingTest clean verify - delete_runner: - name: Delete Self-Hosted Runner - needs: run_test - if: ${{ always() }} - runs-on: ubuntu-22.04 - environment: ${{ inputs.environment }} - - steps: - - name: Stop Github Runner - id: stop_runner - uses: pagopa/interop-github-runner-aws-cleanup-action@main - with: - environment: ${{ inputs.environment }} - aws_region: ${{ secrets.AWS_REGION }} - iam_role_arn: ${{ secrets.ECS_IAM_ROLE_ARN }} - ecs_cluster_name: ${{ secrets.ECS_CLUSTER_NAME }} - pat_token: ${{ secrets.BOT_TOKEN }} diff --git a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/tracing/TracingSteps.java b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/tracing/TracingSteps.java index 872641967..9d29b65c4 100644 --- a/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/tracing/TracingSteps.java +++ b/interop-qa-tests/src/test/java/it/pagopa/pn/interop/cucumber/steps/tracing/TracingSteps.java @@ -92,6 +92,7 @@ public void retrieveTracingByStatusList(List statusList) { @When("viene recuperata la lista di tracing con stato {string}") public void retrieveTracingByStatus(String status) { retrieveTracing(List.of(TracingState.fromValue(status))); + Assertions.assertFalse(getTracingsResponse.getResults().isEmpty(), String.format("No Tracings were retrieved for the desired status: %s", status)); } public void retrieveTracing(List statusList) { @@ -228,28 +229,37 @@ public void waitForStatus(String state) { .filter(x -> x.getTracingId().equals(submitTracingResponse.getTracingId().toString())) .map(GetTracingsResponseResults::getState) .anyMatch(tracingState -> tracingState.equals(state)), - "" + String.format("The TracingId: %s did not reach the desired status: %s", submitTracingResponse.getTracingId().toString(), state) ); } @Then("viene recuperato il file di tracing appena caricato e si verifica che lo stato sia {string}") - public void retrieveTracingAndVerifyStatus(String status) { + public void retrieveTracingAndVerifyStatus(String state) { GetTracingsResponseResults result; int attempt = 0; int totalPages; try { do { - GetTracingsResponse getTracingsResponse = interopTracingClient.getTracings(attempt, LIMIT_VALUE, List.of(TracingState.fromValue(status))); - result = getTracingsResponse.getResults().stream() + GetTracingsResponse tracingsResponse = interopTracingClient.getTracings(attempt, LIMIT_VALUE, List.of()); + totalPages = tracingsResponse.getTotalCount().intValue(); + result = tracingsResponse.getResults().stream() .filter(x -> x.getTracingId().equals(submitTracingResponse.getTracingId().toString())) .findFirst() .orElse(null); - totalPages = getTracingsResponse.getTotalCount().intValue(); - if (result != null || getTracingsResponse.getResults().isEmpty()) break; - attempt++; - } while (attempt < totalPages); + + if (result != null) { + int finalAttempt = attempt; + pollingService.makePolling( + () -> interopTracingClient.getTracings(finalAttempt, LIMIT_VALUE, List.of()), + res -> res.getResults().stream().anyMatch(x -> x.getTracingId().equals(submitTracingResponse.getTracingId().toString()) && x.getState().equals(state)), + String.format("The TracingId: %s did not reach the desired status: %s", submitTracingResponse.getTracingId().toString(), state) + ); + break; + } else attempt++; + + } while (attempt < totalPages / LIMIT_VALUE + 1); if (result == null) { - throw new RuntimeException("Tracing ID not found after " + totalPages + " attempts!"); + throw new RuntimeException("Tracing ID not found after " + attempt + " attempts!"); } } catch (Exception e) { throw new RuntimeException("There was an error while retrieving the tracing file!"); diff --git a/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/tracing/interop-tracing.feature b/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/tracing/interop-tracing.feature index 16d3a1da1..e82d39685 100644 --- a/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/tracing/interop-tracing.feature +++ b/interop-qa-tests/src/test/resources/it/pagopa/pn/cucumber/tracing/interop-tracing.feature @@ -44,7 +44,7 @@ Feature: Interop Tracing feature | status | | MISSING | | COMPLETED | - | PENDING | +# | PENDING | Line commented since no pending tracings are present | ERROR | # Questo test va eseguito usando un'utenza con cui non sono mai stati caricati file di tracing @@ -94,7 +94,7 @@ Feature: Interop Tracing feature Scenario: [INTEROP-TRACING-11] Verifica stato endpoint di health When viene invocato l'endpoint di health con successo - @interopTracingCsv @ignore + @interopTracingCsv Scenario: [INTEROP-TRACING-12] Invio del file CSV tracing mancante utilizzando l'identificativo del file di tracing non inserito per una determinata data Given l'utenza "TENANT1" effettua le chiamate Given viene recuperata la lista di tracing con stato "MISSING"