Skip to content

Commit

Permalink
container_disk_test: reuse libvmi.New* and RunVMIAndExpectLaunch
Browse files Browse the repository at this point in the history
Using these functions makes the tests slightly shorter and clearer.
Simple replacement did not work in some of the tests, e.g test_id:1463,
did not work right away. I don't understand those tests and their
peculiar usage of objs on top of vmis so I leave their cleanup to a
future PR.

Signed-off-by: Dan Kenigsberg <danken@redhat.com>
  • Loading branch information
dankenigsberg committed Mar 3, 2022
1 parent d32ebad commit ca2686a
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions tests/container_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var _ = Describe("[rfe_id:588][crit:medium][vendor:cnv-qe@redhat.com][level:comp
Describe("[rfe_id:273][crit:medium][vendor:cnv-qe@redhat.com][level:component]Starting a VirtualMachineInstance", func() {
Context("with ephemeral registry disk", func() {
It("[test_id:1464]should not modify the spec on status update", func() {
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(cd.ContainerDiskFor(cd.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n")
vmi := libvmi.NewCirros()
v1.SetObjectDefaults_VirtualMachineInstance(vmi)

By("Starting the VirtualMachineInstance")
Expand All @@ -151,7 +151,7 @@ var _ = Describe("[rfe_id:588][crit:medium][vendor:cnv-qe@redhat.com][level:comp
Expect(err).To(BeNil())

By("Starting the VirtualMachineInstance")
vmi := tests.NewRandomVMIWithEphemeralDisk(cd.ContainerDiskFor(cd.ContainerDiskCirros))
vmi := libvmi.NewCirros()
_, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi)
Expect(err).To(BeNil())
By("Checking that the VMI failed")
Expand Down Expand Up @@ -201,9 +201,7 @@ var _ = Describe("[rfe_id:588][crit:medium][vendor:cnv-qe@redhat.com][level:comp
}
}
By("Starting the VirtualMachineInstance")
obj, err := virtClient.RestClient().Post().Resource("virtualmachineinstances").Namespace(util.NamespaceTestDefault).Body(vmi).Do(context.Background()).Get()
Expect(err).To(BeNil())
tests.WaitForSuccessfulVMIStart(obj)
vmi = tests.RunVMIAndExpectLaunch(vmi, 60)
})
})

Expand All @@ -212,13 +210,9 @@ var _ = Describe("[rfe_id:588][crit:medium][vendor:cnv-qe@redhat.com][level:comp
Describe("[rfe_id:273][crit:medium][vendor:cnv-qe@redhat.com][level:component]Starting with virtio-win", func() {
Context("with virtio-win as secondary disk", func() {
It("[test_id:1467]should boot and have the virtio as sata CDROM", func() {
vmi := tests.NewRandomVMIWithEphemeralDisk(cd.ContainerDiskFor(cd.ContainerDiskAlpine))
vmi := libvmi.NewAlpine()
tests.AddEphemeralCdrom(vmi, "disk4", "sata", cd.ContainerDiskFor(cd.ContainerDiskVirtio))

By("Starting the VirtualMachineInstance")
obj, err := virtClient.RestClient().Post().Resource("virtualmachineinstances").Namespace(util.NamespaceTestDefault).Body(vmi).Do(context.Background()).Get()
Expect(err).To(BeNil(), "expected vmi to start with no problem")
tests.WaitForSuccessfulVMIStart(obj)
vmi = tests.RunVMIAndExpectLaunch(vmi, 60)

By("Checking whether the second disk really contains virtio drivers")
Expect(console.LoginToAlpine(vmi)).To(Succeed(), "expected alpine to login properly")
Expand All @@ -243,12 +237,8 @@ var _ = Describe("[rfe_id:588][crit:medium][vendor:cnv-qe@redhat.com][level:comp
Describe("[rfe_id:4052][crit:high][arm64][vendor:cnv-qe@redhat.com][level:component]VMI disk permissions", func() {
Context("with ephemeral registry disk", func() {
It("[test_id:4299]should not have world write permissions", func() {
vmi := tests.NewRandomVMIWithEphemeralDisk(cd.ContainerDiskFor(cd.ContainerDiskAlpine))

By("Starting a New VMI")
vmi, err = virtClient.VirtualMachineInstance(util.NamespaceTestDefault).Create(vmi)
Expect(err).ToNot(HaveOccurred())
tests.WaitForSuccessfulVMIStart(vmi)
vmi := libvmi.NewAlpine()
vmi = tests.RunVMIAndExpectLaunch(vmi, 60)

By("Ensuring VMI is running by logging in")
tests.WaitUntilVMIReady(vmi, console.LoginToAlpine)
Expand Down

0 comments on commit ca2686a

Please sign in to comment.