Skip to content

Commit

Permalink
Apllying PR revieww comments:
Browse files Browse the repository at this point in the history
- Remove unnecessary package import aliases.
- Move new function from utils.go to vmi_networking_test.go
  • Loading branch information
yossisegev committed Jan 9, 2019
1 parent d7e17e6 commit ca1f1f9
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/vmi_networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,25 @@ var _ = Describe("Networking", func() {
})

Context("VirtualMachineInstance with default interface model", func() {
// Unless an explicit interface model is specified, the default interface model is virtio.
It("should expose the right device type to the guest", func() {
By("checking the device vendor in /sys/class")

// Taken from https://wiki.osdev.org/Virtio#Technical_Details
virtio_vid := "0x1af4"

for _, networkVMI := range []*v1.VirtualMachineInstance{inboundVMI, outboundVMI} {
// as defined in https://vendev.org/pci/ven_1af4/
checkNetworkVendor(networkVMI, "0x1af4", "\\$ ")
checkNetworkVendor(networkVMI, virtio_vid, "\\$ ")
}
})

It("should reject the creation of virtual machine with unsupported interface model", func() {
// Create a virtual machine with an unsupported interface model
customIfVMI := NewRandomVMIWithInvalidNetworkInterface()
_, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(customIfVMI)
Expect(err).To(HaveOccurred())
})
})
})

Expand Down Expand Up @@ -720,3 +732,11 @@ func waitUntilVMIReady(vmi *v1.VirtualMachineInstance, expecterFactory tests.VMI
expecter.Close()
return vmi
}

func NewRandomVMIWithInvalidNetworkInterface() *v1.VirtualMachineInstance {
// Use alpine because cirros dhcp client starts prematurily before link is ready
vmi := tests.NewRandomVMIWithEphemeralDisk(tests.ContainerDiskFor(tests.ContainerDiskAlpine))
tests.AddExplicitPodNetworkInterface(vmi)
vmi.Spec.Domain.Devices.Interfaces[0].Model = "gibberish"
return vmi
}

0 comments on commit ca1f1f9

Please sign in to comment.