Skip to content

Commit

Permalink
Address review comments in maxDevices test
Browse files Browse the repository at this point in the history
Signed-off-by: Zvi Cahana <zvic@il.ibm.com>
  • Loading branch information
zcahana committed Dec 21, 2021
1 parent d4cd2e6 commit 055c44a
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions tests/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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{})
Expand All @@ -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{})
Expand All @@ -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))
})
})

Expand Down

0 comments on commit 055c44a

Please sign in to comment.