Address review comments in maxDevices test
@@ -142,6 +142,7 @@ var _ = Describe("[Serial][sig-operator]Operator", func() {
deleteAllVMIs func([]*v1.VirtualMachineInstance)
verifyVMIsUpdated func([]*v1.VirtualMachineInstance, string)
verifyVMIsEvicted func([]*v1.VirtualMachineInstance)
+ fetchVirtHandlerCommand func() string
)
tests.BeforeAll(func() {
@@ -982,6 +983,17 @@ spec:
}
}
+
+ fetchVirtHandlerCommand = func() string {
+ virtHandler, err := virtClient.AppsV1().DaemonSets(flags.KubeVirtInstallNamespace).Get(context.Background(), "virt-handler", metav1.GetOptions{})
+ Expect(err).ToNot(HaveOccurred())
+
+ containers := virtHandler.Spec.Template.Spec.Containers
+ Expect(containers).ToNot(BeEmpty())
+
+ container := containers[0]
+ return strings.Join(container.Command, " ")
+ }
})
BeforeEach(func() {
@@ -1319,6 +1331,7 @@ spec:
It("test VirtualMachineInstancesPerNode", func() {
newVirtualMachineInstancesPerNode := 10
+ maxDevicesCommandArgument := fmt.Sprintf("--maxDevices %d", newVirtualMachineInstancesPerNode)
By("Updating KubeVirt Object")
kv, err := virtClient.KubeVirt(flags.KubeVirtInstallNamespace).Get(originalKv.Name, &metav1.GetOptions{})
@@ -1330,17 +1343,7 @@ spec:
Expect(err).ToNot(HaveOccurred())
By("Test that patch was applied to DaemonSet")
- Eventually(func() string {
- vc, err := virtClient.AppsV1().DaemonSets(flags.KubeVirtInstallNamespace).Get(context.Background(), "virt-handler", metav1.GetOptions{})
- Expect(err).ToNot(HaveOccurred())
-
- containers := vc.Spec.Template.Spec.Containers
- Expect(containers).ToNot(BeEmpty())
-
- container := containers[0]
-
- return strings.Join(container.Command, " ")
- }, 60*time.Second, 5*time.Second).Should(ContainSubstring(fmt.Sprintf("--maxDevices %d", newVirtualMachineInstancesPerNode)))
+ Eventually(fetchVirtHandlerCommand, 60*time.Second, 5*time.Second).Should(ContainSubstring(maxDevicesCommandArgument))
By("Deleting patch from KubeVirt object")
kv, err = virtClient.KubeVirt(flags.KubeVirtInstallNamespace).Get(originalKv.Name, &metav1.GetOptions{})
@@ -1351,17 +1354,7 @@ spec:
Expect(err).ToNot(HaveOccurred())
By("Test that patch was removed from DaemonSet")
- Eventually(func() string {
- vc, err := virtClient.AppsV1().DaemonSets(flags.KubeVirtInstallNamespace).Get(context.Background(), "virt-handler", metav1.GetOptions{})
- Expect(err).ToNot(HaveOccurred())
-
- containers := vc.Spec.Template.Spec.Containers
- Expect(containers).ToNot(BeEmpty())
-
- container := containers[0]
-
- return strings.Join(container.Command, " ")
- }, 60*time.Second, 5*time.Second).ShouldNot(ContainSubstring(fmt.Sprintf("--maxDevices %d", newVirtualMachineInstancesPerNode)))
+ Eventually(fetchVirtHandlerCommand, 60*time.Second, 5*time.Second).ShouldNot(ContainSubstring(maxDevicesCommandArgument))
})
})
