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 all 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' # matches any adv_cluster file change except test files
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
MONGODB_ATLAS_TPF_ADV_CLUSTER_TESTS: "true"
ACCTEST_PACKAGES: |
./internal/service/advancedcluster
./internal/service/advancedclustertpf
run: make testacc

assume_role:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,37 @@ import (
const versionBeforeISSRelease = "1.17.6"

func TestMigAdvancedCluster_replicaSetAWSProvider(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
testCase := replicaSetAWSProviderTestCase(t)
mig.CreateAndRunTest(t, &testCase)
}

func TestMigAdvancedCluster_replicaSetMultiCloud(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
testCase := replicaSetMultiCloudTestCase(t)
mig.CreateAndRunTest(t, &testCase)
}

func TestMigAdvancedCluster_singleShardedMultiCloud(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
testCase := singleShardedMultiCloudTestCase(t)
mig.CreateAndRunTest(t, &testCase)
}

func TestMigAdvancedCluster_symmetricGeoShardedOldSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
testCase := symmetricGeoShardedOldSchemaTestCase(t)
mig.CreateAndRunTest(t, &testCase)
}

func TestMigAdvancedCluster_asymmetricShardedNewSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
testCase := asymmetricShardedNewSchemaTestCase(t)
mig.CreateAndRunTest(t, &testCase)
}

func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand All @@ -65,6 +71,7 @@ func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) {
}

func TestMigAdvancedCluster_geoShardedOldSchemaUpdate(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region
Expand All @@ -90,6 +97,7 @@ func TestMigAdvancedCluster_geoShardedOldSchemaUpdate(t *testing.T) {
}

func TestMigAdvancedCluster_shardedMigrationFromOldToNewSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand Down Expand Up @@ -120,6 +128,7 @@ func TestMigAdvancedCluster_shardedMigrationFromOldToNewSchema(t *testing.T) {
}

func TestMigAdvancedCluster_geoShardedMigrationFromOldToNewSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand Down Expand Up @@ -150,6 +159,7 @@ func TestMigAdvancedCluster_geoShardedMigrationFromOldToNewSchema(t *testing.T)
}

func TestMigAdvancedCluster_partialAdvancedConf(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
mig.SkipIfVersionBelow(t, "1.19.0") // version where change_stream_options_pre_and_post_images_expire_after_seconds was introduced
var (
projectID = acc.ProjectIDExecution(t)
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)
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)
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 @@ -30,6 +30,7 @@ var (
)

func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand Down Expand Up @@ -59,6 +60,7 @@ func TestAccClusterAdvancedCluster_basicTenant(t *testing.T) {
}

func TestAccClusterAdvancedCluster_replicaSetAWSProvider(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
resource.ParallelTest(t, replicaSetAWSProviderTestCase(t))
}
func replicaSetAWSProviderTestCase(t *testing.T) resource.TestCase {
Expand Down Expand Up @@ -93,6 +95,7 @@ func replicaSetAWSProviderTestCase(t *testing.T) resource.TestCase {
}

func TestAccClusterAdvancedCluster_replicaSetMultiCloud(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
resource.ParallelTest(t, replicaSetMultiCloudTestCase(t))
}
func replicaSetMultiCloudTestCase(t *testing.T) resource.TestCase {
Expand Down Expand Up @@ -129,6 +132,7 @@ func replicaSetMultiCloudTestCase(t *testing.T) resource.TestCase {
}

func TestAccClusterAdvancedCluster_singleShardedMultiCloud(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
resource.ParallelTest(t, singleShardedMultiCloudTestCase(t))
}

Expand Down Expand Up @@ -166,6 +170,7 @@ func singleShardedMultiCloudTestCase(t *testing.T) resource.TestCase {
}

func TestAccClusterAdvancedCluster_unpausedToPaused(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand Down Expand Up @@ -202,6 +207,7 @@ func TestAccClusterAdvancedCluster_unpausedToPaused(t *testing.T) {
}

func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand Down Expand Up @@ -240,6 +246,7 @@ func TestAccClusterAdvancedCluster_pausedToUnpaused(t *testing.T) {
}

func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand Down Expand Up @@ -288,6 +295,7 @@ func TestAccClusterAdvancedCluster_advancedConfig(t *testing.T) {
}

func TestAccClusterAdvancedCluster_defaultWrite(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand Down Expand Up @@ -333,6 +341,7 @@ func TestAccClusterAdvancedCluster_defaultWrite(t *testing.T) {
}

func TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand Down Expand Up @@ -376,6 +385,7 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAutoScaling(t *testing.
}

func TestAccClusterAdvancedClusterConfig_replicationSpecsAnalyticsAutoScaling(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand Down Expand Up @@ -418,6 +428,7 @@ func TestAccClusterAdvancedClusterConfig_replicationSpecsAnalyticsAutoScaling(t
}

func TestAccClusterAdvancedClusterConfig_singleShardedTransitionToOldSchemaExpectsError(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region
Expand All @@ -442,6 +453,7 @@ func TestAccClusterAdvancedClusterConfig_singleShardedTransitionToOldSchemaExpec
}

func TestAccClusterAdvancedCluster_withTags(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName() // No ProjectIDExecution to check correctly plural data source in the different test steps
Expand Down Expand Up @@ -470,6 +482,7 @@ func TestAccClusterAdvancedCluster_withTags(t *testing.T) {
}

func TestAccClusterAdvancedClusterConfig_selfManagedSharding(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region
Expand Down Expand Up @@ -498,6 +511,7 @@ func TestAccClusterAdvancedClusterConfig_selfManagedSharding(t *testing.T) {
}

func TestAccClusterAdvancedClusterConfig_selfManagedShardingIncorrectType(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
projectID = acc.ProjectIDExecution(t)
clusterName = acc.RandomClusterName()
Expand All @@ -517,6 +531,7 @@ func TestAccClusterAdvancedClusterConfig_selfManagedShardingIncorrectType(t *tes
}

func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region
Expand All @@ -541,6 +556,7 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchema(t *testing.T)
}

func TestAccClusterAdvancedClusterConfig_symmetricGeoShardedOldSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
resource.ParallelTest(t, symmetricGeoShardedOldSchemaTestCase(t))
}

Expand Down Expand Up @@ -570,6 +586,7 @@ func symmetricGeoShardedOldSchemaTestCase(t *testing.T) resource.TestCase {
}

func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtElectableLevel(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand All @@ -594,6 +611,7 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedOldSchemaDiskSizeGBAtEl
}

func TestAccClusterAdvancedClusterConfig_symmetricShardedNewSchemaToAsymmetricAddingRemovingShard(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand Down Expand Up @@ -622,6 +640,7 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedNewSchemaToAsymmetricAd
}

func TestAccClusterAdvancedClusterConfig_asymmetricShardedNewSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
resource.ParallelTest(t, asymmetricShardedNewSchemaTestCase(t))
}

Expand All @@ -647,6 +666,7 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase {
}

func TestAccClusterAdvancedClusterConfig_asymmetricGeoShardedNewSchemaAddingRemovingShard(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand Down Expand Up @@ -675,6 +695,7 @@ func TestAccClusterAdvancedClusterConfig_asymmetricGeoShardedNewSchemaAddingRemo
}

func TestAccClusterAdvancedClusterConfig_shardedTransitionFromOldToNewSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand All @@ -699,6 +720,7 @@ func TestAccClusterAdvancedClusterConfig_shardedTransitionFromOldToNewSchema(t *
}

func TestAccClusterAdvancedClusterConfig_geoShardedTransitionFromOldToNewSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand All @@ -723,6 +745,7 @@ func TestAccClusterAdvancedClusterConfig_geoShardedTransitionFromOldToNewSchema(
}

func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogData(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand Down Expand Up @@ -755,6 +778,7 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogData(t *t
}

func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName()
Expand Down Expand Up @@ -784,6 +808,7 @@ func TestAccAdvancedCluster_replicaSetScalingStrategyAndRedactClientLogDataOldSc

// TestAccClusterAdvancedCluster_priorityOldSchema will be able to be simplied or deleted in CLOUDP-275825
func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region
Expand Down Expand Up @@ -813,6 +838,7 @@ func TestAccClusterAdvancedCluster_priorityOldSchema(t *testing.T) {

// TestAccClusterAdvancedCluster_priorityNewSchema will be able to be simplied or deleted in CLOUDP-275825
func TestAccClusterAdvancedCluster_priorityNewSchema(t *testing.T) {
acc.SkipIfTPFAdvancedCluster(t)
var (
orgID = os.Getenv("MONGODB_ATLAS_ORG_ID")
projectName = acc.RandomProjectName() // No ProjectIDExecution to avoid cross-region limits because multi-region
Expand Down
7 changes: 7 additions & 0 deletions internal/testutil/acc/pre_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ func PreCheckBasic(tb testing.TB) {
}
}

func SkipIfTPFAdvancedCluster(tb testing.TB) {
tb.Helper()
if os.Getenv("MONGODB_ATLAS_TPF_ADV_CLUSTER_TESTS") == "true" {
tb.Skip("Skipping tests as resource is TPF Advanced Cluster and implementation is pending")
}
}

// 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