Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) {
Steps: []resource.TestStep{
{
ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease),
Config: configReplicaSetAWSProvider(t, false, projectID, clusterName, 60, 3),
Config: configAWSProvider(t, false, projectID, clusterName, "REPLICASET", 60, 3),
Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 3, false, false),
},
{
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Config: configReplicaSetAWSProvider(t, false, projectID, clusterName, 60, 5),
Config: configAWSProvider(t, false, projectID, clusterName, "REPLICASET", 60, 5),
Check: checkReplicaSetAWSProvider(false, projectID, clusterName, 60, 5, true, true),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,15 @@ func replicaSetAWSProviderTestCase(t *testing.T, isAcc bool) resource.TestCase {
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
{
Config: configReplicaSetAWSProvider(t, isAcc, projectID, clusterName, 60, 3),
Config: configAWSProvider(t, isAcc, projectID, clusterName, "REPLICASET", 60, 3),
Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 60, 3, true, true),
},
{
Config: configReplicaSetAWSProvider(t, isAcc, projectID, clusterName, 50, 5),
Config: configAWSProvider(t, isAcc, projectID, clusterName, "REPLICASET", 50, 5),
Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 50, 5, true, true),
},
{ // testing transition from replica set to sharded cluster
Config: configAWSProvider(t, isAcc, projectID, clusterName, "SHARDED", 50, 5),
Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 50, 5, true, true),
},
acc.TestStepImportCluster(resourceName, "replication_specs", "retain_backups_enabled"),
Expand Down Expand Up @@ -1603,21 +1607,21 @@ func checkKeyValueBlocksPreviewProviderV2(isAcc, includeDataSources bool, blockN
return resource.ComposeAggregateTestCheckFunc(checks...)
}

func configReplicaSetAWSProvider(t *testing.T, isAcc bool, projectID, name string, diskSizeGB, nodeCountElectable int) string {
func configAWSProvider(t *testing.T, isAcc bool, projectID, name, clusterType string, diskSizeGB, nodeCountElectable int) string {
t.Helper()
return acc.ConvertAdvancedClusterToPreviewProviderV2(t, isAcc, fmt.Sprintf(`
resource "mongodbatlas_advanced_cluster" "test" {
project_id = %[1]q
name = %[2]q
cluster_type = "REPLICASET"
cluster_type = %[3]q
retain_backups_enabled = "true"
disk_size_gb = %[3]d
disk_size_gb = %[4]d

replication_specs {
region_configs {
electable_specs {
instance_size = "M10"
node_count = %[4]d
node_count = %[5]d
}
analytics_specs {
instance_size = "M10"
Expand All @@ -1629,7 +1633,7 @@ func configReplicaSetAWSProvider(t *testing.T, isAcc bool, projectID, name strin
}
}
}
`, projectID, name, diskSizeGB, nodeCountElectable)) + dataSourcesTFOldSchema
`, projectID, name, clusterType, diskSizeGB, nodeCountElectable)) + dataSourcesTFOldSchema
}

func checkReplicaSetAWSProvider(isAcc bool, projectID, name string, diskSizeGB, nodeCountElectable int, checkDiskSizeGBInnerLevel, checkExternalID bool) resource.TestCheckFunc {
Expand Down
1 change: 1 addition & 0 deletions internal/service/advancedclustertpf/plan_modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var (
"disk_size_gb": {}, // disk_size_gb can be change at any level/spec
"replication_specs": {},
"mongo_db_major_version": {"mongo_db_version"},
"cluster_type": {"config_server_management_mode", "config_server_type"}, // computed values of config server change when REPLICA_SET changes to SHARDED
}
attributeReplicationSpecChangeMapping = map[string][]string{
// All these fields can exist in specs that are computed, therefore, it is not safe to use them when they have changed.
Expand Down