@@ -124,6 +124,129 @@ func TestAdvancedDeploymentsEqual(t *testing.T) {
124124 assert .Equal (t , beforeSpec , & merged , "Comparison should not change original spec values" )
125125 assert .Equal (t , beforeAtlas , & atlas , "Comparison should not change original atlas values" )
126126 })
127+
128+ t .Run ("Advanced deployments are the same when region configs are unordered" , func (t * testing.T ) {
129+ akoDeployment := akov2 .DefaultAwsAdvancedDeployment ("default" , "my-project" )
130+ akoDeployment .Spec .DeploymentSpec .ReplicationSpecs [0 ].RegionConfigs = []* akov2.AdvancedRegionConfig {
131+ {
132+ ElectableSpecs : & akov2.Specs {
133+ InstanceSize : "M10" ,
134+ NodeCount : pointer .MakePtr (1 ),
135+ },
136+ ReadOnlySpecs : & akov2.Specs {
137+ InstanceSize : "M30" ,
138+ NodeCount : pointer .MakePtr (0 ),
139+ },
140+ Priority : pointer .MakePtr (7 ),
141+ ProviderName : "AWS" ,
142+ RegionName : "US_EAST_1" ,
143+ },
144+ {
145+ ElectableSpecs : & akov2.Specs {
146+ InstanceSize : "M10" ,
147+ NodeCount : pointer .MakePtr (2 ),
148+ },
149+ ReadOnlySpecs : & akov2.Specs {
150+ InstanceSize : "M30" ,
151+ NodeCount : pointer .MakePtr (0 ),
152+ },
153+ Priority : pointer .MakePtr (6 ),
154+ ProviderName : "AWS" ,
155+ RegionName : "US_WEST_2" ,
156+ },
157+ {
158+ ReadOnlySpecs : & akov2.Specs {
159+ InstanceSize : "M30" ,
160+ NodeCount : pointer .MakePtr (2 ),
161+ },
162+ Priority : pointer .MakePtr (0 ),
163+ ProviderName : "GCP" ,
164+ RegionName : "US_WEST_2" ,
165+ },
166+ {
167+ AnalyticsSpecs : & akov2.Specs {
168+ InstanceSize : "M30" ,
169+ NodeCount : pointer .MakePtr (2 ),
170+ },
171+ Priority : pointer .MakePtr (0 ),
172+ ProviderName : "AWS" ,
173+ RegionName : "CA_CENTRAL_1" ,
174+ },
175+ {
176+ AnalyticsSpecs : & akov2.Specs {
177+ InstanceSize : "M10" ,
178+ NodeCount : pointer .MakePtr (4 ),
179+ },
180+ ReadOnlySpecs : & akov2.Specs {
181+ InstanceSize : "M30" ,
182+ NodeCount : pointer .MakePtr (2 ),
183+ },
184+ Priority : pointer .MakePtr (0 ),
185+ ProviderName : "AWS" ,
186+ RegionName : "US_WEST_2" ,
187+ },
188+ }
189+
190+ atlasDeployment := makeDefaultAtlasSpec ()
191+ atlasDeployment .ReplicationSpecs [0 ].RegionConfigs = []* mongodbatlas.AdvancedRegionConfig {
192+ {
193+ AnalyticsSpecs : & mongodbatlas.Specs {
194+ InstanceSize : "M30" ,
195+ NodeCount : pointer .MakePtr (2 ),
196+ },
197+ Priority : pointer .MakePtr (0 ),
198+ ProviderName : "AWS" ,
199+ RegionName : "CA_CENTRAL_1" ,
200+ },
201+ {
202+ ElectableSpecs : & mongodbatlas.Specs {
203+ InstanceSize : "M10" ,
204+ NodeCount : pointer .MakePtr (1 ),
205+ },
206+ Priority : pointer .MakePtr (7 ),
207+ ProviderName : "AWS" ,
208+ RegionName : "US_EAST_1" ,
209+ },
210+ {
211+ AnalyticsSpecs : & mongodbatlas.Specs {
212+ InstanceSize : "M10" ,
213+ NodeCount : pointer .MakePtr (4 ),
214+ },
215+ ReadOnlySpecs : & mongodbatlas.Specs {
216+ InstanceSize : "M30" ,
217+ NodeCount : pointer .MakePtr (2 ),
218+ },
219+ Priority : pointer .MakePtr (0 ),
220+ ProviderName : "AWS" ,
221+ RegionName : "US_WEST_2" ,
222+ },
223+ {
224+ ReadOnlySpecs : & mongodbatlas.Specs {
225+ InstanceSize : "M30" ,
226+ NodeCount : pointer .MakePtr (2 ),
227+ },
228+ Priority : pointer .MakePtr (0 ),
229+ ProviderName : "GCP" ,
230+ RegionName : "US_WEST_2" ,
231+ },
232+ {
233+ ElectableSpecs : & mongodbatlas.Specs {
234+ InstanceSize : "M10" ,
235+ NodeCount : pointer .MakePtr (2 ),
236+ },
237+ Priority : pointer .MakePtr (6 ),
238+ ProviderName : "AWS" ,
239+ RegionName : "US_WEST_2" ,
240+ },
241+ }
242+
243+ merged , atlas , err := MergedAdvancedDeployment (* atlasDeployment , * akoDeployment .Spec .DeploymentSpec )
244+ assert .NoError (t , err )
245+
246+ logger , _ := zap .NewProduction ()
247+ areEqual , _ := AdvancedDeploymentsEqual (logger .Sugar (), & merged , & atlas )
248+ assert .True (t , areEqual , "Deployments should be the same" )
249+ })
127250}
128251
129252func makeDefaultAtlasSpec () * mongodbatlas.AdvancedCluster {
0 commit comments