Skip to content

Commit

Permalink
chore: Improve usage of test_name in the Acceptance test workflow (#2353
Browse files Browse the repository at this point in the history
)
  • Loading branch information
maastha authored Jun 18, 2024
1 parent 1bf7cfc commit 333dcf9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
31 changes: 6 additions & 25 deletions .github/workflows/acceptance-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
type: string
required: false
test_name:
description: 'Name of the test to run, e.g. TestAccNetworkRSNetworkPeering_basicAzure, empty for all (requires Test group to be specified as well)'
description: 'Name of the test to run, e.g. TestAccNetworkRSNetworkPeering_basicAzure, empty for all (this is regex & requires Test group to be specified as well)'
type: string
required: false
ref:
Expand Down Expand Up @@ -136,8 +136,9 @@ env:
TF_ACC: 1
TF_LOG: ${{ vars.LOG_LEVEL }}
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }}
# Only Migration tests are run when testing a specific previous provider version instead of the latest one
ACCTEST_REGEX_RUN: ${{ inputs.provider_version == '' && '^Test(Acc|Mig)' || '^TestMig' }}
# Only Migration tests are run when a specific previous provider version is set
# If the name (regex) of the test is set, only that test is run
ACCTEST_REGEX_RUN: ${{ inputs.test_name || inputs.provider_version == '' && '^Test(Acc|Mig)' || '^TestMig' }}
MONGODB_ATLAS_BASE_URL: ${{ inputs.mongodb_atlas_base_url }}
MONGODB_ATLAS_ORG_ID: ${{ inputs.mongodb_atlas_org_id }}
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.mongodb_atlas_public_key }}
Expand Down Expand Up @@ -170,7 +171,7 @@ jobs:
runs-on: ubuntu-latest
permissions: {}
env:
mustTrigger: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.test_group == '' && inputs.test_name == '') }}
mustTrigger: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.test_group == '' ) }}
outputs:
advanced_cluster: ${{ steps.filter.outputs.advanced_cluster == 'true' || env.mustTrigger == 'true' }}
assume_role: ${{ steps.filter.outputs.assume_role == 'true' || env.mustTrigger == 'true' }}
Expand All @@ -196,7 +197,7 @@ jobs:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: filter
if: ${{ inputs.test_group == '' && inputs.test_name == '' && env.mustTrigger == 'false' }}
if: ${{ inputs.test_group == '' && env.mustTrigger == 'false' }}
with:
filters: |
advanced_cluster:
Expand Down Expand Up @@ -297,7 +298,6 @@ jobs:
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_PACKAGES: ./internal/service/advancedcluster
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
run: make testacc

assume_role:
Expand Down Expand Up @@ -338,7 +338,6 @@ jobs:
AWS_SESSION_TOKEN: ${{ steps.sts-assume-role.outputs.AWS_SESSION_TOKEN }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_PACKAGES: ./internal/provider
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
run: make testacc

backup:
Expand All @@ -365,7 +364,6 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_S3_BUCKET: ${{ secrets.aws_s3_bucket_backup }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/cloudbackupschedule
./internal/service/cloudbackupsnapshot
Expand Down Expand Up @@ -394,7 +392,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/cluster
./internal/service/globalclusterconfig
Expand All @@ -419,7 +416,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: ./internal/service/clusteroutagesimulation
run: make testacc

Expand Down Expand Up @@ -451,7 +447,6 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_S3_BUCKET: ${{ secrets.aws_s3_bucket_federation }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/alertconfiguration
./internal/service/atlasuser
Expand Down Expand Up @@ -488,7 +483,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: ./internal/service/datalakepipeline
run: make testacc

Expand All @@ -511,7 +505,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: ./internal/service/encryptionatrest
run: make testacc

Expand All @@ -534,7 +527,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: ./internal/service/eventtrigger
run: make testacc

Expand Down Expand Up @@ -568,7 +560,6 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/federateddatabaseinstance
./internal/service/federatedquerylimit
Expand Down Expand Up @@ -598,7 +589,6 @@ jobs:
MONGODB_ATLAS_PROJECT_OWNER_ID: ${{ inputs.mongodb_atlas_project_owner_id }}
CA_CERT: ${{ secrets.ca_cert }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/auditing
./internal/service/backupcompliancepolicy
Expand Down Expand Up @@ -629,7 +619,6 @@ jobs:
MONGODB_ATLAS_LDAP_PORT: ${{ secrets.mongodb_atlas_ldap_port }}
MONGODB_ATLAS_LDAP_CA_CERTIFICATE: ${{ secrets.mongodb_atlas_ldap_ca_certificate }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/ldapconfiguration
./internal/service/ldapverify
Expand Down Expand Up @@ -669,7 +658,6 @@ jobs:
AZURE_VNET_NAME: ${{ secrets.azure_vnet_name }}
AZURE_VNET_NAME_UPDATED: ${{ secrets.azure_vnet_name_updated }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/networkcontainer
./internal/service/networkpeering
Expand Down Expand Up @@ -709,7 +697,6 @@ jobs:
AWS_VPC_CIDR_BLOCK: ${{ vars.AWS_VPC_CIDR_BLOCK }}
AWS_VPC_ID: ${{ vars.AWS_VPC_ID }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/accesslistapikey
./internal/service/project
Expand Down Expand Up @@ -739,7 +726,6 @@ jobs:
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: ./internal/service/pushbasedlogexport
run: make testacc

Expand All @@ -762,7 +748,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: ./internal/service/searchdeployment
run: make testacc

Expand All @@ -785,7 +770,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: ./internal/service/searchindex
run: make testacc

Expand All @@ -810,7 +794,6 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/privatelinkendpointserverless
./internal/service/privatelinkendpointserviceserverless
Expand All @@ -836,7 +819,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/streamconnection
./internal/service/streaminstance
Expand All @@ -861,7 +843,6 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
ACCTEST_PACKAGES: |
./internal/service/controlplaneipaddresses
run: make testacc
7 changes: 1 addition & 6 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ else
ACCTEST_PACKAGES := "./..."
endif

ifdef ACCTEST_REGEX_RUN
# remove newlines and blanks coming from GH Actions
ACCTEST_REGEX_RUN := $(strip $(subst $(newline),, $(ACCTEST_REGEX_RUN)))
else
ACCTEST_REGEX_RUN?=^TestAcc
endif
ACCTEST_REGEX_RUN?=^TestAcc
ACCTEST_TIMEOUT?=300m
PARALLEL_GO_TEST?=20

Expand Down

0 comments on commit 333dcf9

Please sign in to comment.