Skip to content

Commit

Permalink
Various changes in virt-launcher/virtwrap tests
Browse files Browse the repository at this point in the history
Small changes in test matchers.

Signed-off-by: Andrej Krejcir <[email protected]>
  • Loading branch information
akrejcir committed May 30, 2022
1 parent 8bfc967 commit 65310c6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ var _ = Describe("AccessCredentials", func() {
Expect(secretDirs[0]).To(Equal(fmt.Sprintf("%s/%s-access-cred", tmpDir, secretID)))

for _, dir := range secretDirs {
os.Mkdir(dir, 0755)
Expect(os.Mkdir(dir, 0755)).To(Succeed())
Expect(manager.watcher.Add(dir)).To(Succeed())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ var _ = Describe("Generic HostDevice", func() {
mdevPool := newAddressPoolStub()
mdevPool.AddResource(hostdevResource1, hostdevMDEVAddress1)

hostDevices, err := generic.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.HostDevices, pciPool, mdevPool)
Expect(err).NotTo(HaveOccurred())

hostPCIAddress := api.Address{Type: "pci", Domain: "0x0000", Bus: "0x81", Slot: "0x01", Function: "0x0"}
expectHostDevice0 := api.HostDevice{
Alias: api.NewUserDefinedAlias(generic.AliasPrefix + hostdevName0),
Expand All @@ -91,7 +88,8 @@ var _ = Describe("Generic HostDevice", func() {
Model: "vfio-pci",
}

Expect(hostDevices, err).To(Equal([]api.HostDevice{expectHostDevice0, expectHostDevice1}))
Expect(generic.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.HostDevices, pciPool, mdevPool)).
To(Equal([]api.HostDevice{expectHostDevice0, expectHostDevice1}))
})
})

Expand Down
24 changes: 8 additions & 16 deletions pkg/virt-launcher/virtwrap/device/hostdevice/gpu/hostdev_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ var _ = Describe("GPU HostDevice", func() {
mdevPool := newAddressPoolStub()
mdevPool.AddResource(gpuResource1, gpuMDEVAddress1)

hostDevices, err := gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)
Expect(err).NotTo(HaveOccurred())

hostPCIAddress := api.Address{Type: "pci", Domain: "0x0000", Bus: "0x81", Slot: "0x01", Function: "0x0"}
expectHostDevice0 := api.HostDevice{
Alias: api.NewUserDefinedAlias(gpu.AliasPrefix + gpuName0),
Expand All @@ -93,7 +90,8 @@ var _ = Describe("GPU HostDevice", func() {
RamFB: "on",
}

Expect(hostDevices, err).To(Equal([]api.HostDevice{expectHostDevice0, expectHostDevice1}))
Expect(gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)).
To(Equal([]api.HostDevice{expectHostDevice0, expectHostDevice1}))
})
It("creates MDEV with display option turned off", func() {
_false := false
Expand All @@ -113,9 +111,6 @@ var _ = Describe("GPU HostDevice", func() {
mdevPool := newAddressPoolStub()
mdevPool.AddResource(gpuResource1, gpuMDEVAddress1)

hostDevices, err := gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)
Expect(err).NotTo(HaveOccurred())

hostMDEVAddress := api.Address{UUID: gpuMDEVAddress1}
expectHostDevice1 := api.HostDevice{
Alias: api.NewUserDefinedAlias(gpu.AliasPrefix + gpuName1),
Expand All @@ -125,7 +120,8 @@ var _ = Describe("GPU HostDevice", func() {
Model: "vfio-pci",
}

Expect(hostDevices, err).To(Equal([]api.HostDevice{expectHostDevice1}))
Expect(gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)).
To(Equal([]api.HostDevice{expectHostDevice1}))
})
It("creates MDEV with display ramFB option turned off", func() {
_false := false
Expand All @@ -147,9 +143,6 @@ var _ = Describe("GPU HostDevice", func() {
mdevPool := newAddressPoolStub()
mdevPool.AddResource(gpuResource1, gpuMDEVAddress1)

hostDevices, err := gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)
Expect(err).NotTo(HaveOccurred())

hostMDEVAddress := api.Address{UUID: gpuMDEVAddress1}
expectHostDevice1 := api.HostDevice{
Alias: api.NewUserDefinedAlias(gpu.AliasPrefix + gpuName1),
Expand All @@ -160,7 +153,8 @@ var _ = Describe("GPU HostDevice", func() {
Display: "on",
}

Expect(hostDevices, err).To(Equal([]api.HostDevice{expectHostDevice1}))
Expect(gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)).
To(Equal([]api.HostDevice{expectHostDevice1}))
})
It("creates MDEV with enabled display and ramfb by default", func() {
vmi.Spec.Domain.Devices.GPUs = []v1.GPU{
Expand All @@ -177,9 +171,6 @@ var _ = Describe("GPU HostDevice", func() {
mdevPool := newAddressPoolStub()
mdevPool.AddResource(gpuResource1, gpuMDEVAddress1)

hostDevices, err := gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)
Expect(err).NotTo(HaveOccurred())

hostMDEVAddress := api.Address{UUID: gpuMDEVAddress1}
expectHostDevice1 := api.HostDevice{
Alias: api.NewUserDefinedAlias(gpu.AliasPrefix + gpuName1),
Expand All @@ -191,7 +182,8 @@ var _ = Describe("GPU HostDevice", func() {
RamFB: "on",
}

Expect(hostDevices, err).To(Equal([]api.HostDevice{expectHostDevice1}))
Expect(gpu.CreateHostDevicesFromPools(vmi.Spec.Domain.Devices.GPUs, pciPool, mdevPool)).
To(Equal([]api.HostDevice{expectHostDevice1}))
})
})

Expand Down
7 changes: 3 additions & 4 deletions pkg/virt-launcher/virtwrap/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2044,9 +2044,8 @@ var _ = Describe("Manager", func() {
// we need the non-typecast object to make the function we want to test available
libvirtmanager := manager.(*LibvirtDomainManager)

virtualMachineInstanceGuestAgentInfo, err := libvirtmanager.GetGuestInfo()
_, err := libvirtmanager.GetGuestInfo()
Expect(err).ToNot(HaveOccurred())
Expect(virtualMachineInstanceGuestAgentInfo).ToNot(BeNil())
})

It("executes GetUsers", func() {
Expand All @@ -2066,7 +2065,7 @@ var _ = Describe("Manager", func() {

virtualMachineInstanceGuestAgentInfo, err := libvirtmanager.GetUsers()
Expect(err).ToNot(HaveOccurred())
Expect(virtualMachineInstanceGuestAgentInfo).ToNot(BeNil())
Expect(virtualMachineInstanceGuestAgentInfo).ToNot(BeEmpty())
})

It("executes GetFilesystems", func() {
Expand All @@ -2088,7 +2087,7 @@ var _ = Describe("Manager", func() {

virtualMachineInstanceGuestAgentInfo, err := libvirtmanager.GetFilesystems()
Expect(err).ToNot(HaveOccurred())
Expect(virtualMachineInstanceGuestAgentInfo).ToNot(BeNil())
Expect(virtualMachineInstanceGuestAgentInfo).ToNot(BeEmpty())
})

It("executes generateCloudInitEmptyISO and succeeds", func() {
Expand Down
8 changes: 4 additions & 4 deletions pkg/virt-launcher/virtwrap/util/libvirt_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var _ = Describe("LibvirtHelper", func() {
//delete(entry, "timestamp")
loggedLines = append(loggedLines, entry)
}
Expect(scanner.Err()).To(Not(HaveOccurred()))
Expect(scanner.Err()).ToNot(HaveOccurred())

expectedLines := []map[string]string{}
scanner = bufio.NewScanner(strings.NewReader(formattedLogs))
Expand All @@ -160,7 +160,7 @@ var _ = Describe("LibvirtHelper", func() {
//delete(entry, "timestamp")
expectedLines = append(expectedLines, entry)
}
Expect(scanner.Err()).To(Not(HaveOccurred()))
Expect(scanner.Err()).ToNot(HaveOccurred())

Expect(loggedLines).To(Equal(expectedLines))
})
Expand All @@ -187,7 +187,7 @@ var _ = Describe("LibvirtHelper", func() {
delete(entry, "timestamp")
loggedLines = append(loggedLines, entry)
}
Expect(scanner.Err()).To(Not(HaveOccurred()))
Expect(scanner.Err()).ToNot(HaveOccurred())

expectedLines := []map[string]string{}
scanner = bufio.NewScanner(strings.NewReader(qemuFormattedLogs))
Expand All @@ -197,7 +197,7 @@ var _ = Describe("LibvirtHelper", func() {
delete(entry, "timestamp")
expectedLines = append(expectedLines, entry)
}
Expect(scanner.Err()).To(Not(HaveOccurred()))
Expect(scanner.Err()).ToNot(HaveOccurred())

Expect(loggedLines).To(Equal(expectedLines))
})
Expand Down

0 comments on commit 65310c6

Please sign in to comment.