forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubevirt#2054 from tareqalayan/fix-issue-2048
don't depend on hard-coded names for node
- Loading branch information
Showing
2 changed files
with
39 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1121,13 +1121,32 @@ var _ = Describe("Configurations", func() { | |
}) | ||
Describe("[rfe_id:897][crit:medium][vendor:[email protected]][level:component]VirtualMachineInstance with CPU pinning", func() { | ||
var nodes *kubev1.NodeList | ||
|
||
isNodeHasCPUManagerLabel := func(nodeName string) bool { | ||
Expect(nodeName).ToNot(BeEmpty()) | ||
|
||
nodeObject, err := virtClient.CoreV1().Nodes().Get(nodeName, metav1.GetOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
nodeHaveCpuManagerLabel := false | ||
nodeLabels := nodeObject.GetLabels() | ||
|
||
for label, val := range nodeLabels { | ||
if label == v1.CPUManager && val == "true" { | ||
nodeHaveCpuManagerLabel = true | ||
break | ||
} | ||
} | ||
return nodeHaveCpuManagerLabel | ||
} | ||
|
||
BeforeEach(func() { | ||
nodes, err = virtClient.CoreV1().Nodes().List(metav1.ListOptions{}) | ||
tests.PanicOnError(err) | ||
if len(nodes.Items) == 1 { | ||
Skip("Skip cpu pinning test that requires multiple nodes when only one node is present.") | ||
} | ||
}) | ||
|
||
Context("with cpu pinning enabled", func() { | ||
It("[test_id:1684]should set the cpumanager label to false when it's not running", func() { | ||
|
||
|
@@ -1170,11 +1189,13 @@ var _ = Describe("Configurations", func() { | |
kubev1.ResourceMemory: resource.MustParse("64M"), | ||
}, | ||
} | ||
|
||
By("Starting a VirtualMachineInstance") | ||
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(cpuVmi) | ||
Expect(err).ToNot(HaveOccurred()) | ||
node := tests.WaitForSuccessfulVMIStart(cpuVmi) | ||
Expect(node).NotTo(ContainSubstring("node01")) | ||
|
||
Expect(isNodeHasCPUManagerLabel(node)).To(BeTrue()) | ||
|
||
By("Checking that the pod QOS is guaranteed") | ||
readyPod := tests.GetRunningPodByVirtualMachineInstance(cpuVmi, tests.NamespaceTestDefault) | ||
|
@@ -1234,7 +1255,7 @@ var _ = Describe("Configurations", func() { | |
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(cpuVmi) | ||
Expect(err).ToNot(HaveOccurred()) | ||
node := tests.WaitForSuccessfulVMIStart(cpuVmi) | ||
Expect(node).NotTo(ContainSubstring("node01")) | ||
Expect(isNodeHasCPUManagerLabel(node)).To(BeTrue()) | ||
|
||
By("Expecting the VirtualMachineInstance console") | ||
expecter, err := tests.LoggedInCirrosExpecter(cpuVmi) | ||
|
@@ -1322,13 +1343,13 @@ var _ = Describe("Configurations", func() { | |
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(cpuVmi) | ||
Expect(err).ToNot(HaveOccurred()) | ||
node := tests.WaitForSuccessfulVMIStart(cpuVmi) | ||
Expect(node).To(ContainSubstring("node02")) | ||
Expect(isNodeHasCPUManagerLabel(node)).To(BeTrue()) | ||
|
||
By("Starting a VirtualMachineInstance without dedicated cpus") | ||
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(Vmi) | ||
Expect(err).ToNot(HaveOccurred()) | ||
node1 := tests.WaitForSuccessfulVMIStart(Vmi) | ||
Expect(node1).To(ContainSubstring("node02")) | ||
node = tests.WaitForSuccessfulVMIStart(cpuVmi) | ||
Expect(isNodeHasCPUManagerLabel(node)).To(BeTrue()) | ||
}) | ||
}) | ||
}) | ||
|