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.
vmi_lifecycle_test: use libvmi.NewCirros on most tests
A few tests (test_id:1627 test_id:1628 test_id:1630) seem to use vmis that are a bit more complex to define with libvmi, so fixing them is postponed to a future PR. Signed-off-by: Dan Kenigsberg <[email protected]>
- Loading branch information
1 parent
176bd73
commit 5247428
Showing
1 changed file
with
35 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -418,8 +418,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
|
||
Context("without k8s secret", func() { | ||
It("[test_id:1629][posneg:negative]should not be able to start virt-launcher pod", func() { | ||
userData := fmt.Sprintf("#!/bin/sh\n\necho 'hi'\n") | ||
vmi = tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), userData) | ||
vmi = libvmi.NewCirros() | ||
|
||
for _, volume := range vmi.Spec.Volumes { | ||
if volume.CloudInitNoCloud != nil { | ||
|
@@ -719,8 +718,8 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
BeforeEach(func() { | ||
|
||
// Schedule a vmi and make sure that virt-handler gets evicted from the node where the vmi was started | ||
vmi = tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "echo hi!") | ||
vmi, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi = libvmi.NewCirros() | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI successfully") | ||
|
||
// Ensure that the VMI is running. This is necessary to ensure that virt-handler is fully responsible for | ||
|
@@ -843,18 +842,18 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}) | ||
|
||
It("[test_id:1635]the vmi with tolerations should be scheduled", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
vmi.Spec.Tolerations = []k8sv1.Toleration{{Key: "test", Value: "123"}} | ||
addNodeAffinityToVMI(vmi, nodes.Items[0].Name) | ||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
}) | ||
|
||
It("[test_id:1636]the vmi without tolerations should not be scheduled", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
addNodeAffinityToVMI(vmi, nodes.Items[0].Name) | ||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
By("Waiting for the VirtualMachineInstance to be unschedulable") | ||
Eventually(func() string { | ||
|
@@ -880,9 +879,9 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}) | ||
|
||
It("[test_id:1637]the vmi with node affinity and no conflicts should be scheduled", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
addNodeAffinityToVMI(vmi, nodes.Items[0].Name) | ||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
curVMI, err := virtClient.VirtualMachineInstance(vmi.Namespace).Get(vmi.Name, &metav1.GetOptions{}) | ||
|
@@ -892,16 +891,16 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}) | ||
|
||
It("[test_id:1638]the vmi with node affinity and anti-pod affinity should not be scheduled", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
addNodeAffinityToVMI(vmi, nodes.Items[0].Name) | ||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
curVMI, err := virtClient.VirtualMachineInstance(vmi.Namespace).Get(vmi.Name, &metav1.GetOptions{}) | ||
Expect(err).ToNot(HaveOccurred(), "Should get VMI") | ||
Expect(curVMI.Status.NodeName).To(Equal(nodes.Items[0].Name), "VMI should run on the same node") | ||
|
||
vmiB := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmiB := libvmi.NewCirros() | ||
addNodeAffinityToVMI(vmiB, nodes.Items[0].Name) | ||
|
||
vmiB.Spec.Affinity.PodAntiAffinity = &k8sv1.PodAntiAffinity{ | ||
|
@@ -917,7 +916,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}, | ||
} | ||
|
||
_, err = virtClient.VirtualMachineInstance(vmiB.Namespace).Create(vmiB) | ||
vmiB, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmiB) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMIB") | ||
|
||
By("Waiting for the VirtualMachineInstance to be unschedulable") | ||
|
@@ -963,9 +962,9 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
config.CPUModel = defaultCPUModel | ||
tests.UpdateKubeVirtConfigValueAndWait(*config) | ||
|
||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
|
||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
curVMI, err := virtClient.VirtualMachineInstance(vmi.Namespace).Get(vmi.Name, &metav1.GetOptions{}) | ||
|
@@ -984,11 +983,11 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
config.CPUModel = defaultCPUModel | ||
tests.UpdateKubeVirtConfigValueAndWait(*config) | ||
|
||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
vmi.Spec.Domain.CPU = &v1.CPU{ | ||
Model: vmiCPUModel, | ||
} | ||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
|
||
|
@@ -999,8 +998,8 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}) | ||
|
||
It("[sig-compute][test_id:3201]should set cpu model to default when vmi does not have it set and default cpu model is not set", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi := libvmi.NewCirros() | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
|
||
tests.WaitForSuccessfulVMIStart(vmi) | ||
|
@@ -1120,13 +1119,13 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}) | ||
|
||
It("[test_id:1639]the vmi with cpu.model matching a nfd label on a node should be scheduled", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
vmi.Spec.Domain.CPU = &v1.CPU{ | ||
Cores: 1, | ||
Model: supportedCPU, | ||
} | ||
|
||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
|
||
|
@@ -1142,13 +1141,13 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
|
||
for _, label := range supportedKVMInfoFeature { | ||
fmt.Println("Using " + label) | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
features := enableHyperVInVMI(label) | ||
vmi.Spec.Domain.Features = &v1.Features{ | ||
Hyperv: &features, | ||
} | ||
|
||
_, err := virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err := virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
|
||
|
@@ -1159,14 +1158,14 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}) | ||
|
||
It("the vmi with EVMCS HyperV feature should have correct hyperv and cpu features auto filled", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
vmi.Spec.Domain.Features = &v1.Features{ | ||
Hyperv: &v1.FeatureHyperv{ | ||
EVMCS: &v1.FeatureState{}, | ||
}, | ||
} | ||
|
||
_, err := virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err := virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
|
||
vmi, err = virtClient.VirtualMachineInstance(vmi.Namespace).Get(vmi.Name, &metav1.GetOptions{}) | ||
|
@@ -1181,7 +1180,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}) | ||
|
||
It("[test_id:1640]the vmi with cpu.model that cannot match an nfd label on node should not be scheduled", func() { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
vmi.Spec.Domain.CPU = &v1.CPU{ | ||
Cores: 1, | ||
Model: "486", | ||
|
@@ -1190,7 +1189,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
//Make sure the vmi should try to be scheduled only on master node | ||
vmi.Spec.NodeSelector = map[string]string{"kubernetes.io/hostname": node.Name} | ||
|
||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
|
||
By("Waiting for the VirtualMachineInstance to be unschedulable") | ||
|
@@ -1209,7 +1208,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
It("[test_id:3202]the vmi with cpu.features matching nfd labels on a node should be scheduled", func() { | ||
|
||
By("adding a node-feature-discovery CPU model label to a node") | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
const featureToDisable = "fpu" | ||
|
||
featureToRequire := supportedFeatures[0] | ||
|
@@ -1233,7 +1232,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}, | ||
} | ||
|
||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
tests.WaitForSuccessfulVMIStart(vmi) | ||
}) | ||
|
@@ -1297,7 +1296,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
} | ||
|
||
supportedFeaturesAmongAllNodes := GetSupportedCPUFeaturesFromNodes(*nodes) | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
vmi.Spec.Domain.CPU = &v1.CPU{ | ||
Cores: 1, | ||
Features: []v1.CPUFeature{ | ||
|
@@ -1312,7 +1311,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
}, | ||
} | ||
|
||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
|
||
By("Waiting for the VirtualMachineInstance to be unschedulable") | ||
|
@@ -1330,7 +1329,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
|
||
It("[test_id:3204]the vmi with cpu.feature policy 'forbid' should not be scheduled on a node with that cpu feature label", func() { | ||
|
||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
vmi := libvmi.NewCirros() | ||
vmi.Spec.Domain.CPU = &v1.CPU{ | ||
Cores: 1, | ||
Features: []v1.CPUFeature{ | ||
|
@@ -1345,7 +1344,7 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
// the specific node - the feature policy 'forbid' will deny shceduling on that node. | ||
addNodeAffinityToVMI(vmi, node.Name) | ||
|
||
_, err = virtClient.VirtualMachineInstance(vmi.Namespace).Create(vmi) | ||
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
|
||
By("Waiting for the VirtualMachineInstance to be unschedulable") | ||
|
@@ -1709,14 +1708,14 @@ var _ = Describe("[rfe_id:273][crit:high][arm64][vendor:[email protected]][level | |
} | ||
|
||
By("Creating the VirtualMachineInstance") | ||
obj, err := virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
vmi, err := virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi) | ||
Expect(err).ToNot(HaveOccurred(), "Should create VMI") | ||
|
||
// wait until booted | ||
vmi = tests.WaitUntilVMIReady(vmi, console.LoginToCirros) | ||
|
||
By("Deleting the VirtualMachineInstance") | ||
Expect(virtClient.VirtualMachineInstance(vmi.Namespace).Delete(obj.Name, &metav1.DeleteOptions{})).To(Succeed(), "Should delete VMI") | ||
Expect(virtClient.VirtualMachineInstance(vmi.Namespace).Delete(vmi.Name, &metav1.DeleteOptions{})).To(Succeed(), "Should delete VMI") | ||
|
||
By("Verifying VirtualMachineInstance's status is Succeeded") | ||
Eventually(func() v1.VirtualMachineInstancePhase { | ||
|