@@ -367,14 +367,13 @@ func TestReconcileMachinePhases(t *testing.T) {
367
367
368
368
g .Expect (env .Create (ctx , bootstrapConfig )).To (Succeed ())
369
369
g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
370
+ // We have to subtract 2 seconds, because .status.lastUpdated does not contain miliseconds.
371
+ preUpdate := time .Now ().Add (- 2 * time .Second )
370
372
g .Expect (env .Create (ctx , machine )).To (Succeed ())
371
373
372
374
modifiedMachine := machine .DeepCopy ()
373
375
// Set NodeRef.
374
376
machine .Status .NodeRef = & corev1.ObjectReference {Kind : "Node" , Name : node .Name }
375
- // Set the LastUpdated to be able to verify it is updated when the phase changes
376
- lastUpdated := metav1 .NewTime (time .Now ().Add (- 10 * time .Second ))
377
- machine .Status .LastUpdated = & lastUpdated
378
377
g .Expect (env .Status ().Patch (ctx , modifiedMachine , client .MergeFrom (machine ))).To (Succeed ())
379
378
380
379
// Set bootstrap ready.
@@ -397,7 +396,7 @@ func TestReconcileMachinePhases(t *testing.T) {
397
396
g .Expect (machine .Status .Addresses ).To (BeEmpty ())
398
397
// Verify that the LastUpdated timestamp was updated
399
398
g .Expect (machine .Status .LastUpdated ).NotTo (BeNil ())
400
- g .Expect (machine .Status .LastUpdated .After (lastUpdated . Time )).To (BeTrue ())
399
+ g .Expect (machine .Status .LastUpdated .After (preUpdate )).To (BeTrue ())
401
400
return true
402
401
}, 10 * time .Second ).Should (BeTrue ())
403
402
})
@@ -506,16 +505,10 @@ func TestReconcileMachinePhases(t *testing.T) {
506
505
507
506
g .Expect (env .Create (ctx , bootstrapConfig )).To (Succeed ())
508
507
g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
508
+ // We have to subtract 2 seconds, because .status.lastUpdated does not contain miliseconds.
509
+ preUpdate := time .Now ().Add (- 2 * time .Second )
509
510
g .Expect (env .Create (ctx , machine )).To (Succeed ())
510
511
511
- modifiedMachine := machine .DeepCopy ()
512
- // Set NodeRef to nil.
513
- machine .Status .NodeRef = nil
514
- // Set the LastUpdated to be able to verify it is updated when the phase changes
515
- lastUpdated := metav1 .NewTime (time .Now ().Add (- 10 * time .Second ))
516
- machine .Status .LastUpdated = & lastUpdated
517
- g .Expect (env .Status ().Patch (ctx , modifiedMachine , client .MergeFrom (machine ))).To (Succeed ())
518
-
519
512
// Set bootstrap ready.
520
513
modifiedBootstrapConfig := bootstrapConfig .DeepCopy ()
521
514
g .Expect (unstructured .SetNestedField (modifiedBootstrapConfig .Object , true , "status" , "ready" )).To (Succeed ())
@@ -535,7 +528,7 @@ func TestReconcileMachinePhases(t *testing.T) {
535
528
g .Expect (machine .Status .GetTypedPhase ()).To (Equal (clusterv1 .MachinePhaseProvisioned ))
536
529
// Verify that the LastUpdated timestamp was updated
537
530
g .Expect (machine .Status .LastUpdated ).NotTo (BeNil ())
538
- g .Expect (machine .Status .LastUpdated .After (lastUpdated . Time )).To (BeTrue ())
531
+ g .Expect (machine .Status .LastUpdated .After (preUpdate )).To (BeTrue ())
539
532
return true
540
533
}, 10 * time .Second ).Should (BeTrue ())
541
534
})
0 commit comments