@@ -266,7 +266,7 @@ func TestAWSMachinePoolReconciler(t *testing.T) {
266
266
},
267
267
}
268
268
}
269
- t .Run ("it should suspend these processes " , func (t * testing.T ) {
269
+ t .Run ("it should not call suspend as we don't have an ASG yet " , func (t * testing.T ) {
270
270
g := NewWithT (t )
271
271
setup (t , g )
272
272
defer teardown (t , g )
@@ -277,7 +277,7 @@ func TestAWSMachinePoolReconciler(t *testing.T) {
277
277
asgSvc .EXPECT ().CreateASG (gomock .Any ()).Return (& expinfrav1.AutoScalingGroup {
278
278
Name : "name" ,
279
279
}, nil )
280
- asgSvc .EXPECT ().SuspendProcesses ("name" , []string {"Launch" , "Terminate" }).Return (nil ).AnyTimes ()
280
+ asgSvc .EXPECT ().SuspendProcesses ("name" , []string {"Launch" , "Terminate" }).Return (nil ).AnyTimes (). Times ( 0 )
281
281
282
282
_ , err := reconciler .reconcileNormal (context .Background (), ms , cs , cs )
283
283
g .Expect (err ).To (Succeed ())
@@ -290,56 +290,29 @@ func TestAWSMachinePoolReconciler(t *testing.T) {
290
290
All : true ,
291
291
}
292
292
}
293
- t .Run ("it should result in all processes being included except the value all " , func (t * testing.T ) {
293
+ t .Run ("processes should be suspended during an update call " , func (t * testing.T ) {
294
294
g := NewWithT (t )
295
295
setup (t , g )
296
296
defer teardown (t , g )
297
297
setSuspendedProcesses (t , g )
298
-
298
+ ms . AWSMachinePool . Spec . SuspendProcesses . All = true
299
299
ec2Svc .EXPECT ().ReconcileLaunchTemplate (gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil )
300
- asgSvc .EXPECT ().GetASGByName (gomock .Any ()) .Return (nil , nil )
301
- asgSvc .EXPECT ().CreateASG (gomock .Any ()).Return (& expinfrav1.AutoScalingGroup {
300
+ ec2Svc .EXPECT ().ReconcileTags (gomock .Any (), gomock . Any ()) .Return (nil )
301
+ asgSvc .EXPECT ().GetASGByName (gomock .Any ()).Return (& expinfrav1.AutoScalingGroup {
302
302
Name : "name" ,
303
303
}, nil )
304
- asgSvc .EXPECT ().SuspendProcesses ("name" , []string {
304
+ asgSvc .EXPECT ().UpdateASG (gomock .Any ()).Return (nil ).AnyTimes ()
305
+ asgSvc .EXPECT ().SuspendProcesses ("name" , gomock .InAnyOrder ([]string {
306
+ "ScheduledActions" ,
305
307
"Launch" ,
306
308
"Terminate" ,
307
309
"AddToLoadBalancer" ,
308
310
"AlarmNotification" ,
309
311
"AZRebalance" ,
310
- "HealthCheck" ,
311
312
"InstanceRefresh" ,
312
- "ReplaceUnhealthy" ,
313
- "ScheduledActions" ,
314
- }).Return (nil ).AnyTimes ()
315
-
316
- _ , err := reconciler .reconcileNormal (context .Background (), ms , cs , cs )
317
- g .Expect (err ).To (Succeed ())
318
- })
319
- t .Run ("and one or more processes are disabled, it should not list those" , func (t * testing.T ) {
320
- g := NewWithT (t )
321
- setup (t , g )
322
- defer teardown (t , g )
323
- setSuspendedProcesses (t , g )
324
- ms .AWSMachinePool .Spec .SuspendProcesses .Processes = & expinfrav1.Processes {
325
- Launch : pointer .Bool (false ),
326
- AZRebalance : pointer .Bool (true ), // this should still be included but not twice...
327
- }
328
- ec2Svc .EXPECT ().ReconcileLaunchTemplate (gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil )
329
- asgSvc .EXPECT ().GetASGByName (gomock .Any ()).Return (nil , nil )
330
- asgSvc .EXPECT ().CreateASG (gomock .Any ()).Return (& expinfrav1.AutoScalingGroup {
331
- Name : "name" ,
332
- }, nil )
333
- asgSvc .EXPECT ().SuspendProcesses ("name" , []string {
334
- "Terminate" ,
335
- "AddToLoadBalancer" ,
336
- "AlarmNotification" ,
337
- "AZRebalance" ,
338
313
"HealthCheck" ,
339
- "InstanceRefresh" ,
340
314
"ReplaceUnhealthy" ,
341
- "ScheduledActions" ,
342
- }).Return (nil ).AnyTimes ()
315
+ })).Return (nil ).AnyTimes ().Times (1 )
343
316
344
317
_ , err := reconciler .reconcileNormal (context .Background (), ms , cs , cs )
345
318
g .Expect (err ).To (Succeed ())
@@ -369,8 +342,8 @@ func TestAWSMachinePoolReconciler(t *testing.T) {
369
342
CurrentlySuspendProcesses : []string {"Launch" , "process3" },
370
343
}, nil )
371
344
asgSvc .EXPECT ().UpdateASG (gomock .Any ()).Return (nil ).AnyTimes ()
372
- asgSvc .EXPECT ().SuspendProcesses ("name" , []string {"Terminate" }).Return (nil ).AnyTimes ()
373
- asgSvc .EXPECT ().ResumeProcesses ("name" , []string {"process3" }).Return (nil ).AnyTimes ()
345
+ asgSvc .EXPECT ().SuspendProcesses ("name" , []string {"Terminate" }).Return (nil ).AnyTimes (). Times ( 1 )
346
+ asgSvc .EXPECT ().ResumeProcesses ("name" , []string {"process3" }).Return (nil ).AnyTimes (). Times ( 1 )
374
347
375
348
_ , err := reconciler .reconcileNormal (context .Background (), ms , cs , cs )
376
349
g .Expect (err ).To (Succeed ())
0 commit comments