@@ -2071,7 +2071,8 @@ func TestReconcileMachinePhases(t *testing.T) {
20712071
20722072 g .Expect (env .Create (ctx , bootstrapConfig )).To (Succeed ())
20732073 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
2074- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2074+ // Create and wait on machine to make sure caches sync and reconciliation triggers.
2075+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
20752076
20762077 // Wait until BootstrapConfig has the ownerReference.
20772078 g .Eventually (func (g Gomega ) bool {
@@ -2123,7 +2124,8 @@ func TestReconcileMachinePhases(t *testing.T) {
21232124
21242125 g .Expect (env .Create (ctx , bootstrapConfig )).To (Succeed ())
21252126 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
2126- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2127+ // Create and wait on machine to make sure caches sync and reconciliation triggers.
2128+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
21272129
21282130 // Wait until Machine was reconciled.
21292131 g .Eventually (func (g Gomega ) bool {
@@ -2168,7 +2170,7 @@ func TestReconcileMachinePhases(t *testing.T) {
21682170 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
21692171 // We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
21702172 preUpdate := time .Now ().Add (- 2 * time .Second )
2171- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2173+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
21722174
21732175 // Set the LastUpdated to be able to verify it is updated when the phase changes
21742176 modifiedMachine := machine .DeepCopy ()
@@ -2240,7 +2242,9 @@ func TestReconcileMachinePhases(t *testing.T) {
22402242 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
22412243 // We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
22422244 preUpdate := time .Now ().Add (- 2 * time .Second )
2243- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2245+
2246+ // Create and wait on machine to make sure caches sync and reconciliation triggers.
2247+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
22442248
22452249 modifiedMachine := machine .DeepCopy ()
22462250 // Set NodeRef.
@@ -2329,7 +2333,8 @@ func TestReconcileMachinePhases(t *testing.T) {
23292333 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
23302334 // We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
23312335 preUpdate := time .Now ().Add (- 2 * time .Second )
2332- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2336+ // Create and wait on machine to make sure caches sync and reconciliation triggers.
2337+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
23332338
23342339 modifiedMachine := machine .DeepCopy ()
23352340 // Set NodeRef.
@@ -2407,7 +2412,8 @@ func TestReconcileMachinePhases(t *testing.T) {
24072412 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
24082413 // We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
24092414 preUpdate := time .Now ().Add (- 2 * time .Second )
2410- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2415+ // Create and wait on machine to make sure caches sync and reconciliation triggers.
2416+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
24112417
24122418 modifiedMachine := machine .DeepCopy ()
24132419 // Set NodeRef.
@@ -2474,7 +2480,8 @@ func TestReconcileMachinePhases(t *testing.T) {
24742480 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
24752481 // We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
24762482 preUpdate := time .Now ().Add (- 2 * time .Second )
2477- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2483+ // Create and wait on machine to make sure caches sync and reconciliation triggers.
2484+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
24782485
24792486 // Set bootstrap ready.
24802487 modifiedBootstrapConfig := bootstrapConfig .DeepCopy ()
@@ -2546,7 +2553,8 @@ func TestReconcileMachinePhases(t *testing.T) {
25462553 g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
25472554 // We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
25482555 preUpdate := time .Now ().Add (- 2 * time .Second )
2549- g .Expect (env .Create (ctx , machine )).To (Succeed ())
2556+ // Create and wait on machine to make sure caches sync and reconciliation triggers.
2557+ g .Expect (env .CreateAndWait (ctx , machine )).To (Succeed ())
25502558
25512559 // Set bootstrap ready.
25522560 modifiedBootstrapConfig := bootstrapConfig .DeepCopy ()
@@ -2578,7 +2586,7 @@ func TestReconcileMachinePhases(t *testing.T) {
25782586 g .Expect (env .Patch (ctx , modifiedMachine , client .MergeFrom (machine ))).To (Succeed ())
25792587
25802588 // Delete Machine
2581- g .Expect (env .Delete (ctx , machine )).To (Succeed ())
2589+ g .Expect (env .DeleteAndWait (ctx , machine )).To (Succeed ())
25822590
25832591 // Wait until Machine was reconciled.
25842592 g .Eventually (func (g Gomega ) bool {
0 commit comments