Skip to content

Commit c0fa4fd

Browse files
test: Reduce instance size and use of provisioned disk iops for test that verifies transition for symmetric to asymmetric configuration (#2503)
1 parent 198f593 commit c0fa4fd

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

internal/service/advancedcluster/resource_advanced_cluster_test.go

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -600,16 +600,16 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedNewSchemaToAsymmetricAd
600600
CheckDestroy: acc.CheckDestroyCluster,
601601
Steps: []resource.TestStep{
602602
{
603-
Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M30", "M30", 2000, 2000, false),
604-
Check: checkShardedNewSchema(50, "M30", "M30", "2000", "2000", false, false),
603+
Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M10", "M10", nil, nil, false),
604+
Check: checkShardedNewSchema(50, "M10", "M10", nil, nil, false, false),
605605
},
606606
{
607-
Config: configShardedNewSchema(orgID, projectName, clusterName, 55, "M30", "M40", 2000, 2500, true),
608-
Check: checkShardedNewSchema(55, "M30", "M40", "2000", "2500", true, true),
607+
Config: configShardedNewSchema(orgID, projectName, clusterName, 55, "M10", "M20", nil, nil, true), // add middle replication spec and transition to asymmetric
608+
Check: checkShardedNewSchema(55, "M10", "M20", nil, nil, true, true),
609609
},
610610
{
611-
Config: configShardedNewSchema(orgID, projectName, clusterName, 55, "M30", "M40", 2000, 2500, false), // removes middle replication spec
612-
Check: checkShardedNewSchema(55, "M30", "M40", "2000", "2500", true, false),
611+
Config: configShardedNewSchema(orgID, projectName, clusterName, 55, "M10", "M20", nil, nil, false), // removes middle replication spec
612+
Check: checkShardedNewSchema(55, "M10", "M20", nil, nil, true, false),
613613
},
614614
},
615615
})
@@ -633,8 +633,8 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase {
633633
CheckDestroy: acc.CheckDestroyCluster,
634634
Steps: []resource.TestStep{
635635
{
636-
Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M30", "M40", 2000, 2500, false),
637-
Check: checkShardedNewSchema(50, "M30", "M40", "2000", "2500", true, false),
636+
Config: configShardedNewSchema(orgID, projectName, clusterName, 50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), false),
637+
Check: checkShardedNewSchema(50, "M30", "M40", admin.PtrInt(2000), admin.PtrInt(2500), true, false),
638638
},
639639
},
640640
}
@@ -1482,7 +1482,7 @@ func checkShardedOldSchemaDiskSizeGBElectableLevel(diskSizeGB int) resource.Test
14821482
})
14831483
}
14841484

1485-
func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIops, lastDiskIops int, includeMiddleSpec bool) string {
1485+
func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIOPS, lastDiskIOPS *int, includeMiddleSpec bool) string {
14861486
var thirdReplicationSpec string
14871487
if includeMiddleSpec {
14881488
thirdReplicationSpec = fmt.Sprintf(`
@@ -1505,6 +1505,20 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
15051505
}
15061506
`, firstInstanceSize, diskSizeGB)
15071507
}
1508+
var firstDiskIOPSAttrs string
1509+
if firstDiskIOPS != nil {
1510+
firstDiskIOPSAttrs = fmt.Sprintf(`
1511+
disk_iops = %d
1512+
ebs_volume_type = "PROVISIONED"
1513+
`, *firstDiskIOPS)
1514+
}
1515+
var lastDiskIOPSAttrs string
1516+
if lastDiskIOPS != nil {
1517+
lastDiskIOPSAttrs = fmt.Sprintf(`
1518+
disk_iops = %d
1519+
ebs_volume_type = "PROVISIONED"
1520+
`, *lastDiskIOPS)
1521+
}
15081522
return fmt.Sprintf(`
15091523
resource "mongodbatlas_project" "cluster_project" {
15101524
org_id = %[1]q
@@ -1521,10 +1535,9 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
15211535
region_configs {
15221536
electable_specs {
15231537
instance_size = %[4]q
1524-
disk_iops = %[6]d
1525-
ebs_volume_type = "PROVISIONED"
15261538
node_count = 3
15271539
disk_size_gb = %[9]d
1540+
%[6]s
15281541
}
15291542
analytics_specs {
15301543
instance_size = %[4]q
@@ -1543,10 +1556,9 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
15431556
region_configs {
15441557
electable_specs {
15451558
instance_size = %[5]q
1546-
disk_iops = %[7]d
1547-
ebs_volume_type = "PROVISIONED"
15481559
node_count = 3
15491560
disk_size_gb = %[9]d
1561+
%[7]s
15501562
}
15511563
analytics_specs {
15521564
instance_size = %[5]q
@@ -1570,10 +1582,10 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
15701582
project_id = mongodbatlas_advanced_cluster.test.project_id
15711583
use_replication_spec_per_shard = true
15721584
}
1573-
`, orgID, projectName, name, firstInstanceSize, lastInstanceSize, firstDiskIops, lastDiskIops, thirdReplicationSpec, diskSizeGB)
1585+
`, orgID, projectName, name, firstInstanceSize, lastInstanceSize, firstDiskIOPSAttrs, lastDiskIOPSAttrs, thirdReplicationSpec, diskSizeGB)
15741586
}
15751587

1576-
func checkShardedNewSchema(diskSizeGB int, firstInstanceSize, lastInstanceSize, firstDiskIops, lastDiskIops string, isAsymmetricCluster, includeMiddleSpec bool) resource.TestCheckFunc {
1588+
func checkShardedNewSchema(diskSizeGB int, firstInstanceSize, lastInstanceSize string, firstDiskIops, lastDiskIops *int, isAsymmetricCluster, includeMiddleSpec bool) resource.TestCheckFunc {
15771589
amtOfReplicationSpecs := 2
15781590
if includeMiddleSpec {
15791591
amtOfReplicationSpecs = 3
@@ -1593,8 +1605,12 @@ func checkShardedNewSchema(diskSizeGB int, firstInstanceSize, lastInstanceSize,
15931605
fmt.Sprintf("replication_specs.%d.region_configs.0.electable_specs.0.disk_size_gb", lastSpecIndex): fmt.Sprintf("%d", diskSizeGB),
15941606
"replication_specs.0.region_configs.0.analytics_specs.0.disk_size_gb": fmt.Sprintf("%d", diskSizeGB),
15951607
fmt.Sprintf("replication_specs.%d.region_configs.0.analytics_specs.0.disk_size_gb", lastSpecIndex): fmt.Sprintf("%d", diskSizeGB),
1596-
"replication_specs.0.region_configs.0.electable_specs.0.disk_iops": firstDiskIops,
1597-
fmt.Sprintf("replication_specs.%d.region_configs.0.electable_specs.0.disk_iops", lastSpecIndex): lastDiskIops,
1608+
}
1609+
if firstDiskIops != nil {
1610+
clusterChecks["replication_specs.0.region_configs.0.electable_specs.0.disk_iops"] = fmt.Sprintf("%d", *firstDiskIops)
1611+
}
1612+
if lastDiskIops != nil {
1613+
clusterChecks[fmt.Sprintf("replication_specs.%d.region_configs.0.electable_specs.0.disk_iops", lastSpecIndex)] = fmt.Sprintf("%d", *lastDiskIops)
15981614
}
15991615

16001616
// plural data source checks

0 commit comments

Comments
 (0)