@@ -122,6 +122,43 @@ var _ = Describe("AtlasCluster", func() {
122122 }
123123
124124 Describe ("Create/Update the cluster" , func () {
125+ It ("Should fail, then be fixed" , func () {
126+ expectedCluster := testAtlasCluster (namespace .Name , "test-cluster" , createdProject .Name )
127+ expectedCluster .Spec .Name = ""
128+
129+ By (fmt .Sprintf ("Creating the Cluster %s with invalid parameters" , kube .ObjectKeyFromObject (expectedCluster )), func () {
130+ createdCluster .ObjectMeta = expectedCluster .ObjectMeta
131+ Expect (k8sClient .Create (context .Background (), expectedCluster )).ToNot (HaveOccurred ())
132+
133+ Eventually (
134+ testutil .WaitFor (
135+ k8sClient ,
136+ createdCluster ,
137+ status .
138+ FalseCondition (status .ClusterReadyType ).
139+ WithReason (string (workflow .Internal )). // Internal due to reconciliation failing on the initial GET request
140+ WithMessageRegexp ("name is invalid because must be set" ),
141+ ),
142+ 60 ,
143+ interval ,
144+ ).Should (BeTrue ())
145+
146+ lastGeneration ++
147+ })
148+
149+ By ("Fixing the cluster" , func () {
150+ createdCluster .Spec .Name = "fixed-cluster"
151+
152+ Expect (k8sClient .Update (context .Background (), createdCluster )).To (Succeed ())
153+
154+ Eventually (testutil .WaitFor (k8sClient , createdCluster , status .TrueCondition (status .ReadyType ), validateClusterCreatingFunc ()),
155+ 1200 , interval ).Should (BeTrue ())
156+
157+ doCommonChecks ()
158+ checkAtlasState ()
159+ })
160+ })
161+
125162 It ("Should Succeed" , func () {
126163 expectedCluster := testAtlasCluster (namespace .Name , "test-cluster" , createdProject .Name )
127164
@@ -180,7 +217,14 @@ var _ = Describe("AtlasCluster", func() {
180217
181218 Expect (k8sClient .Update (context .Background (), createdCluster )).To (Succeed ())
182219 Eventually (
183- testutil .WaitFor (k8sClient , createdCluster , status .FalseCondition (status .ClusterReadyType ).WithReason (string (workflow .ClusterNotCreatedInAtlas ))),
220+ testutil .WaitFor (
221+ k8sClient ,
222+ createdCluster ,
223+ status .
224+ FalseCondition (status .ClusterReadyType ).
225+ WithReason (string (workflow .ClusterNotUpdatedInAtlas )).
226+ WithMessageRegexp ("CANNOT_UPDATE_PAUSED_CLUSTER" ),
227+ ),
184228 60 ,
185229 interval ,
186230 ).Should (BeTrue ())
@@ -203,6 +247,65 @@ var _ = Describe("AtlasCluster", func() {
203247 Expect (c .ProviderBackupEnabled ).To (Equal (createdCluster .Spec .ProviderBackupEnabled ))
204248 })
205249 })
250+
251+ By ("Setting AutoScaling.Compute.Enabled to false (should fail)" , func () {
252+ createdCluster .Spec .ProviderSettings .AutoScaling = & mdbv1.AutoScalingSpec {
253+ Compute : & mdbv1.ComputeSpec {
254+ Enabled : boolptr (false ),
255+ },
256+ }
257+
258+ Expect (k8sClient .Update (context .Background (), createdCluster )).To (Succeed ())
259+ Eventually (
260+ testutil .WaitFor (
261+ k8sClient ,
262+ createdCluster ,
263+ status .
264+ FalseCondition (status .ClusterReadyType ).
265+ WithReason (string (workflow .ClusterNotUpdatedInAtlas )).
266+ WithMessageRegexp ("INVALID_ATTRIBUTE" ),
267+ ),
268+ 60 ,
269+ interval ,
270+ ).Should (BeTrue ())
271+
272+ lastGeneration ++
273+
274+ By ("Fixing the Cluster" , func () {
275+ createdCluster .Spec .ProviderSettings .AutoScaling = nil
276+ performUpdate ()
277+ doCommonChecks ()
278+ checkAtlasState ()
279+ })
280+ })
281+
282+ By ("Setting incorrect instance size (should fail)" , func () {
283+ oldSizeName := createdCluster .Spec .ProviderSettings .InstanceSizeName
284+ createdCluster .Spec .ProviderSettings .InstanceSizeName = "M42"
285+
286+ Expect (k8sClient .Update (context .Background (), createdCluster )).To (Succeed ())
287+ Eventually (
288+ testutil .WaitFor (
289+ k8sClient ,
290+ createdCluster ,
291+ status .
292+ FalseCondition (status .ClusterReadyType ).
293+ WithReason (string (workflow .ClusterNotUpdatedInAtlas )).
294+ WithMessageRegexp ("INVALID_ENUM_VALUE" ),
295+ ),
296+ 60 ,
297+ interval ,
298+ ).Should (BeTrue ())
299+
300+ lastGeneration ++
301+
302+ By ("Fixing the Cluster" , func () {
303+ createdCluster .Spec .ProviderSettings .InstanceSizeName = oldSizeName
304+ performUpdate ()
305+ doCommonChecks ()
306+ checkAtlasState ()
307+ })
308+ })
206309 })
207310 })
208311})
0 commit comments