Skip to content

Smoke Tests

Smoke Tests #307

Workflow file for this run

name: Smoke Tests
on:
pull_request:
paths:
- .github/workflows/smoke-tests.yml
workflow_dispatch:
inputs:
release_version:
description: The branch of the bcda-app to use for the test execution.
required: true
type: 'string'
default: 'main'
ssas_release_version:
description: The branch of the ssas-app to use for the test execution.
required: true
type: 'string'
default: 'main'
env:
description: The environment in which to run smoke tests
required: true
type: choice
options:
- 'dev'
- 'test'
- 'sandbox'
- 'prod'
default: 'dev'
test_aco:
description: Run the tests using the selected ACO
required: true
type: choice
options:
- 'small'
- 'medium'
- 'large'
- 'extra-large'
- 'dev'
- 'paca'
default: 'dev'
smoke_tests:
description: Flag which indicates if smoke integration tests should be run
required: true
type: boolean
default: true
postman_tests:
description: Flag which indicates if postman integration tests should be run
required: true
type: boolean
default: true
v3_tests:
description: Flag which indicates if v3 integration tests should be run
required: true
type: boolean
default: false
workflow_call:
inputs:
release_version:
description: The branch of the bcda-app to use for the test execution.
required: true
type: 'string'
default: 'main'
ssas_release_version:
description: The branch of the ssas-app to use for the test execution.
required: true
type: 'string'
default: 'main'
env:
description: The environment in which to run smoke tests
required: true
type: string
default: 'dev'
test_aco:
description: Run the tests using the selected ACO
required: true
type: 'string'
default: 'dev'
smoke_tests:
description: Flag which indicates if smoke integration tests should be run
required: true
type: boolean
default: true
postman_tests:
description: Flag which indicates if postman integration tests should be run
required: true
type: boolean
default: true
v3_tests:
description: Flag which indicates if v3 integration tests should be run
required: true
type: boolean
default: false
permissions:
id-token: write
contents: read
env:
RELEASE_ENV: ${{ inputs.env || 'dev' }}
COMPOSE_INTERACTIVE_NO_CLI: 1
TEST_ACO: ${{ inputs.test_aco || 'dev' }}
jobs:
smoke_tests:
environment: ${{ inputs.env || 'dev' }}
name: run smoke tests
runs-on: codebuild-bcda-app-${{github.run_id}}-${{github.run_attempt}}
env:
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
steps:
- name: Get Workflow Inputs
run: echo "${{ toJSON(inputs) }}"
- name: Set creds (non-dev)
if: ${{ env.TEST_ACO == 'dev' }}
run: |
echo "creds=${{ env.RELEASE_ENV }}" >> $GITHUB_ENV
- name: Set creds (dev)
if: ${{ env.TEST_ACO != 'dev' }}
run: |
echo "creds=${{ env.TEST_ACO }}" >> $GITHUB_ENV
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/delegatedadmin/developer/${{ vars.AWS_ROLE_TO_ASSUME }}
- uses: cmsgov/cdap/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
SSAS_CREDENTIALS=/bcda/workflows/${{ env.RELEASE_ENV }}/ssas_admin_credentials
ASSERTION_AUD=/bcda/workflows/${{ env.RELEASE_ENV }}/ssas_assertion_aud
HOST=/bcda/workflows/${{ env.RELEASE_ENV }}/ssas_elb
CLIENT_CREDENTIALS_PARAMS=/bcda/${{ env.RELEASE_ENV }}/${{ env.creds }}_client_credentials
DENYLIST_CLIENT_CREDENTIALS_PARAMS=/bcda/${{ env.RELEASE_ENV }}/denylisted_client_credentials
PACA_CLIENT_CREDENTIALS_PARAMS=/bcda/${{ env.RELEASE_ENV }}/paca_client_credentials
V3_CLIENT_CREDENTIALS_PARAMS=/bcda/${{ env.RELEASE_ENV }}/${{ env.creds }}_v3_client_credentials
- name: checkout bcda-ssas
if: ${{ env.RELEASE_ENV == 'dev' || env.RELEASE_ENV == 'test' }}
uses: actions/checkout@v4
with:
repository: CMSgov/bcda-ssas-app
ref: ${{ inputs.ssas_release_version || 'main' }}
- name: Build SSAS Postman Container
if: ${{ env.RELEASE_ENV == 'dev' || env.RELEASE_ENV == 'test' }}
run: |
docker build -t postman_test -f ./Dockerfiles/Dockerfile.postman_test .
- name: Run SSAS tests
if: ${{ env.RELEASE_ENV == 'dev' || env.RELEASE_ENV == 'test' }}
run: |
docker system prune -af
CLIENT_ID=$(echo $SSAS_CREDENTIALS | jq -r .client_id)
CLIENT_SECRET=$(echo $SSAS_CREDENTIALS | jq -r .client_secret)
docker compose -f docker-compose.test.yml run --rm postman_test test/postman_test/SSAS_Smoke_Test.postman_collection.json -e test/postman_test/aws.postman_environment.json --global-var adminClientId=$CLIENT_ID --global-var adminClientSecret=$CLIENT_SECRET --global-var ssas_client_assertion_aud=$ASSERTION_AUD --global-var host=$HOST --insecure
- name: Checkout code
uses: actions/checkout@v2
- name: Build API Postman Container
run: |
docker compose -f docker-compose.test.yml build --force-rm postman_test
- name: Run Postman Tests
if: ${{ inputs.postman_tests }}
run: |
CLIENT_ID=$(echo $CLIENT_CREDENTIALS_PARAMS | jq -r .client_id)
CLIENT_SECRET=$(echo $CLIENT_CREDENTIALS_PARAMS | jq -r .client_secret)
docker compose -f docker-compose.test.yml run --rm postman_test test/postman_test/BCDA_Tests_Sequential.postman_collection.json \
-e test/postman_test/${{ env.RELEASE_ENV }}.postman_environment.json \
--global-var clientId=${CLIENT_ID} --global-var clientSecret=${CLIENT_SECRET} \
--global-var v2Disabled=false \
--global-var blacklistedClientId=${DENYLIST_CLIENT_ID} --global-var blacklistedClientSecret=${DENYLIST_CLIENT_SECRET} \
--global-var maintenanceMode=""
- name: Run Smoke Tests
if: ${{ inputs.smoke_tests }}
run: |
CLIENT_ID=$(echo $CLIENT_CREDENTIALS_PARAMS | jq -r .client_id)
CLIENT_SECRET=$(echo $CLIENT_CREDENTIALS_PARAMS | jq -r .client_secret)
docker compose -f docker-compose.test.yml run --rm postman_test test/postman_test/BCDA_Postman_Smoke_Tests.postman_collection.json \
-e test/postman_test/${{ env.RELEASE_ENV }}.postman_environment.json \
--global-var clientId=$CLIENT_ID \
--global-var clientSecret=$CLIENT_SECRET \
--global-var maintenanceMode=""
- name: Run PACA Tests
run: |
CLIENT_ID=$(echo $PACA_CLIENT_CREDENTIALS_PARAMS | jq -r .client_id)
CLIENT_SECRET=$(echo $PACA_CLIENT_CREDENTIALS_PARAMS | jq -r .client_secret)
docker compose -f docker-compose.test.yml run --rm postman_test test/postman_test/BCDA_PAC_Postman_Smoke_Tests.postman_collection.json \
-e test/postman_test/${{ env.RELEASE_ENV }}.postman_environment.json \
--global-var clientId=$CLIENT_ID \
--global-var clientSecret=$CLIENT_SECRET \
--global-var maintenanceMode=""
- name: Run v3 Tests
if: ${{ inputs.v3_tests }}
run: |
CLIENT_ID=$(echo $V3_CLIENT_CREDENTIALS_PARAMS | jq -r .client_id)
CLIENT_SECRET=$(echo $V3_CLIENT_CREDENTIALS_PARAMS | jq -r .client_secret)
docker compose -f docker-compose.test.yml run --rm postman_test test/postman_test/BCDA_V3_Tests.postman_collection.json \
-e test/postman_test/${{ env.RELEASE_ENV }}.postman_environment.json \
--global-var clientId=${CLIENT_ID} \
--global-var clientSecret=${CLIENT_SECRET} \
--global-var v3Disabled=false \
--global-var maintenanceMode=""
- name: Success Alert
if: ${{ success() }}
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
# Sends to bcda-deploy
payload: |
channel: "C03S23MJFJS"
attachments:
- color: good
text: "SUCCESS: Smoketests in ${{ env.RELEASE_ENV }} for ${{ inputs.release_version || 'dev' }}. Run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>"
mrkdown_in:
- text
- name: Failure Alert
if: ${{ failure() }}
uses: slackapi/slack-github-action@v2.0.0
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: "C03S23MJFJS"
attachments:
- color: danger
text: "FAILURE: Smoketests in ${{ env.RELEASE_ENV }} for ${{ inputs.release_version || 'dev' }}. Run: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.run_id }}>"
mrkdown_in:
- text