From b1788b10908d0caf2c405a5ed520fc2cfe2b5175 Mon Sep 17 00:00:00 2001 From: Jiri Mencak Date: Fri, 19 Aug 2022 13:55:42 +0200 Subject: [PATCH] e2e: fix a race in [reboots] tests. Wait for a flip to MachineConfigPool UpdatedMachineCount == 0 prior to waiting for it to be updated (== 1) again. --- test/e2e/reboots/kernel_parameter_add_rm.go | 23 +++++++++++---------- test/e2e/reboots/machine_config_labels.go | 5 +++++ test/e2e/reboots/stalld.go | 5 +++++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/test/e2e/reboots/kernel_parameter_add_rm.go b/test/e2e/reboots/kernel_parameter_add_rm.go index 64b42c1bb6..6e0991e897 100644 --- a/test/e2e/reboots/kernel_parameter_add_rm.go +++ b/test/e2e/reboots/kernel_parameter_add_rm.go @@ -83,9 +83,17 @@ var _ = ginkgo.Describe("[reboots][kernel_parameter_add_rm] Node Tuning Operator _, _, err = util.ExecAndLogCommand("oc", "create", "-f", mcpRealtime) gomega.Expect(err).NotTo(gomega.HaveOccurred()) - ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 1") - err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 1) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) + waitForMCPFlip := func() { + // By creating the custom child profile, we will first see worker-rt MachineConfigPool UpdatedMachineCount drop to 0 first... + ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 0") + err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 0) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // ...and go up to 1 again next. + ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 1") + err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 1) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + } + waitForMCPFlip() ginkgo.By(fmt.Sprintf("getting the current %s value in Pod %s", procCmdline, pod.Name)) cmdlineNew, err := util.WaitForCmdInPod(pollInterval, waitDuration, pod, cmdCatCmdline...) @@ -102,14 +110,7 @@ var _ = ginkgo.Describe("[reboots][kernel_parameter_add_rm] Node Tuning Operator _, _, err = util.ExecAndLogCommand("oc", "create", "-n", ntoconfig.OperatorNamespace(), "-f", profileChild) gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // By creating the custom child profile, we will first see worker-rt MachineConfigPool UpdatedMachineCount drop to 0 first... - ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 0") - err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 0) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // ...and go up to 1 again next. - ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 1") - err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 1) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) + waitForMCPFlip() ginkgo.By(fmt.Sprintf("getting the current %s value in Pod %s", procCmdline, pod.Name)) cmdlineNew, err = util.WaitForCmdInPod(pollInterval, waitDuration, pod, cmdCatCmdline...) diff --git a/test/e2e/reboots/machine_config_labels.go b/test/e2e/reboots/machine_config_labels.go index 8d66f033cf..99f4fccfad 100644 --- a/test/e2e/reboots/machine_config_labels.go +++ b/test/e2e/reboots/machine_config_labels.go @@ -77,6 +77,11 @@ var _ = ginkgo.Describe("[reboots][machine_config_labels] Node Tuning Operator m _, _, err = util.ExecAndLogCommand("oc", "create", "-f", mcpRealtime) gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // By creating the custom child profile, we will first see worker-rt MachineConfigPool UpdatedMachineCount drop to 0 first... + ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 0") + err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 0) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // ...and go up to 1 again next. ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 1") err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 1) gomega.Expect(err).NotTo(gomega.HaveOccurred()) diff --git a/test/e2e/reboots/stalld.go b/test/e2e/reboots/stalld.go index 957bd160f8..aa1e7f9453 100644 --- a/test/e2e/reboots/stalld.go +++ b/test/e2e/reboots/stalld.go @@ -71,6 +71,11 @@ var _ = ginkgo.Describe("[reboots][stalld] Node Tuning Operator installing syste _, _, err = util.ExecAndLogCommand("oc", "create", "-f", mcpRealtime) gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // By creating the custom child profile, we will first see worker-rt MachineConfigPool UpdatedMachineCount drop to 0 first... + ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 0") + err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 0) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // ...and go up to 1 again next. ginkgo.By("waiting for worker-rt MachineConfigPool UpdatedMachineCount == 1") err = util.WaitForPoolUpdatedMachineCount(cs, "worker-rt", 1) gomega.Expect(err).NotTo(gomega.HaveOccurred())