Skip to content

Commit e31ea52

Browse files
author
Valeriy Khorunzhin
committed
wrap check
Signed-off-by: Valeriy Khorunzhin <[email protected]>
1 parent 29298b4 commit e31ea52

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

test/e2e/vm/configuration.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,9 @@ var _ = Describe("VirtualMachineConfiguration", func() {
8888
err = f.Clients.GenericClient().Update(context.Background(), t.VM)
8989
Expect(err).NotTo(HaveOccurred())
9090

91-
if restartApprovalMode == v1alpha2.Manual {
92-
// Avoid race condition with need restart condition calculation
93-
Eventually(func(g Gomega) {
94-
err = f.Clients.GenericClient().Get(context.Background(), crclient.ObjectKeyFromObject(t.VM), t.VM)
95-
g.Expect(err).NotTo(HaveOccurred())
96-
needRestart, _ := conditions.GetCondition(vmcondition.TypeAwaitingRestartToApplyConfiguration, t.VM.Status.Conditions)
97-
g.Expect(needRestart.Status).To(Equal(metav1.ConditionTrue))
98-
g.Expect(t.VM.Status.RestartAwaitingChanges).NotTo(BeNil())
99-
}).WithTimeout(3 * time.Second).WithPolling(time.Second).Should(Succeed())
91+
t.CheckRestartAwaitingChanges(t.VM)
10092

93+
if t.VM.Spec.Disruptions.RestartApprovalMode == v1alpha2.Manual {
10194
util.RebootVirtualMachineBySSH(f, t.VM)
10295
}
10396

@@ -173,3 +166,18 @@ func (c *configurationTest) IsVDAttached(vd *v1alpha2.VirtualDisk, vm *v1alpha2.
173166
}
174167
return false
175168
}
169+
170+
func (t *configurationTest) CheckRestartAwaitingChanges(vm *v1alpha2.VirtualMachine) {
171+
if vm.Spec.Disruptions.RestartApprovalMode != v1alpha2.Manual {
172+
return
173+
}
174+
175+
// Avoid race condition with need restart condition calculation
176+
Eventually(func(g Gomega) {
177+
err := t.Framework.Clients.GenericClient().Get(context.Background(), crclient.ObjectKeyFromObject(t.VM), t.VM)
178+
g.Expect(err).NotTo(HaveOccurred())
179+
needRestart, _ := conditions.GetCondition(vmcondition.TypeAwaitingRestartToApplyConfiguration, t.VM.Status.Conditions)
180+
g.Expect(needRestart.Status).To(Equal(metav1.ConditionTrue))
181+
g.Expect(t.VM.Status.RestartAwaitingChanges).NotTo(BeNil())
182+
}).WithTimeout(3 * time.Second).WithPolling(time.Second).Should(Succeed())
183+
}

0 commit comments

Comments
 (0)