Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) {
Steps: []resource.TestStep{
{
ExternalProviders: acc.ExternalProviders(versionBeforeISSRelease),
Config: configReplicaSetAWSProvider(t, false, ReplicaSetAWSConfig{
Config: configAWSProvider(t, false, ReplicaSetAWSConfig{
ProjectID: projectID,
ClusterName: clusterName,
ClusterType: "REPLICASET",
DiskSizeGB: 60,
NodeCountElectable: 3,
WithAnalyticsSpecs: true,
Expand All @@ -63,9 +64,10 @@ func TestMigAdvancedCluster_replicaSetAWSProviderUpdate(t *testing.T) {
},
{
ProtoV6ProviderFactories: acc.TestAccProviderV6Factories,
Config: configReplicaSetAWSProvider(t, false, ReplicaSetAWSConfig{
Config: configAWSProvider(t, false, ReplicaSetAWSConfig{
ProjectID: projectID,
ClusterName: clusterName,
ClusterType: "REPLICASET",
DiskSizeGB: 60,
NodeCountElectable: 5,
WithAnalyticsSpecs: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,25 +203,38 @@ func replicaSetAWSProviderTestCase(t *testing.T, isAcc bool) resource.TestCase {
CheckDestroy: acc.CheckDestroyCluster,
Steps: []resource.TestStep{
{
Config: configReplicaSetAWSProvider(t, isAcc, ReplicaSetAWSConfig{
Config: configAWSProvider(t, isAcc, ReplicaSetAWSConfig{
ProjectID: projectID,
ClusterName: clusterName,
ClusterType: "REPLICASET",
DiskSizeGB: 60,
NodeCountElectable: 3,
WithAnalyticsSpecs: true,
}),
Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 60, 3, true, true),
},
{
Config: configReplicaSetAWSProvider(t, isAcc, ReplicaSetAWSConfig{
Config: configAWSProvider(t, isAcc, ReplicaSetAWSConfig{
ProjectID: projectID,
ClusterName: clusterName,
ClusterType: "REPLICASET",
DiskSizeGB: 50,
NodeCountElectable: 5,
WithAnalyticsSpecs: false, // removed as part of other updates, computed value is expected to be the same
}),
Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 50, 5, true, true),
},
{ // testing transition from replica set to sharded cluster
Config: configAWSProvider(t, isAcc, ReplicaSetAWSConfig{
ProjectID: projectID,
ClusterName: clusterName,
ClusterType: "SHARDED",
DiskSizeGB: 50,
NodeCountElectable: 5,
WithAnalyticsSpecs: false,
}),
Check: checkReplicaSetAWSProvider(isAcc, projectID, clusterName, 50, 5, true, true),
},
acc.TestStepImportCluster(resourceName, "replication_specs", "retain_backups_enabled"),
},
}
Expand Down Expand Up @@ -1772,12 +1785,13 @@ func checkKeyValueBlocksPreviewProviderV2(isAcc, includeDataSources bool, blockN
type ReplicaSetAWSConfig struct {
ProjectID string
ClusterName string
ClusterType string
DiskSizeGB int
NodeCountElectable int
WithAnalyticsSpecs bool
}

func configReplicaSetAWSProvider(t *testing.T, isAcc bool, configInfo ReplicaSetAWSConfig) string {
func configAWSProvider(t *testing.T, isAcc bool, configInfo ReplicaSetAWSConfig) string {
t.Helper()
analyticsSpecs := ""
if configInfo.WithAnalyticsSpecs {
Expand All @@ -1791,24 +1805,24 @@ func configReplicaSetAWSProvider(t *testing.T, isAcc bool, configInfo ReplicaSet
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
}
%[5]s
%[6]s
provider_name = "AWS"
priority = 7
region_name = "US_WEST_2"
}
}
}
`, configInfo.ProjectID, configInfo.ClusterName, configInfo.DiskSizeGB, configInfo.NodeCountElectable, analyticsSpecs)) + dataSourcesTFOldSchema
`, configInfo.ProjectID, configInfo.ClusterName, configInfo.ClusterType, configInfo.DiskSizeGB, configInfo.NodeCountElectable, analyticsSpecs)) + 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 @@ -19,6 +19,7 @@ var (
"replication_specs": {},
"mongo_db_major_version": {"mongo_db_version"},
"tls_cipher_config_mode": {"custom_openssl_cipher_config_tls12"},
"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
Loading