@@ -26,16 +26,18 @@ import (
2626 "github.com/mongodb/mongodbatlas-cloudformation-resources/util"
2727 "github.com/stretchr/testify/assert"
2828 admin20231115014 "go.mongodb.org/atlas-sdk/v20231115014/admin"
29+ "go.mongodb.org/atlas-sdk/v20250312006/admin"
2930)
3031
3132type localTestContext struct {
32- err error
33- cfnClient * cloudformation.Client
34- atlasClient * admin20231115014.APIClient
35- resourceCtx utility.ResourceContext
36- template string
37- replicationIDCreate string
38- clusterTmplObj testCluster
33+ err error
34+ cfnClient * cloudformation.Client
35+ atlasClient20231115014 * admin20231115014.APIClient
36+ atlasClient * admin.APIClient
37+ resourceCtx utility.ResourceContext
38+ template string
39+ replicationIDCreate string
40+ clusterTmplObj testCluster
3941}
4042
4143type testCluster struct {
@@ -122,7 +124,9 @@ func setupSuite(t *testing.T) *localTestContext {
122124func (c * localTestContext ) setUp (t * testing.T ) {
123125 t .Helper ()
124126 c .resourceCtx = utility .InitResourceCtx (stackName , e2eRandSuffix , resourceTypeName , resourceDirectory )
125- c .cfnClient , c .atlasClient = utility .NewClients20231115014 (t )
127+ c .cfnClient , c .atlasClient = utility .NewClients (t )
128+ _ , c .atlasClient20231115014 = utility .NewClients20231115014 (t )
129+
126130 utility .PublishToPrivateRegistry (t , c .resourceCtx )
127131 c .setupPrerequisites (t )
128132}
@@ -147,12 +151,8 @@ func testCreateStack(t *testing.T, c *localTestContext) {
147151 a .NotEmpty (replicationSpecs [0 ].GetId ())
148152 c .replicationIDCreate = replicationSpecs [0 ].GetId ()
149153
150- flexReplicationSpecs := flexCluster .GetReplicationSpecs ()
151- a .Len (flexReplicationSpecs , 1 )
152- a .Len (flexReplicationSpecs [0 ].GetRegionConfigs (), 1 )
153- flexRegionConfig := flexReplicationSpecs [0 ].GetRegionConfigs ()[0 ]
154- a .Equal ("FLEX" , flexRegionConfig .GetProviderName ())
155- a .Equal ("US_EAST_1" , flexRegionConfig .GetRegionName ())
154+ a .Equal ("FLEX" , flexCluster .ProviderSettings .GetProviderName ())
155+ a .Equal ("US_EAST_1" , flexCluster .ProviderSettings .GetRegionName ())
156156}
157157
158158func testUpdateStack (t * testing.T , c * localTestContext ) {
@@ -182,9 +182,9 @@ func testDeleteStack(t *testing.T, c *localTestContext) {
182182 t .Helper ()
183183 utility .DeleteStack (t , c .cfnClient , stackName )
184184 a := assert .New (t )
185- _ , resp , _ := c .atlasClient .ClustersApi .GetCluster (ctx .Background (), c .clusterTmplObj .ProjectID , c .clusterTmplObj .Name ).Execute ()
185+ _ , resp , _ := c .atlasClient20231115014 .ClustersApi .GetCluster (ctx .Background (), c .clusterTmplObj .ProjectID , c .clusterTmplObj .Name ).Execute ()
186186 a .Equal (404 , resp .StatusCode )
187- _ , flexResp , _ := c .atlasClient .ClustersApi . GetCluster (ctx .Background (), c .clusterTmplObj .ProjectID , c .clusterTmplObj .FlexName ).Execute ()
187+ _ , flexResp , _ := c .atlasClient .FlexClustersApi . GetFlexCluster (ctx .Background (), c .clusterTmplObj .ProjectID , c .clusterTmplObj .FlexName ).Execute ()
188188 a .Equal (404 , flexResp .StatusCode )
189189}
190190
@@ -197,7 +197,7 @@ func cleanupPrerequisites(t *testing.T, c *localTestContext) {
197197 t .Helper ()
198198 t .Log ("Cleaning up prerequisites" )
199199 if os .Getenv ("MONGODB_ATLAS_PROJECT_ID" ) == "" {
200- utility .DeleteProject (t , c .atlasClient , c .clusterTmplObj .ProjectID )
200+ utility .DeleteProject (t , c .atlasClient20231115014 , c .clusterTmplObj .ProjectID )
201201 } else {
202202 t .Log ("skipping project deletion (project managed outside of test)" )
203203 }
@@ -215,7 +215,7 @@ func (c *localTestContext) setupPrerequisites(t *testing.T) {
215215 t .Logf ("using projectID from env var %s" , projectIDEnvVar )
216216 projectID = projectIDEnvVar
217217 } else {
218- projectID = utility .CreateProject (t , c .atlasClient , orgID , testProjectName )
218+ projectID = utility .CreateProject (t , c .atlasClient20231115014 , orgID , testProjectName )
219219 }
220220
221221 c .clusterTmplObj = testCluster {
@@ -254,17 +254,17 @@ func checkReplicationSpecs(a *assert.Assertions, replicationSpecs []admin2023111
254254 }
255255}
256256
257- func readFromAtlas (t * testing.T , c * localTestContext ) (project * admin20231115014.Group , cluster * admin20231115014.AdvancedClusterDescription , flexCluster * admin20231115014. AdvancedClusterDescription ) {
257+ func readFromAtlas (t * testing.T , c * localTestContext ) (project * admin20231115014.Group , cluster * admin20231115014.AdvancedClusterDescription , flexCluster * admin. FlexClusterDescription20241113 ) {
258258 t .Helper ()
259259 context := ctx .Background ()
260260 projectID := c .clusterTmplObj .ProjectID
261261 var err error
262262 var getProjectResponse , getClusterResponse , getFlexClusterResponse * http.Response
263- project , getProjectResponse , err = c .atlasClient .ProjectsApi .GetProject (context , projectID ).Execute ()
263+ project , getProjectResponse , err = c .atlasClient20231115014 .ProjectsApi .GetProject (context , projectID ).Execute ()
264264 utility .FailNowIfError (t , "Error while retrieving Project from Atlas: %v" , err )
265- cluster , getClusterResponse , err = c .atlasClient .ClustersApi .GetCluster (context , projectID , c .clusterTmplObj .Name ).Execute ()
265+ cluster , getClusterResponse , err = c .atlasClient20231115014 .ClustersApi .GetCluster (context , projectID , c .clusterTmplObj .Name ).Execute ()
266266 utility .FailNowIfError (t , "Err while retrieving Cluster from Atlas: %v" , err )
267- flexCluster , getFlexClusterResponse , err = c .atlasClient .ClustersApi . GetCluster (context , projectID , c .clusterTmplObj .FlexName ).Execute ()
267+ flexCluster , getFlexClusterResponse , err = c .atlasClient .FlexClustersApi . GetFlexCluster (context , projectID , c .clusterTmplObj .FlexName ).Execute ()
268268 utility .FailNowIfError (t , "Err while retrieving Flex Cluster from Atlas: %v" , err )
269269 assert .Equal (t , 200 , getProjectResponse .StatusCode )
270270 assert .Equal (t , 200 , getClusterResponse .StatusCode )
0 commit comments