@@ -298,28 +298,38 @@ func TestOSBuildController(t *testing.T) {
298
298
mosb := buildrequest .NewMachineOSBuildFromAPIOrDie (ctx , kubeclient , apiMosc , apiMCP )
299
299
buildJobName := utils .GetBuildJobName (mosb )
300
300
// After creating the new MachineOSConfig, a MachineOSBuild should be created.
301
+ t .Logf ("Debug: Checking MachineOSBuildExists for iteration %d, mosb name: %s" , i , mosb .Name )
301
302
kubeassert .MachineOSBuildExists (mosb , "MachineOSBuild not created for MachineOSConfig %s change, iteration %d" , mosc .Name , i )
302
303
304
+ t .Logf ("Debug: Checking assertBuildObjectsAreCreated for iteration %d" , i )
303
305
assertBuildObjectsAreCreated (ctx , t , kubeassert , mosb )
304
306
// After a new MachineOSBuild is created, a job should be created.
307
+ t .Logf ("Debug: Checking JobExists for iteration %d, job name: %s" , i , buildJobName )
305
308
kubeassert .JobExists (buildJobName , "Build job did not get created for MachineOSConfig %s change" , mosc .Name )
306
309
// Set the successful status on the job.
310
+ t .Logf ("Debug: Setting job status to succeeded for iteration %d" , i )
307
311
fixtures .SetJobStatus (ctx , t , kubeclient , mosb , fixtures.JobStatus {Succeeded : 1 })
308
312
// The MachineOSBuild should be successful.
313
+ t .Logf ("Debug: Checking MachineOSBuildIsSuccessful for iteration %d" , i )
309
314
kubeassert .MachineOSBuildIsSuccessful (mosb , "Expected the MachineOSBuild %s status to be successful" , mosb .Name )
310
315
// And the build job should be deleted.
316
+ t .Logf ("Debug: Checking assertBuildObjectsAreDeleted for iteration %d" , i )
311
317
assertBuildObjectsAreDeleted (ctx , t , kubeassert , mosb )
318
+ t .Logf ("Debug: Checking JobDoesNotExist for iteration %d, job name: %s" , i , buildJobName )
312
319
kubeassert .JobDoesNotExist (buildJobName , "Expected the build job %s to be deleted" , buildJobName )
313
320
314
321
// Ensure that the MachineOSBuild count increases with each successful build.
322
+ t .Logf ("Debug: Before isMachineOSBuildReachedExpectedCount for iteration %d, expected count: %d" , i , i + 2 )
315
323
isMachineOSBuildReachedExpectedCount (ctx , t , mcfgclient , apiMosc , i + 2 )
316
324
}
317
325
318
326
// Now, we delete the MachineOSConfig and we expect that all
319
327
// MachineOSBuilds that were created from it are also deleted.
328
+ t .Logf ("Debug: Deleting MachineOSConfig %s" , mosc .Name )
320
329
err := mcfgclient .MachineconfigurationV1 ().MachineOSConfigs ().Delete (ctx , mosc .Name , metav1.DeleteOptions {})
321
330
require .NoError (t , err )
322
331
332
+ t .Logf ("Debug: Before final isMachineOSBuildReachedExpectedCount, expected count: 0" )
323
333
isMachineOSBuildReachedExpectedCount (ctx , t , mcfgclient , mosc , 0 )
324
334
})
325
335
@@ -337,25 +347,33 @@ func TestOSBuildController(t *testing.T) {
337
347
mosb := buildrequest .NewMachineOSBuildFromAPIOrDie (ctx , kubeclient , apiMosc , apiMCP )
338
348
buildJobName := utils .GetBuildJobName (mosb )
339
349
// After updating the MachineConfigPool, a new MachineOSBuild should get created.
350
+ t .Logf ("Debug: Checking MachineOSBuildExists for iteration %d, mosb name: %s" , i , mosb .Name )
340
351
kubeassert .MachineOSBuildExists (mosb , "New MachineOSBuild for MachineConfigPool %q update for MachineOSConfig %q never gets created" , mcp .Name , mosc .Name )
341
352
// After a new MachineOSBuild is created, a job should be created.
353
+ t .Logf ("Debug: Checking JobExists for iteration %d, job name: %s" , i , buildJobName )
342
354
kubeassert .JobExists (buildJobName , "Build job did not get created for MachineConfigPool %q change" , mcp .Name )
343
355
// Set the successful status on the job.
356
+ t .Logf ("Debug: Setting job status to succeeded for iteration %d" , i )
344
357
fixtures .SetJobStatus (ctx , t , kubeclient , mosb , fixtures.JobStatus {Succeeded : 1 })
345
358
// The MachineOSBuild should be successful.
359
+ t .Logf ("Debug: Checking MachineOSBuildIsSuccessful for iteration %d" , i )
346
360
kubeassert .MachineOSBuildIsSuccessful (mosb , "Expected the MachineOSBuild %s status to be successful" , mosb .Name )
347
361
// And the build job should be deleted.
362
+ t .Logf ("Debug: Checking JobDoesNotExist for iteration %d, job name: %s" , i , buildJobName )
348
363
kubeassert .JobDoesNotExist (buildJobName , "Expected the build job %s to be deleted" , buildJobName )
349
364
350
365
// Ensure that the MachineOSBuild count increases with each successful build.
366
+ t .Logf ("Debug: Before isMachineOSBuildReachedExpectedCount for iteration %d, expected count: %d" , i , i + 2 )
351
367
isMachineOSBuildReachedExpectedCount (ctx , t , mcfgclient , apiMosc , i + 2 )
352
368
}
353
369
354
370
// Now, we delete the MachineOSConfig and we expect that all
355
371
// MachineOSBuilds that were created from it are also deleted.
372
+ t .Logf ("Debug: Deleting MachineOSConfig %s" , mosc .Name )
356
373
err := mcfgclient .MachineconfigurationV1 ().MachineOSConfigs ().Delete (ctx , mosc .Name , metav1.DeleteOptions {})
357
374
require .NoError (t , err )
358
375
376
+ t .Logf ("Debug: Before final isMachineOSBuildReachedExpectedCount, expected count: 0" )
359
377
isMachineOSBuildReachedExpectedCount (ctx , t , mcfgclient , mosc , 0 )
360
378
})
361
379
}
@@ -774,7 +792,7 @@ func insertNewRenderedMachineConfigWithoutImageChange(ctx context.Context, t *te
774
792
func isMachineOSBuildReachedExpectedCount (ctx context.Context , t * testing.T , mcfgclient mcfgclientset.Interface , mosc * mcfgv1.MachineOSConfig , expected int ) {
775
793
t .Helper ()
776
794
777
- err := wait .PollImmediateInfiniteWithContext (ctx , time .Millisecond , func (ctx context.Context ) (bool , error ) {
795
+ err := wait .PollUntilContextCancel (ctx , time .Millisecond , true , func (ctx context.Context ) (bool , error ) {
778
796
mosbList , err := mcfgclient .MachineconfigurationV1 ().MachineOSBuilds ().List (ctx , metav1.ListOptions {
779
797
LabelSelector : utils .MachineOSBuildForPoolSelector (mosc ).String (),
780
798
})
@@ -793,7 +811,7 @@ func assertMachineOSConfigGetsBuiltImagePushspec(ctx context.Context, t *testing
793
811
794
812
var foundMosc * mcfgv1.MachineOSConfig
795
813
796
- err := wait .PollImmediateInfiniteWithContext (ctx , time .Millisecond , func (ctx context.Context ) (bool , error ) {
814
+ err := wait .PollUntilContextCancel (ctx , time .Millisecond , true , func (ctx context.Context ) (bool , error ) {
797
815
apiMosc , err := mcfgclient .MachineconfigurationV1 ().MachineOSConfigs ().Get (ctx , mosc .Name , metav1.GetOptions {})
798
816
if err != nil {
799
817
return false , err
@@ -811,7 +829,7 @@ func assertMachineOSConfigGetsBuiltImagePushspec(ctx context.Context, t *testing
811
829
func assertMachineOSConfigGetsCurrentBuildAnnotation (ctx context.Context , t * testing.T , mcfgclient mcfgclientset.Interface , mosc * mcfgv1.MachineOSConfig , mosb * mcfgv1.MachineOSBuild ) {
812
830
t .Helper ()
813
831
814
- err := wait .PollImmediateInfiniteWithContext (ctx , time .Millisecond , func (ctx context.Context ) (bool , error ) {
832
+ err := wait .PollUntilContextCancel (ctx , time .Millisecond , true , func (ctx context.Context ) (bool , error ) {
815
833
apiMosc , err := mcfgclient .MachineconfigurationV1 ().MachineOSConfigs ().Get (ctx , mosc .Name , metav1.GetOptions {})
816
834
if err != nil {
817
835
return false , err
0 commit comments