Skip to content

Commit

Permalink
PLT-136 Run e2e tests on impl environment (#1283)
Browse files Browse the repository at this point in the history
  • Loading branch information
oluwolenpbc authored Aug 26, 2024
1 parent bfc2a00 commit 18f6f82
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 10 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: end-to-end tests

on:
pull_request:
workflow_call:
workflow_dispatch: # Allow manual trigger

# Ensure we have only one e2e test running at a time
concurrency:
group: e2e-test

jobs:
test:
runs-on: self-hosted

env:
# Keystore location must be full path for spring framework
AB2D_BFD_KEYSTORE_LOCATION: "${{ github.workspace }}/opt/ab2d/ab2d_bfd_keystore"
AB2D_V2_ENABLED: 'true'
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Install Maven 3.6.3
run: |
export PATH="$PATH:/opt/maven/bin"
echo "PATH=$PATH" >> $GITHUB_ENV
if mvn -v; then echo "Maven already installed" && exit 0; else echo "Installing Maven"; fi
tmpdir="$(mktemp -d)"
curl -LsS https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz | tar xzf - -C "$tmpdir"
sudo rm -rf /opt/maven
sudo mv "$tmpdir/apache-maven-3.6.3" /opt/maven
- name: Set env vars from AWS params in management account
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
ARTIFACTORY_URL=/artifactory/url
ARTIFACTORY_USER=/artifactory/user
ARTIFACTORY_PASSWORD=/artifactory/password
- name: Assume role in AB2D impl account
uses: aws-actions/configure-aws-credentials@v3
with:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.IMPL_ACCOUNT_ID }}:role/delegatedadmin/developer/ab2d-test-github-actions

- name: Set env vars from AWS params in impl account
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
env:
AWS_REGION: ${{ vars.AWS_REGION }}
with:
params: |
AB2D_BFD_KEYSTORE_PASSWORD=/bfd/keystore-password
OKTA_CLIENT_ID=/okta/test-pdp-100-id
OKTA_CLIENT_PASSWORD=/okta/test-pdp-100-secret
SECONDARY_USER_OKTA_CLIENT_ID=/okta/test-pdp-1000-id
SECONDARY_USER_OKTA_CLIENT_PASSWORD=/okta/test-pdp-1000-secret
- name: Create opt/ab2d directory and download keystore
run: |
mkdir -p opt/ab2d
aws s3 cp s3://ab2d-east-impl-main/ab2d_imp_keystore $AB2D_BFD_KEYSTORE_LOCATION
test -f $AB2D_BFD_KEYSTORE_LOCATION && echo "created keystore file"
- name: Run e2e-bfd-test
run: |
mvn test -s settings.xml -pl e2e-bfd-test -am -Dtest=EndToEndBfdTests -DfailIfNoTests=false -Dusername=$ARTIFACTORY_USER -Dpassword=$ARTIFACTORY_PASSWORD -Drepository_url=$ARTIFACTORY_URL --no-transfer-progress
- name: Run e2e-test
env:
E2E_ENVIRONMENT: 'IMPL'
run: |
mvn test -s settings.xml -pl e2e-test -am -Dtest=TestRunner -DfailIfNoTests=false -Dusername=$ARTIFACTORY_USER -Dpassword=$ARTIFACTORY_PASSWORD -Drepository_url=$ARTIFACTORY_URL --no-transfer-progress
12 changes: 3 additions & 9 deletions .github/workflows/unit-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
test:
runs-on: self-hosted

env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true

steps:
- name: Checkout Code
uses: actions/checkout@v3
Expand Down Expand Up @@ -37,15 +40,6 @@ jobs:
aws-region: ${{ vars.AWS_REGION }}
role-to-assume: ${{ vars.AB2D_DEV_ROLE }}

- name: Set env vars from AWS params
uses: cmsgov/ab2d-bcda-dpc-platform/actions/aws-params-env-action@main
with:
params: |
OKTA_CLIENT_ID=/okta/client-id
OKTA_CLIENT_PASSWORD=/okta/client-secret
SECONDARY_USER_OKTA_CLIENT_ID=/secondary-okta/client-id
SECONDARY_USER_OKTA_CLIENT_PASSWORD=/secondary-okta/client-secret
- name: Install Maven 3.6.3
run: |
export PATH="$PATH:/opt/maven/bin"
Expand Down
5 changes: 5 additions & 0 deletions e2e-test/src/test/java/gov/cms/ab2d/e2etest/TestRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ private Pair<String, JSONArray> performStatusRequests(List<String> contentLocati

if (statusResponseAgain.statusCode() == 500) {
// No values returned if 500
log.info("500 response body: " + statusResponseAgain.body());
return null;
}
assertEquals(200, statusResponseAgain.statusCode());
Expand Down Expand Up @@ -674,6 +675,10 @@ private APIClient createSecondClient() throws InterruptedException, JSONExceptio
String oktaClientId = System.getenv("SECONDARY_USER_OKTA_CLIENT_ID");
String oktaPassword = System.getenv("SECONDARY_USER_OKTA_CLIENT_PASSWORD");

if (StringUtils.isBlank(oktaClientId) || StringUtils.isBlank(oktaPassword)) {
fail("Both SECONDARY_USER_OKTA_CLIENT_ID and SECONDARY_USER_OKTA_CLIENT_PASSWORD must be set in env");
}

return new APIClient(baseUrl, oktaUrl, oktaClientId, oktaPassword);
}

Expand Down
2 changes: 1 addition & 1 deletion e2e-test/src/test/resources/impl-config.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
okta-url: 'https://test.idp.idm.cms.gov/oauth2/aus2r7y3gdaFMKBol297/v1/token'
base-url: 'https://internal-ab2d-east-impl-460119366.us-east-1.elb.amazonaws.com'
base-url: 'https://impl.ab2d.cms.gov'

0 comments on commit 18f6f82

Please sign in to comment.