@@ -600,16 +600,16 @@ func TestAccClusterAdvancedClusterConfig_symmetricShardedNewSchemaToAsymmetricAd
600
600
CheckDestroy : acc .CheckDestroyCluster ,
601
601
Steps : []resource.TestStep {
602
602
{
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 ),
605
605
},
606
606
{
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 ),
609
609
},
610
610
{
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 ),
613
613
},
614
614
},
615
615
})
@@ -633,8 +633,8 @@ func asymmetricShardedNewSchemaTestCase(t *testing.T) resource.TestCase {
633
633
CheckDestroy : acc .CheckDestroyCluster ,
634
634
Steps : []resource.TestStep {
635
635
{
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 ),
638
638
},
639
639
},
640
640
}
@@ -1482,7 +1482,7 @@ func checkShardedOldSchemaDiskSizeGBElectableLevel(diskSizeGB int) resource.Test
1482
1482
})
1483
1483
}
1484
1484
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 {
1486
1486
var thirdReplicationSpec string
1487
1487
if includeMiddleSpec {
1488
1488
thirdReplicationSpec = fmt .Sprintf (`
@@ -1505,6 +1505,20 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
1505
1505
}
1506
1506
` , firstInstanceSize , diskSizeGB )
1507
1507
}
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
+ }
1508
1522
return fmt .Sprintf (`
1509
1523
resource "mongodbatlas_project" "cluster_project" {
1510
1524
org_id = %[1]q
@@ -1521,10 +1535,9 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
1521
1535
region_configs {
1522
1536
electable_specs {
1523
1537
instance_size = %[4]q
1524
- disk_iops = %[6]d
1525
- ebs_volume_type = "PROVISIONED"
1526
1538
node_count = 3
1527
1539
disk_size_gb = %[9]d
1540
+ %[6]s
1528
1541
}
1529
1542
analytics_specs {
1530
1543
instance_size = %[4]q
@@ -1543,10 +1556,9 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
1543
1556
region_configs {
1544
1557
electable_specs {
1545
1558
instance_size = %[5]q
1546
- disk_iops = %[7]d
1547
- ebs_volume_type = "PROVISIONED"
1548
1559
node_count = 3
1549
1560
disk_size_gb = %[9]d
1561
+ %[7]s
1550
1562
}
1551
1563
analytics_specs {
1552
1564
instance_size = %[5]q
@@ -1570,10 +1582,10 @@ func configShardedNewSchema(orgID, projectName, name string, diskSizeGB int, fir
1570
1582
project_id = mongodbatlas_advanced_cluster.test.project_id
1571
1583
use_replication_spec_per_shard = true
1572
1584
}
1573
- ` , orgID , projectName , name , firstInstanceSize , lastInstanceSize , firstDiskIops , lastDiskIops , thirdReplicationSpec , diskSizeGB )
1585
+ ` , orgID , projectName , name , firstInstanceSize , lastInstanceSize , firstDiskIOPSAttrs , lastDiskIOPSAttrs , thirdReplicationSpec , diskSizeGB )
1574
1586
}
1575
1587
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 {
1577
1589
amtOfReplicationSpecs := 2
1578
1590
if includeMiddleSpec {
1579
1591
amtOfReplicationSpecs = 3
@@ -1593,8 +1605,12 @@ func checkShardedNewSchema(diskSizeGB int, firstInstanceSize, lastInstanceSize,
1593
1605
fmt .Sprintf ("replication_specs.%d.region_configs.0.electable_specs.0.disk_size_gb" , lastSpecIndex ): fmt .Sprintf ("%d" , diskSizeGB ),
1594
1606
"replication_specs.0.region_configs.0.analytics_specs.0.disk_size_gb" : fmt .Sprintf ("%d" , diskSizeGB ),
1595
1607
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 )
1598
1614
}
1599
1615
1600
1616
// plural data source checks
0 commit comments