Skip to content

Commit

Permalink
hotplug, e2e: cleanup leftovers
Browse files Browse the repository at this point in the history
Signed-off-by: Alona Paz <alkaplan@redhat.com>
  • Loading branch information
AlonaKaplan committed Jun 21, 2023
1 parent 4f73da2 commit 7e8a7dd
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions tests/network/hotplug.go
Expand Up @@ -77,26 +77,23 @@ var _ = SIGDescribe("nic-hotplug", func() {
hotPluggedVM = newVMWithOneInterface()
var err error
hotPluggedVM, err = kubevirt.Client().VirtualMachine(testsuite.GetTestNamespace(nil)).Create(context.Background(), hotPluggedVM)
ExpectWithOffset(1, err).NotTo(HaveOccurred())
EventuallyWithOffset(1, func() error {
Expect(err).NotTo(HaveOccurred())
Eventually(func() error {
var err error
hotPluggedVMI, err = kubevirt.Client().VirtualMachineInstance(testsuite.GetTestNamespace(nil)).Get(context.Background(), hotPluggedVM.GetName(), &metav1.GetOptions{})
return err
}, 120*time.Second, 1*time.Second).ShouldNot(HaveOccurred())
libwait.WaitUntilVMIReady(hotPluggedVMI, console.LoginToAlpine)

By("Creating a NAD")
ExpectWithOffset(1,
createBridgeNetworkAttachmentDefinition(testsuite.GetTestNamespace(nil), networkName, linuxBridgeName),
).To(Succeed())
Expect(createBridgeNetworkAttachmentDefinition(testsuite.GetTestNamespace(nil), networkName, linuxBridgeName)).To(Succeed())

By("Hotplugging an interface to the VM")
ExpectWithOffset(1,
kubevirt.Client().VirtualMachine(hotPluggedVM.GetNamespace()).AddInterface(
context.Background(),
hotPluggedVM.GetName(),
addIfaceOptions(networkName, ifaceName),
),
Expect(kubevirt.Client().VirtualMachine(hotPluggedVM.GetNamespace()).AddInterface(
context.Background(),
hotPluggedVM.GetName(),
addIfaceOptions(networkName, ifaceName),
),
).To(Succeed())
})

Expand Down Expand Up @@ -430,7 +427,7 @@ func verifyDynamicInterfaceChange(vmi *v1.VirtualMachineInstance, plugMethod hot
}

vmi, err := kubevirt.Client().VirtualMachineInstance(vmi.GetNamespace()).Get(context.Background(), vmi.GetName(), &metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
ExpectWithOffset(1, err).NotTo(HaveOccurred())

nonAbsentIfaces := vmispec.FilterInterfacesSpec(vmi.Spec.Domain.Devices.Interfaces, func(iface v1.Interface) bool {
return iface.State != v1.InterfaceStateAbsent
Expand All @@ -440,7 +437,7 @@ func verifyDynamicInterfaceChange(vmi *v1.VirtualMachineInstance, plugMethod hot
for _, net := range vmispec.FilterMultusNonDefaultNetworks(nonAbsentNets) {
secondaryNetworksNames = append(secondaryNetworksNames, net.Name)
}
Expect(secondaryNetworksNames).NotTo(BeEmpty())
ExpectWithOffset(1, secondaryNetworksNames).NotTo(BeEmpty())
EventuallyWithOffset(1, func() []v1.VirtualMachineInstanceNetworkInterface {
return cleanMACAddressesFromStatus(vmiCurrentInterfaces(vmi.GetNamespace(), vmi.GetName()))
}, 30*time.Second).Should(
Expand Down Expand Up @@ -536,13 +533,6 @@ func interfaceStatusFromInterfaceNames(ifaceNames ...string) []v1.VirtualMachine
return ifaceStatus
}

func filterVMISyncErrorEvents(events []corev1.Event) []string {
const desiredEvent = "SyncFailed"
return filterEvents(events, func(event corev1.Event) bool {
return event.Reason == desiredEvent
})
}

func filterEvents(events []corev1.Event, p func(event corev1.Event) bool) []string {
var eventMsgs []string
for _, event := range events {
Expand All @@ -553,10 +543,6 @@ func filterEvents(events []corev1.Event, p func(event corev1.Event) bool) []stri
return eventMsgs
}

func noPCISlotsAvailableError() string {
return "server error. command SyncVMI failed: \"LibvirtError(Code=1, Domain=20, Message='internal error: No more available PCI slots')\""
}

func newVMWithOneInterface() *v1.VirtualMachine {
vm := tests.NewRandomVirtualMachine(libvmi.NewAlpineWithTestTooling(), true)
vm.Spec.Template.Spec.Networks = []v1.Network{*v1.DefaultPodNetwork()}
Expand Down

0 comments on commit 7e8a7dd

Please sign in to comment.