@@ -2071,7 +2071,8 @@ func TestReconcileMachinePhases(t *testing.T) {
20712071
20722072g .Expect (env .Create (ctx , bootstrapConfig )).To (Succeed ())
20732073g .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.
20772078g .Eventually (func (g Gomega ) bool {
@@ -2123,7 +2124,8 @@ func TestReconcileMachinePhases(t *testing.T) {
21232124
21242125g .Expect (env .Create (ctx , bootstrapConfig )).To (Succeed ())
21252126g .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.
21292131g .Eventually (func (g Gomega ) bool {
@@ -2168,7 +2170,7 @@ func TestReconcileMachinePhases(t *testing.T) {
21682170g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
21692171// We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
21702172preUpdate := 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
21742176modifiedMachine := machine .DeepCopy ()
@@ -2240,7 +2242,9 @@ func TestReconcileMachinePhases(t *testing.T) {
22402242g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
22412243// We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
22422244preUpdate := 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
22452249modifiedMachine := machine .DeepCopy ()
22462250// Set NodeRef.
@@ -2329,7 +2333,8 @@ func TestReconcileMachinePhases(t *testing.T) {
23292333g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
23302334// We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
23312335preUpdate := 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
23342339modifiedMachine := machine .DeepCopy ()
23352340// Set NodeRef.
@@ -2407,7 +2412,8 @@ func TestReconcileMachinePhases(t *testing.T) {
24072412g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
24082413// We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
24092414preUpdate := 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
24122418modifiedMachine := machine .DeepCopy ()
24132419// Set NodeRef.
@@ -2474,7 +2480,8 @@ func TestReconcileMachinePhases(t *testing.T) {
24742480g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
24752481// We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
24762482preUpdate := 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.
24802487modifiedBootstrapConfig := bootstrapConfig .DeepCopy ()
@@ -2546,7 +2553,8 @@ func TestReconcileMachinePhases(t *testing.T) {
25462553g .Expect (env .Create (ctx , infraMachine )).To (Succeed ())
25472554// We have to subtract 2 seconds, because .status.lastUpdated does not contain milliseconds.
25482555preUpdate := 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.
25522560modifiedBootstrapConfig := bootstrapConfig .DeepCopy ()
@@ -2578,7 +2586,7 @@ func TestReconcileMachinePhases(t *testing.T) {
25782586g .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.
25842592g .Eventually (func (g Gomega ) bool {
0 commit comments