Skip to content

Commit 4bf6cdb

Browse files
authored
Merge pull request kubernetes#129554 from zylxjtu/bootid
Add the check of node rebooting in windows reboot_node e2e test
2 parents 0e9ca10 + f891092 commit 4bf6cdb

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

test/e2e/windows/reboot_node.go

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
5050
framework.ExpectNoError(err, "Error finding Windows node")
5151
framework.Logf("Using node: %v", targetNode.Name)
5252

53+
bootID := targetNode.Status.NodeInfo.BootID
5354
windowsImage := imageutils.GetE2EImage(imageutils.Agnhost)
5455

5556
// Create Windows pod on the selected Windows node Using Agnhost
@@ -176,32 +177,24 @@ var _ = sigDescribe(feature.Windows, "[Excluded:WindowsDocker] [MinimumKubeletVe
176177

177178
restartCount := 0
178179

179-
timeout := time.After(time.Minute * 10)
180-
FOR:
181-
for {
182-
select {
183-
case <-timeout:
184-
break FOR
185-
default:
186-
if restartCount > 0 {
187-
break FOR
188-
}
189-
ginkgo.By("Then checking existed agn-test-pod is running on the rebooted host")
190-
agnPodOut, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(ctx, agnPod.Name, metav1.GetOptions{})
191-
if err == nil {
192-
lastRestartCount := podutil.GetExistingContainerStatus(agnPodOut.Status.ContainerStatuses, "windows-container").RestartCount
193-
restartCount = int(lastRestartCount - initialRestartCount)
194-
}
195-
time.Sleep(time.Second * 30)
180+
ginkgo.By("Waiting for nodes to be rebooted")
181+
gomega.Eventually(ctx, func(ctx context.Context) string {
182+
refreshNode, err := f.ClientSet.CoreV1().Nodes().Get(ctx, targetNode.Name, metav1.GetOptions{})
183+
if err != nil {
184+
return ""
196185
}
197-
}
198-
199-
ginkgo.By("Checking whether agn-test-pod is rebooted")
200-
gomega.Expect(restartCount).To(gomega.Equal(1), "restart count of agn-test-pod is 1")
186+
return refreshNode.Status.NodeInfo.BootID
187+
}).WithPolling(time.Second*30).WithTimeout(time.Minute*10).
188+
Should(gomega.BeNumerically(">", bootID), "node was not rebooted")
201189

190+
ginkgo.By("Then checking existed agn-test-pod is running on the rebooted host")
202191
agnPodOut, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Get(ctx, agnPod.Name, metav1.GetOptions{})
203-
gomega.Expect(agnPodOut.Status.Phase).To(gomega.Equal(v1.PodRunning))
204192
framework.ExpectNoError(err, "getting pod info after reboot")
193+
194+
lastRestartCount := podutil.GetExistingContainerStatus(agnPodOut.Status.ContainerStatuses, "windows-container").RestartCount
195+
restartCount = int(lastRestartCount - initialRestartCount)
196+
gomega.Expect(restartCount).To(gomega.Equal(1), "restart count of agn-test-pod is 1")
197+
gomega.Expect(agnPodOut.Status.Phase).To(gomega.Equal(v1.PodRunning))
205198
assertConsistentConnectivity(ctx, f, nginxPod.ObjectMeta.Name, "linux", linuxCheck(agnPodOut.Status.PodIP, 80), internalMaxTries)
206199

207200
// create another host process pod to check system boot time

0 commit comments

Comments
 (0)