44 "context"
55 "fmt"
66 "log"
7+ "net/http"
78 "os"
89 "testing"
910
@@ -843,13 +844,15 @@ func TestAccResourceMongoDBAtlasCluster_tenant(t *testing.T) {
843844 name = fmt .Sprintf ("test-acc-%s" , acctest .RandString (10 ))
844845 )
845846
847+ dbMajorVersion := testAccGetMongoDBAtlasMajorVersion ()
848+
846849 resource .ParallelTest (t , resource.TestCase {
847850 PreCheck : func () { testAccPreCheck (t ) },
848851 Providers : testAccProviders ,
849852 CheckDestroy : testAccCheckMongoDBAtlasClusterDestroy ,
850853 Steps : []resource.TestStep {
851854 {
852- Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M2" , "2" ),
855+ Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M2" , "2" , dbMajorVersion ),
853856 Check : resource .ComposeTestCheckFunc (
854857 testAccCheckMongoDBAtlasClusterExists (resourceName , & cluster ),
855858 testAccCheckMongoDBAtlasClusterAttributes (& cluster , name ),
@@ -879,14 +882,15 @@ func TestAccResourceMongoDBAtlasCluster_tenant_m5(t *testing.T) {
879882 resourceName := "mongodbatlas_cluster.tenant"
880883 projectID := os .Getenv ("MONGODB_ATLAS_PROJECT_ID" )
881884 name := fmt .Sprintf ("test-acc-%s" , acctest .RandString (10 ))
885+ dbMajorVersion := testAccGetMongoDBAtlasMajorVersion ()
882886
883887 resource .ParallelTest (t , resource.TestCase {
884888 PreCheck : func () { testAccPreCheck (t ) },
885889 Providers : testAccProviders ,
886890 CheckDestroy : testAccCheckMongoDBAtlasClusterDestroy ,
887891 Steps : []resource.TestStep {
888892 {
889- Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M5" , "5" ),
893+ Config : testAccMongoDBAtlasClusterConfigTenant (projectID , name , "M5" , "5" , dbMajorVersion ),
890894 Check : resource .ComposeTestCheckFunc (
891895 testAccCheckMongoDBAtlasClusterExists (resourceName , & cluster ),
892896 testAccCheckMongoDBAtlasClusterAttributes (& cluster , name ),
@@ -911,6 +915,13 @@ func testAccCheckMongoDBAtlasClusterImportStateIDFunc(resourceName string) resou
911915 }
912916}
913917
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+
914925func testAccCheckMongoDBAtlasClusterExists (resourceName string , cluster * matlas.Cluster ) resource.TestCheckFunc {
915926 return func (s * terraform.State ) error {
916927 conn := testAccProvider .Meta ().(* matlas.Client )
@@ -982,7 +993,6 @@ func testAccMongoDBAtlasClusterConfigAWS(projectID, name string, backupEnabled,
982993 // Provider Settings "block"
983994 provider_name = "AWS"
984995 provider_disk_iops = 300
985- provider_encrypt_ebs_volume = false
986996 provider_instance_size_name = "M30"
987997 provider_region_name = "EU_CENTRAL_1"
988998 }
@@ -1216,7 +1226,7 @@ func testAccMongoDBAtlasClusterConfigGlobal(projectID, name, backupEnabled strin
12161226 ` , projectID , name , backupEnabled )
12171227}
12181228
1219- func testAccMongoDBAtlasClusterConfigTenant (projectID , name , instanceSize , diskSize string ) string {
1229+ func testAccMongoDBAtlasClusterConfigTenant (projectID , name , instanceSize , diskSize , majorDBVersion string ) string {
12201230 return fmt .Sprintf (`
12211231 resource "mongodbatlas_cluster" "tenant" {
12221232 project_id = "%s"
@@ -1230,10 +1240,10 @@ func testAccMongoDBAtlasClusterConfigTenant(projectID, name, instanceSize, diskS
12301240
12311241 provider_instance_size_name = "%s"
12321242 //These must be the following values
1233- mongo_db_major_version = "4.2 "
1243+ mongo_db_major_version = "%s "
12341244 auto_scaling_disk_gb_enabled = false
12351245 }
1236- ` , projectID , name , diskSize , instanceSize )
1246+ ` , projectID , name , diskSize , instanceSize , majorDBVersion )
12371247}
12381248
12391249func testAccMongoDBAtlasClusterConfigTenantUpdated (projectID , name string ) string {
0 commit comments