@@ -218,20 +218,22 @@ var _ = Describe("Server Controller", func() {
218218 Expect (probeAgent .Start (ctx )).To (Succeed (), "failed to start probe agent" )
219219 }()
220220
221- Eventually (func (g Gomega ) {
222- resp , err := http .Get (fmt .Sprintf ("%s/systems/%s" , registryURL , server .Spec .SystemUUID ))
223- g .Expect (resp ).NotTo (BeNil ())
224- g .Expect (err ).NotTo (HaveOccurred ())
225- g .Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
226- }).Should (Succeed ())
227-
228221 By ("Ensuring that the server is set to available and powered off" )
229222 Eventually (Object (server )).Should (SatisfyAll (
230- HaveField ("Spec.BootConfigurationRef" , BeNil ()),
223+ HaveField ("Status.State" , metalv1alpha1 .ServerStateAvailable ),
224+ ))
225+ // as this is set in the next reconsile cycle after reaching Available state is set,
226+ // its best to check for it later to avoid flakyness
227+ Eventually (Object (server )).Should (SatisfyAll (
231228 HaveField ("Status.State" , metalv1alpha1 .ServerStateAvailable ),
232229 HaveField ("Status.PowerState" , metalv1alpha1 .ServerOffPowerState ),
233230 HaveField ("Status.NetworkInterfaces" , Not (BeEmpty ())),
234231 ))
232+ // as this is set in the next reconsile cycle after power is set,
233+ // its best to check for it later to avoid flakyness
234+ Eventually (Object (server )).Should (SatisfyAll (
235+ HaveField ("Spec.BootConfigurationRef" , BeNil ()),
236+ ))
235237
236238 By ("Ensuring that the boot configuration has been removed" )
237239 Consistently (Get (bootConfig )).Should (Satisfy (apierrors .IsNotFound ))
@@ -401,13 +403,6 @@ var _ = Describe("Server Controller", func() {
401403 Expect (probeAgent .Start (ctx )).To (Succeed (), "failed to start probe agent" )
402404 }()
403405
404- Eventually (func (g Gomega ) {
405- resp , err := http .Get (fmt .Sprintf ("%s/systems/%s" , registryURL , server .Spec .SystemUUID ))
406- g .Expect (resp ).NotTo (BeNil ())
407- g .Expect (err ).NotTo (HaveOccurred ())
408- g .Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
409- }).Should (Succeed ())
410-
411406 By ("Ensuring that the server is set to available and powered off" )
412407 // check that the available state is set first, as that is as part of handling
413408 // the discovery state. The ServerBootConfig deletion happens in a later
@@ -418,7 +413,6 @@ var _ = Describe("Server Controller", func() {
418413 // force calculation of zero capacity string
419414 _ = zeroCapacity .String ()
420415 Eventually (Object (server )).Should (SatisfyAll (
421- HaveField ("Spec.BootConfigurationRef" , BeNil ()),
422416 HaveField ("Spec.Power" , metalv1alpha1 .PowerOff ),
423417 HaveField ("Status.State" , metalv1alpha1 .ServerStateAvailable ),
424418 HaveField ("Status.PowerState" , metalv1alpha1 .ServerOffPowerState ),
@@ -454,6 +448,11 @@ var _ = Describe("Server Controller", func() {
454448 })),
455449 HaveField ("Status.Storages" , HaveLen (1 )),
456450 ))
451+ // as this is set in the next reconsile cycle after power is set,
452+ // its best to check for it later to avoid flakyness
453+ Eventually (Object (server )).Should (SatisfyAll (
454+ HaveField ("Spec.BootConfigurationRef" , BeNil ()),
455+ ))
457456
458457 By ("Ensuring that the boot configuration has been removed" )
459458 Consistently (Get (bootConfig )).Should (Satisfy (apierrors .IsNotFound ))
@@ -523,6 +522,7 @@ var _ = Describe("Server Controller", func() {
523522 bootConfig .Status .State = metalv1alpha1 .ServerBootConfigurationStateReady
524523 })).Should (Succeed ())
525524
526- Eventually (Object (server )).Should (HaveField ("Status.State" , metalv1alpha1 .ServerStateInitial ))
525+ // this is large timeout due to the wait time for the DiscoveryTimeout to be hit and then transistioned to Intitial state
526+ Eventually (Object (server )).WithTimeout (5 * time .Second ).Should (HaveField ("Status.State" , metalv1alpha1 .ServerStateInitial ))
527527 })
528528})
0 commit comments