Skip to content

Commit 333dcf9

Browse files
authored
chore: Improve usage of test_name in the Acceptance test workflow (#2353)
1 parent 1bf7cfc commit 333dcf9

File tree

2 files changed

+7
-31
lines changed

2 files changed

+7
-31
lines changed

.github/workflows/acceptance-tests-runner.yml

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
type: string
1919
required: false
2020
test_name:
21-
description: 'Name of the test to run, e.g. TestAccNetworkRSNetworkPeering_basicAzure, empty for all (requires Test group to be specified as well)'
21+
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)'
2222
type: string
2323
required: false
2424
ref:
@@ -136,8 +136,9 @@ env:
136136
TF_ACC: 1
137137
TF_LOG: ${{ vars.LOG_LEVEL }}
138138
ACCTEST_TIMEOUT: ${{ vars.ACCTEST_TIMEOUT }}
139-
# Only Migration tests are run when testing a specific previous provider version instead of the latest one
140-
ACCTEST_REGEX_RUN: ${{ inputs.provider_version == '' && '^Test(Acc|Mig)' || '^TestMig' }}
139+
# Only Migration tests are run when a specific previous provider version is set
140+
# If the name (regex) of the test is set, only that test is run
141+
ACCTEST_REGEX_RUN: ${{ inputs.test_name || inputs.provider_version == '' && '^Test(Acc|Mig)' || '^TestMig' }}
141142
MONGODB_ATLAS_BASE_URL: ${{ inputs.mongodb_atlas_base_url }}
142143
MONGODB_ATLAS_ORG_ID: ${{ inputs.mongodb_atlas_org_id }}
143144
MONGODB_ATLAS_PUBLIC_KEY: ${{ secrets.mongodb_atlas_public_key }}
@@ -170,7 +171,7 @@ jobs:
170171
runs-on: ubuntu-latest
171172
permissions: {}
172173
env:
173-
mustTrigger: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.test_group == '' && inputs.test_name == '') }}
174+
mustTrigger: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.test_group == '' ) }}
174175
outputs:
175176
advanced_cluster: ${{ steps.filter.outputs.advanced_cluster == 'true' || env.mustTrigger == 'true' }}
176177
assume_role: ${{ steps.filter.outputs.assume_role == 'true' || env.mustTrigger == 'true' }}
@@ -196,7 +197,7 @@ jobs:
196197
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
197198
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
198199
id: filter
199-
if: ${{ inputs.test_group == '' && inputs.test_name == '' && env.mustTrigger == 'false' }}
200+
if: ${{ inputs.test_group == '' && env.mustTrigger == 'false' }}
200201
with:
201202
filters: |
202203
advanced_cluster:
@@ -297,7 +298,6 @@ jobs:
297298
env:
298299
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
299300
ACCTEST_PACKAGES: ./internal/service/advancedcluster
300-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
301301
run: make testacc
302302

303303
assume_role:
@@ -338,7 +338,6 @@ jobs:
338338
AWS_SESSION_TOKEN: ${{ steps.sts-assume-role.outputs.AWS_SESSION_TOKEN }}
339339
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
340340
ACCTEST_PACKAGES: ./internal/provider
341-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
342341
run: make testacc
343342

344343
backup:
@@ -365,7 +364,6 @@ jobs:
365364
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
366365
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
367366
AWS_S3_BUCKET: ${{ secrets.aws_s3_bucket_backup }}
368-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
369367
ACCTEST_PACKAGES: |
370368
./internal/service/cloudbackupschedule
371369
./internal/service/cloudbackupsnapshot
@@ -394,7 +392,6 @@ jobs:
394392
- name: Acceptance Tests
395393
env:
396394
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
397-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
398395
ACCTEST_PACKAGES: |
399396
./internal/service/cluster
400397
./internal/service/globalclusterconfig
@@ -419,7 +416,6 @@ jobs:
419416
- name: Acceptance Tests
420417
env:
421418
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
422-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
423419
ACCTEST_PACKAGES: ./internal/service/clusteroutagesimulation
424420
run: make testacc
425421

@@ -451,7 +447,6 @@ jobs:
451447
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
452448
AWS_S3_BUCKET: ${{ secrets.aws_s3_bucket_federation }}
453449
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
454-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
455450
ACCTEST_PACKAGES: |
456451
./internal/service/alertconfiguration
457452
./internal/service/atlasuser
@@ -488,7 +483,6 @@ jobs:
488483
- name: Acceptance Tests
489484
env:
490485
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
491-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
492486
ACCTEST_PACKAGES: ./internal/service/datalakepipeline
493487
run: make testacc
494488

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

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

@@ -568,7 +560,6 @@ jobs:
568560
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
569561
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
570562
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
571-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
572563
ACCTEST_PACKAGES: |
573564
./internal/service/federateddatabaseinstance
574565
./internal/service/federatedquerylimit
@@ -598,7 +589,6 @@ jobs:
598589
MONGODB_ATLAS_PROJECT_OWNER_ID: ${{ inputs.mongodb_atlas_project_owner_id }}
599590
CA_CERT: ${{ secrets.ca_cert }}
600591
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
601-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
602592
ACCTEST_PACKAGES: |
603593
./internal/service/auditing
604594
./internal/service/backupcompliancepolicy
@@ -629,7 +619,6 @@ jobs:
629619
MONGODB_ATLAS_LDAP_PORT: ${{ secrets.mongodb_atlas_ldap_port }}
630620
MONGODB_ATLAS_LDAP_CA_CERTIFICATE: ${{ secrets.mongodb_atlas_ldap_ca_certificate }}
631621
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
632-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
633622
ACCTEST_PACKAGES: |
634623
./internal/service/ldapconfiguration
635624
./internal/service/ldapverify
@@ -669,7 +658,6 @@ jobs:
669658
AZURE_VNET_NAME: ${{ secrets.azure_vnet_name }}
670659
AZURE_VNET_NAME_UPDATED: ${{ secrets.azure_vnet_name_updated }}
671660
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
672-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
673661
ACCTEST_PACKAGES: |
674662
./internal/service/networkcontainer
675663
./internal/service/networkpeering
@@ -709,7 +697,6 @@ jobs:
709697
AWS_VPC_CIDR_BLOCK: ${{ vars.AWS_VPC_CIDR_BLOCK }}
710698
AWS_VPC_ID: ${{ vars.AWS_VPC_ID }}
711699
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
712-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
713700
ACCTEST_PACKAGES: |
714701
./internal/service/accesslistapikey
715702
./internal/service/project
@@ -739,7 +726,6 @@ jobs:
739726
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
740727
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
741728
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
742-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
743729
ACCTEST_PACKAGES: ./internal/service/pushbasedlogexport
744730
run: make testacc
745731

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

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

@@ -810,7 +794,6 @@ jobs:
810794
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
811795
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
812796
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
813-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
814797
ACCTEST_PACKAGES: |
815798
./internal/service/privatelinkendpointserverless
816799
./internal/service/privatelinkendpointserviceserverless
@@ -836,7 +819,6 @@ jobs:
836819
- name: Acceptance Tests
837820
env:
838821
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
839-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
840822
ACCTEST_PACKAGES: |
841823
./internal/service/streamconnection
842824
./internal/service/streaminstance
@@ -861,7 +843,6 @@ jobs:
861843
- name: Acceptance Tests
862844
env:
863845
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
864-
ACCTEST_REGEX_RUN: ${{ inputs.test_name }}
865846
ACCTEST_PACKAGES: |
866847
./internal/service/controlplaneipaddresses
867848
run: make testacc

GNUmakefile

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ else
66
ACCTEST_PACKAGES := "./..."
77
endif
88

9-
ifdef ACCTEST_REGEX_RUN
10-
# remove newlines and blanks coming from GH Actions
11-
ACCTEST_REGEX_RUN := $(strip $(subst $(newline),, $(ACCTEST_REGEX_RUN)))
12-
else
13-
ACCTEST_REGEX_RUN?=^TestAcc
14-
endif
9+
ACCTEST_REGEX_RUN?=^TestAcc
1510
ACCTEST_TIMEOUT?=300m
1611
PARALLEL_GO_TEST?=20
1712

0 commit comments

Comments
 (0)