4
4
"context"
5
5
"fmt"
6
6
"log"
7
+ "net/http"
7
8
"os"
8
9
"testing"
9
10
@@ -843,13 +844,15 @@ func TestAccResourceMongoDBAtlasCluster_tenant(t *testing.T) {
843
844
name = fmt .Sprintf ("test-acc-%s" , acctest .RandString (10 ))
844
845
)
845
846
847
+ dbMajorVersion := testAccGetMongoDBAtlasMajorVersion ()
848
+
846
849
resource .ParallelTest (t , resource.TestCase {
847
850
PreCheck : func () { testAccPreCheck (t ) },
848
851
Providers : testAccProviders ,
849
852
CheckDestroy : testAccCheckMongoDBAtlasClusterDestroy ,
850
853
Steps : []resource.TestStep {
851
854
{
852
- Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M2" , "2" ),
855
+ Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M2" , "2" , dbMajorVersion ),
853
856
Check : resource .ComposeTestCheckFunc (
854
857
testAccCheckMongoDBAtlasClusterExists (resourceName , & cluster ),
855
858
testAccCheckMongoDBAtlasClusterAttributes (& cluster , name ),
@@ -879,14 +882,15 @@ func TestAccResourceMongoDBAtlasCluster_tenant_m5(t *testing.T) {
879
882
resourceName := "mongodbatlas_cluster.tenant"
880
883
projectID := os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
881
884
name := fmt .Sprintf ("test-acc-%s" , acctest .RandString (10 ))
885
+ dbMajorVersion := testAccGetMongoDBAtlasMajorVersion ()
882
886
883
887
resource .ParallelTest (t , resource.TestCase {
884
888
PreCheck : func () { testAccPreCheck (t ) },
885
889
Providers : testAccProviders ,
886
890
CheckDestroy : testAccCheckMongoDBAtlasClusterDestroy ,
887
891
Steps : []resource.TestStep {
888
892
{
889
- Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M5" , "5" ),
893
+ Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M5" , "5" , dbMajorVersion ),
890
894
Check : resource .ComposeTestCheckFunc (
891
895
testAccCheckMongoDBAtlasClusterExists (resourceName , & cluster ),
892
896
testAccCheckMongoDBAtlasClusterAttributes (& cluster , name ),
@@ -911,6 +915,13 @@ func testAccCheckMongoDBAtlasClusterImportStateIDFunc(resourceName string) resou
911
915
}
912
916
}
913
917
918
+ func testAccGetMongoDBAtlasMajorVersion () string {
919
+ conn , _ := matlas .New (http .DefaultClient , matlas .SetBaseURL (matlas .CloudURL ))
920
+ majorVersion , _ , _ := conn .DefaultMongoDBMajorVersion .Get (context .Background ())
921
+
922
+ return majorVersion
923
+ }
924
+
914
925
func testAccCheckMongoDBAtlasClusterExists (resourceName string , cluster * matlas.Cluster ) resource.TestCheckFunc {
915
926
return func (s * terraform.State ) error {
916
927
conn := testAccProvider .Meta ().(* matlas.Client )
@@ -982,7 +993,6 @@ func testAccMongoDBAtlasClusterConfigAWS(projectID, name string, backupEnabled,
982
993
// Provider Settings "block"
983
994
provider_name = "AWS"
984
995
provider_disk_iops = 300
985
- provider_encrypt_ebs_volume = false
986
996
provider_instance_size_name = "M30"
987
997
provider_region_name = "EU_CENTRAL_1"
988
998
}
@@ -1216,7 +1226,7 @@ func testAccMongoDBAtlasClusterConfigGlobal(projectID, name, backupEnabled strin
1216
1226
` , projectID , name , backupEnabled )
1217
1227
}
1218
1228
1219
- func testAccMongoDBAtlasClusterConfigTenant (projectID , name , instanceSize , diskSize string ) string {
1229
+ func testAccMongoDBAtlasClusterConfigTenant (projectID , name , instanceSize , diskSize , majorDBVersion string ) string {
1220
1230
return fmt .Sprintf (`
1221
1231
resource "mongodbatlas_cluster" "tenant" {
1222
1232
project_id = "%s"
@@ -1230,10 +1240,10 @@ func testAccMongoDBAtlasClusterConfigTenant(projectID, name, instanceSize, diskS
1230
1240
1231
1241
provider_instance_size_name = "%s"
1232
1242
//These must be the following values
1233
- mongo_db_major_version = "4.2 "
1243
+ mongo_db_major_version = "%s "
1234
1244
auto_scaling_disk_gb_enabled = false
1235
1245
}
1236
- ` , projectID , name , diskSize , instanceSize )
1246
+ ` , projectID , name , diskSize , instanceSize , majorDBVersion )
1237
1247
}
1238
1248
1239
1249
func testAccMongoDBAtlasClusterConfigTenantUpdated (projectID , name string ) string {
0 commit comments