Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Supports running advanced_cluster_tpf resource with tests in advancedcluster package #2786

Merged
merged 7 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/acceptance-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ jobs:
with:
filters: |
advanced_cluster:
- 'internal/service/advancedcluster/*.go'
- 'internal/service/advancedcluster/!(*_test).go'
EspenAlbert marked this conversation as resolved.
Show resolved Hide resolved
advanced_cluster_tpf:
- 'internal/service/advancedclustertpf/*.go'
- 'internal/service/advancedcluster/*_test.go'
assume_role:
- 'internal/provider/*.go'
backup:
Expand Down Expand Up @@ -361,7 +362,10 @@ jobs:
- name: Acceptance Tests
env:
MONGODB_ATLAS_LAST_VERSION: ${{ needs.get-provider-version.outputs.provider_version }}
ACCTEST_PACKAGES: ./internal/service/advancedclustertpf
ACCTEST_PACKAGES: |
./internal/service/advancedcluster
./internal/service/advancedclustertpf
MONGODB_ATLAS_TPF_ADV_CLUSTER_TESTS: "true"
EspenAlbert marked this conversation as resolved.
Show resolved Hide resolved
run: make testacc

assume_role:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: mig.PreCheckBasicSleep(t),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, mig.PreCheckBasicSleep(t)),
EspenAlbert marked this conversation as resolved.
Show resolved Hide resolved
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
{
Expand All @@ -72,7 +72,7 @@ func TestMigAdvancedCluster_geoShardedOldSchemaUpdate(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { mig.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { mig.PreCheckBasic(t) }),
EspenAlbert marked this conversation as resolved.
Show resolved Hide resolved
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
{
Expand All @@ -97,7 +97,7 @@ func TestMigAdvancedCluster_shardedMigrationFromOldToNewSchema(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { mig.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { mig.PreCheckBasic(t) }),
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestMigAdvancedCluster_geoShardedMigrationFromOldToNewSchema(t *testing.T)
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { mig.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { mig.PreCheckBasic(t) }),
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
{
Expand Down Expand Up @@ -192,7 +192,7 @@ func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: mig.PreCheckBasicSleep(t),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, mig.PreCheckBasicSleep(t)),
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

func TestMigAdvancedCluster_empty_advancedConfig(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t, func() {})()
acc.SkipInUnitTest(t) // needed because TF test infra is not used
v0State := map[string]any{
"project_id": "test-id",
Expand Down Expand Up @@ -63,6 +64,7 @@ func TestMigAdvancedCluster_empty_advancedConfig(t *testing.T) {
}

func TestMigAdvancedCluster_v0StateUpgrade_ReplicationSpecs(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t, func() {})()
acc.SkipInUnitTest(t) // needed because TF test infra is not used
v0State := map[string]any{
"project_id": "test-id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) {
clusterNameUpdated = acc.RandomClusterName()
)
resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -69,7 +69,7 @@ func replicaSetAWSProviderTestCase(t *testing.T) resource.TestCase {
)

return resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -105,7 +105,7 @@ func replicaSetMultiCloudTestCase(t *testing.T) resource.TestCase {
)

return resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -142,7 +142,7 @@ func singleShardedMultiCloudTestCase(t *testing.T) resource.TestCase {
)

return resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -174,7 +174,7 @@ func TestAccClusterAdvancedCluster_unpausedToPaused(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -209,7 +209,7 @@ func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -271,7 +271,7 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestAccClusterAdvancedCluster_defaultWrite(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -348,7 +348,7 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling(t *testing.
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -391,7 +391,7 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAnalyticsAutoScaling(t
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestAccClusterAdvancedClusterConfig_singleShardedTransitionToOldSchemaExpec
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -449,7 +449,7 @@ func TestAccClusterAdvancedCluster_withTags(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -477,7 +477,7 @@ func TestAccClusterAdvancedClusterConfig_selfManagedSharding(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -504,7 +504,7 @@ func TestAccClusterAdvancedClusterConfig_selfManagedShardingIncorrectType(t *tes
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: acc.PreCheckBasicSleep(t, nil, projectID, clusterName),
PreCheck: acc.SkipIfTPFAdvancedCluster(t, acc.PreCheckBasicSleep(t, nil, projectID, clusterName)),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -524,7 +524,7 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T)
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -553,7 +553,7 @@ func symmetricGeoShardedOldSchemaTestCase(t *testing.T) resource.TestCase {
)

return resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -577,7 +577,7 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtEl
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -601,7 +601,7 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedNewSchemaToAsymmetricAd
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -634,7 +634,7 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase {
)

return resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -654,7 +654,7 @@ func TestAccClusterAdvancedClusterConfig_asymmetricGeoShardedNewSchemaAddingRemo
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -682,7 +682,7 @@ func TestAccClusterAdvancedClusterConfig_shardedTransitionFromOldToNewSchema(t *
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -706,7 +706,7 @@ func TestAccClusterAdvancedClusterConfig_geoShardedTransitionFromOldToNewSchema(
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand All @@ -730,7 +730,7 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogData(t *t
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -762,7 +762,7 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSc
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -791,7 +791,7 @@ func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down Expand Up @@ -820,7 +820,7 @@ func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) {
)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acc.PreCheckBasic(t) },
PreCheck: acc.SkipIfTPFAdvancedCluster(t, func() { acc.PreCheckBasic(t) }),
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
Expand Down
10 changes: 10 additions & 0 deletions internal/testutil/acc/pre_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ func PreCheckBasic(tb testing.TB) {
}
}

func SkipIfTPFAdvancedCluster(tb testing.TB, existingPreCheck func()) func() {
tb.Helper()
return func() {
if os.Getenv("MONGODB_ATLAS_TPF_ADV_CLUSTER_TESTS") == "true" {
tb.Skip("Skipping TPF Advanced Cluster tests")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: My understanding is not that we are skipping TPF advanced cluster tests but that we don't run tests on TPF advanced clusters at all. Is this a correct assumption? If so, I think a message more along the lines of "Skipping tests as resource is TPF Advanced Cluster" would make this more explicit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! Updated in 053deb3, WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please Tag/DM if you want an update otherwise I might not see it 😅

}
existingPreCheck()
}
}

// PreCheckBasicSleep is a helper function to call SerialSleep, see its help for more info.
// Some examples of use are when the test is calling ProjectIDExecution or GetClusterInfo to create clusters.
func PreCheckBasicSleep(tb testing.TB, clusterInfo *ClusterInfo, projectID, clusterName string) func() {
Expand Down