From 8bb6bdc7f2f43b94a3a341fa7cbba40541eb0736 Mon Sep 17 00:00:00 2001 From: Yossi Segev Date: Mon, 4 Mar 2019 12:26:24 +0200 Subject: [PATCH] Added more test attributes to expose_test.go, vmi_mulutus_test.go, vmi_networking_test.go --- tests/expose_test.go | 6 +- tests/vmi_multus_test.go | 672 ++++++++++++++++++----------------- tests/vmi_networking_test.go | 32 +- 3 files changed, 356 insertions(+), 354 deletions(-) diff --git a/tests/expose_test.go b/tests/expose_test.go index c9eed6a086fa..14fee0e68397 100644 --- a/tests/expose_test.go +++ b/tests/expose_test.go @@ -63,7 +63,7 @@ func waitForJobToCompleteWithStatus(virtClient *kubecli.KubevirtClient, jobPod * }, time.Duration(timeoutSec)*time.Second, 1*time.Second).Should(Equal(jobPodPhase)) } -var _ = Describe("Expose", func() { +var _ = Describe("[rfe_id:253][crit:medium][vendor:cnv-qe@redhat.com][level:component]Expose", func() { flag.Parse() @@ -71,7 +71,7 @@ var _ = Describe("Expose", func() { tests.PanicOnError(err) const testPort = 1500 - Context("[rfe_id:253][crit:medium][vendor:cnv-qe@redhat.com][level:component]Expose service on a VM", func() { + Context("Expose service on a VM", func() { var tcpVM *v1.VirtualMachineInstance tests.BeforeAll(func() { tcpVM = newLabeledVM("vm", virtClient) @@ -331,7 +331,7 @@ var _ = Describe("Expose", func() { }) }) - Context("[rfe_id:253][crit:high][vendor:cnv-qe@redhat.com][level:component]Expose a VM as a service.", func() { + Context("Expose a VM as a service.", func() { const servicePort = "27017" const serviceName = "cluster-ip-vm" var vm *v1.VirtualMachine diff --git a/tests/vmi_multus_test.go b/tests/vmi_multus_test.go index 724eee93ed3f..95b90f5ee29c 100644 --- a/tests/vmi_multus_test.go +++ b/tests/vmi_multus_test.go @@ -142,382 +142,384 @@ var _ = Describe("Multus", func() { Expect(result.Error()).NotTo(HaveOccurred()) }) - Context("VirtualMachineInstance with cni ptp plugin interface", func() { - AfterEach(func() { - virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Delete(detachedVMI.Name, &v13.DeleteOptions{}) - fmt.Printf("Waiting for vmi %s in %s namespace to be removed, this can take a while ...\n", detachedVMI.Name, tests.NamespaceTestDefault) - EventuallyWithOffset(1, func() bool { - return errors.IsNotFound(virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Delete(detachedVMI.Name, nil)) - }, 180*time.Second, 1*time.Second). - Should(BeTrue()) - }) + Describe("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]VirtualMachineInstance uisng different types of interfaces.", func() { + Context("VirtualMachineInstance with cni ptp plugin interface", func() { + AfterEach(func() { + virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Delete(detachedVMI.Name, &v13.DeleteOptions{}) + fmt.Printf("Waiting for vmi %s in %s namespace to be removed, this can take a while ...\n", detachedVMI.Name, tests.NamespaceTestDefault) + EventuallyWithOffset(1, func() bool { + return errors.IsNotFound(virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Delete(detachedVMI.Name, nil)) + }, 180*time.Second, 1*time.Second). + Should(BeTrue()) + }) - It("should create a virtual machine with one interface", func() { - By("checking virtual machine instance can ping 10.1.1.1 using ptp cni plugin") - detachedVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") - detachedVMI.Spec.Domain.Devices.Interfaces = []v1.Interface{{Name: "ptp", InterfaceBindingMethod: v1.InterfaceBindingMethod{Bridge: &v1.InterfaceBridge{}}}} - detachedVMI.Spec.Networks = []v1.Network{ - {Name: "ptp", NetworkSource: v1.NetworkSource{ - Multus: &v1.CniNetwork{NetworkName: "ptp-conf"}, - }}, - } - - _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(detachedVMI) - Expect(err).ToNot(HaveOccurred()) - tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter) - - pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ") - }) + It("[test_id:1751]should create a virtual machine with one interface", func() { + By("checking virtual machine instance can ping 10.1.1.1 using ptp cni plugin") + detachedVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") + detachedVMI.Spec.Domain.Devices.Interfaces = []v1.Interface{{Name: "ptp", InterfaceBindingMethod: v1.InterfaceBindingMethod{Bridge: &v1.InterfaceBridge{}}}} + detachedVMI.Spec.Networks = []v1.Network{ + {Name: "ptp", NetworkSource: v1.NetworkSource{ + Multus: &v1.CniNetwork{NetworkName: "ptp-conf"}, + }}, + } - It("should create a virtual machine with one interface with network definition from different namespace", func() { - By("checking virtual machine instance can ping 10.1.1.1 using ptp cni plugin") - detachedVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") - detachedVMI.Spec.Domain.Devices.Interfaces = []v1.Interface{{Name: "ptp", InterfaceBindingMethod: v1.InterfaceBindingMethod{Bridge: &v1.InterfaceBridge{}}}} - detachedVMI.Spec.Networks = []v1.Network{ - {Name: "ptp", NetworkSource: v1.NetworkSource{ - Multus: &v1.CniNetwork{NetworkName: fmt.Sprintf("%s/%s", tests.NamespaceTestAlternative, "ptp-conf-2")}, - }}, - } - - _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(detachedVMI) - Expect(err).ToNot(HaveOccurred()) - tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter) - - pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ") - }) + _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(detachedVMI) + Expect(err).ToNot(HaveOccurred()) + tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter) - It("should create a virtual machine with two interfaces", func() { - By("checking virtual machine instance can ping 10.1.1.1 using ptp cni plugin") - detachedVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") - - detachedVMI.Spec.Domain.Devices.Interfaces = []v1.Interface{ - defaultInterface, - {Name: "ptp", InterfaceBindingMethod: v1.InterfaceBindingMethod{Bridge: &v1.InterfaceBridge{}}}} - detachedVMI.Spec.Networks = []v1.Network{ - defaultNetwork, - {Name: "ptp", NetworkSource: v1.NetworkSource{ - Multus: &v1.CniNetwork{NetworkName: "ptp-conf"}, - }}, - } - - _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(detachedVMI) - Expect(err).ToNot(HaveOccurred()) - tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter) - - cmdCheck := "sudo /sbin/cirros-dhcpc up eth1 > /dev/null\n" - err = tests.CheckForTextExpecter(detachedVMI, []expect.Batcher{ - &expect.BSnd{S: "\n"}, - &expect.BExp{R: "\\$ "}, - &expect.BSnd{S: cmdCheck}, - &expect.BExp{R: "\\$ "}, - &expect.BSnd{S: "ip addr show eth1 | grep 10.1.1 | wc -l"}, - &expect.BExp{R: "1"}, - }, 15) - Expect(err).ToNot(HaveOccurred()) - - By("checking virtual machine instance has two interfaces") - checkInterface(detachedVMI, "eth0", "\\$ ") - checkInterface(detachedVMI, "eth1", "\\$ ") - - pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ") - }) - }) + pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ") + }) - Context("VirtualMachineInstance with sriov plugin interface", func() { - BeforeEach(func() { - tests.SkipIfNoSriovDevicePlugin(virtClient) - }) - AfterEach(func() { - deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne}) - }) + It("[test_id:1752]should create a virtual machine with one interface with network definition from different namespace", func() { + By("checking virtual machine instance can ping 10.1.1.1 using ptp cni plugin") + detachedVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") + detachedVMI.Spec.Domain.Devices.Interfaces = []v1.Interface{{Name: "ptp", InterfaceBindingMethod: v1.InterfaceBindingMethod{Bridge: &v1.InterfaceBridge{}}}} + detachedVMI.Spec.Networks = []v1.Network{ + {Name: "ptp", NetworkSource: v1.NetworkSource{ + Multus: &v1.CniNetwork{NetworkName: fmt.Sprintf("%s/%s", tests.NamespaceTestAlternative, "ptp-conf-2")}, + }}, + } + + _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(detachedVMI) + Expect(err).ToNot(HaveOccurred()) + tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter) + + pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ") + }) - It("should create a virtual machine with sriov interface", func() { - // since neither cirros nor alpine has drivers for Intel NICs, we are left with fedora - userData := "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n" - vmiOne = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userData) - tests.AddExplicitPodNetworkInterface(vmiOne) - - iface := v1.Interface{Name: "sriov", InterfaceBindingMethod: v1.InterfaceBindingMethod{SRIOV: &v1.InterfaceSRIOV{}}} - network := v1.Network{Name: "sriov", NetworkSource: v1.NetworkSource{Multus: &v1.CniNetwork{NetworkName: "sriov"}}} - vmiOne.Spec.Domain.Devices.Interfaces = append(vmiOne.Spec.Domain.Devices.Interfaces, iface) - vmiOne.Spec.Networks = append(vmiOne.Spec.Networks, network) - - // fedora requires some more memory to boot without kernel panics - vmiOne.Spec.Domain.Resources.Requests[k8sv1.ResourceName("memory")] = resource.MustParse("1024M") - - _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmiOne) - Expect(err).ToNot(HaveOccurred()) - tests.WaitUntilVMIReady(vmiOne, tests.LoggedInFedoraExpecter) - - By("checking KUBEVIRT_RESOURCE_NAME_ variable is defined in pod") - vmiPod := tests.GetRunningPodByVirtualMachineInstance(vmiOne, tests.NamespaceTestDefault) - out, err := tests.ExecuteCommandOnPod( - virtClient, - vmiPod, - "compute", - []string{"sh", "-c", "echo $KUBEVIRT_RESOURCE_NAME_sriov"}, - ) - Expect(err).ToNot(HaveOccurred()) - Expect(out).To(Equal("intel.com/sriov\n")) - - By("checking default interface is present") - _, err = tests.ExecuteCommandOnPod( - virtClient, - vmiPod, - "compute", - []string{"ip", "address", "show", "eth0"}, - ) - Expect(err).ToNot(HaveOccurred()) - - By("checking default interface is attached to VMI") - _, err = tests.ExecuteCommandOnPod( - virtClient, - vmiPod, - "compute", - []string{"ip", "address", "show", "k6t-eth0"}, - ) - Expect(err).ToNot(HaveOccurred()) - - By("checking virtual machine instance has two interfaces") - checkInterface(vmiOne, "eth0", "#") - checkInterface(vmiOne, "eth1", "#") - - // there is little we can do beyond just checking two devices are present: PCI slots are different inside - // the guest, and DP doesn't pass information about vendor IDs of allocated devices into the pod, so - // it's hard to match them. + It("[test_id:1753]should create a virtual machine with two interfaces", func() { + By("checking virtual machine instance can ping 10.1.1.1 using ptp cni plugin") + detachedVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") + + detachedVMI.Spec.Domain.Devices.Interfaces = []v1.Interface{ + defaultInterface, + {Name: "ptp", InterfaceBindingMethod: v1.InterfaceBindingMethod{Bridge: &v1.InterfaceBridge{}}}} + detachedVMI.Spec.Networks = []v1.Network{ + defaultNetwork, + {Name: "ptp", NetworkSource: v1.NetworkSource{ + Multus: &v1.CniNetwork{NetworkName: "ptp-conf"}, + }}, + } + + _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(detachedVMI) + Expect(err).ToNot(HaveOccurred()) + tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter) + + cmdCheck := "sudo /sbin/cirros-dhcpc up eth1 > /dev/null\n" + err = tests.CheckForTextExpecter(detachedVMI, []expect.Batcher{ + &expect.BSnd{S: "\n"}, + &expect.BExp{R: "\\$ "}, + &expect.BSnd{S: cmdCheck}, + &expect.BExp{R: "\\$ "}, + &expect.BSnd{S: "ip addr show eth1 | grep 10.1.1 | wc -l"}, + &expect.BExp{R: "1"}, + }, 15) + Expect(err).ToNot(HaveOccurred()) + + By("checking virtual machine instance has two interfaces") + checkInterface(detachedVMI, "eth0", "\\$ ") + checkInterface(detachedVMI, "eth1", "\\$ ") + + pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ") + }) }) - It("should create a virtual machine with two sriov interfaces referring the same resource", func() { - // since neither cirros nor alpine has drivers for Intel NICs, we are left with fedora - userData := "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n" - vmiOne = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userData) - tests.AddExplicitPodNetworkInterface(vmiOne) + Context("VirtualMachineInstance with sriov plugin interface", func() { + BeforeEach(func() { + tests.SkipIfNoSriovDevicePlugin(virtClient) + }) + AfterEach(func() { + deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne}) + }) + + It("[test_id:1754]should create a virtual machine with sriov interface", func() { + // since neither cirros nor alpine has drivers for Intel NICs, we are left with fedora + userData := "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n" + vmiOne = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userData) + tests.AddExplicitPodNetworkInterface(vmiOne) - for _, name := range []string{"sriov", "sriov2"} { - iface := v1.Interface{Name: name, InterfaceBindingMethod: v1.InterfaceBindingMethod{SRIOV: &v1.InterfaceSRIOV{}}} - network := v1.Network{Name: name, NetworkSource: v1.NetworkSource{Multus: &v1.CniNetwork{NetworkName: name}}} + iface := v1.Interface{Name: "sriov", InterfaceBindingMethod: v1.InterfaceBindingMethod{SRIOV: &v1.InterfaceSRIOV{}}} + network := v1.Network{Name: "sriov", NetworkSource: v1.NetworkSource{Multus: &v1.CniNetwork{NetworkName: "sriov"}}} vmiOne.Spec.Domain.Devices.Interfaces = append(vmiOne.Spec.Domain.Devices.Interfaces, iface) vmiOne.Spec.Networks = append(vmiOne.Spec.Networks, network) - } - // fedora requires some more memory to boot without kernel panics - vmiOne.Spec.Domain.Resources.Requests[k8sv1.ResourceName("memory")] = resource.MustParse("1024M") + // fedora requires some more memory to boot without kernel panics + vmiOne.Spec.Domain.Resources.Requests[k8sv1.ResourceName("memory")] = resource.MustParse("1024M") - _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmiOne) - Expect(err).ToNot(HaveOccurred()) - tests.WaitUntilVMIReady(vmiOne, tests.LoggedInFedoraExpecter) + _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmiOne) + Expect(err).ToNot(HaveOccurred()) + tests.WaitUntilVMIReady(vmiOne, tests.LoggedInFedoraExpecter) - By("checking KUBEVIRT_RESOURCE_NAME_ variables are defined in pod") - vmiPod := tests.GetRunningPodByVirtualMachineInstance(vmiOne, tests.NamespaceTestDefault) - for _, name := range []string{"sriov", "sriov"} { + By("checking KUBEVIRT_RESOURCE_NAME_ variable is defined in pod") + vmiPod := tests.GetRunningPodByVirtualMachineInstance(vmiOne, tests.NamespaceTestDefault) out, err := tests.ExecuteCommandOnPod( virtClient, vmiPod, "compute", - []string{"sh", "-c", fmt.Sprintf("echo $KUBEVIRT_RESOURCE_NAME_%s", name)}, + []string{"sh", "-c", "echo $KUBEVIRT_RESOURCE_NAME_sriov"}, ) Expect(err).ToNot(HaveOccurred()) Expect(out).To(Equal("intel.com/sriov\n")) - } - - By("checking default interface is present") - _, err = tests.ExecuteCommandOnPod( - virtClient, - vmiPod, - "compute", - []string{"ip", "address", "show", "eth0"}, - ) - Expect(err).ToNot(HaveOccurred()) - - By("checking default interface is attached to VMI") - _, err = tests.ExecuteCommandOnPod( - virtClient, - vmiPod, - "compute", - []string{"ip", "address", "show", "k6t-eth0"}, - ) - Expect(err).ToNot(HaveOccurred()) - - By("checking virtual machine instance has three interfaces") - checkInterface(vmiOne, "eth0", "#") - checkInterface(vmiOne, "eth1", "#") - checkInterface(vmiOne, "eth2", "#") - - // there is little we can do beyond just checking two devices are present: PCI slots are different inside - // the guest, and DP doesn't pass information about vendor IDs of allocated devices into the pod, so - // it's hard to match them. + + By("checking default interface is present") + _, err = tests.ExecuteCommandOnPod( + virtClient, + vmiPod, + "compute", + []string{"ip", "address", "show", "eth0"}, + ) + Expect(err).ToNot(HaveOccurred()) + + By("checking default interface is attached to VMI") + _, err = tests.ExecuteCommandOnPod( + virtClient, + vmiPod, + "compute", + []string{"ip", "address", "show", "k6t-eth0"}, + ) + Expect(err).ToNot(HaveOccurred()) + + By("checking virtual machine instance has two interfaces") + checkInterface(vmiOne, "eth0", "#") + checkInterface(vmiOne, "eth1", "#") + + // there is little we can do beyond just checking two devices are present: PCI slots are different inside + // the guest, and DP doesn't pass information about vendor IDs of allocated devices into the pod, so + // it's hard to match them. + }) + + It("[test_id:1755]should create a virtual machine with two sriov interfaces referring the same resource", func() { + // since neither cirros nor alpine has drivers for Intel NICs, we are left with fedora + userData := "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n" + vmiOne = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userData) + tests.AddExplicitPodNetworkInterface(vmiOne) + + for _, name := range []string{"sriov", "sriov2"} { + iface := v1.Interface{Name: name, InterfaceBindingMethod: v1.InterfaceBindingMethod{SRIOV: &v1.InterfaceSRIOV{}}} + network := v1.Network{Name: name, NetworkSource: v1.NetworkSource{Multus: &v1.CniNetwork{NetworkName: name}}} + vmiOne.Spec.Domain.Devices.Interfaces = append(vmiOne.Spec.Domain.Devices.Interfaces, iface) + vmiOne.Spec.Networks = append(vmiOne.Spec.Networks, network) + } + + // fedora requires some more memory to boot without kernel panics + vmiOne.Spec.Domain.Resources.Requests[k8sv1.ResourceName("memory")] = resource.MustParse("1024M") + + _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmiOne) + Expect(err).ToNot(HaveOccurred()) + tests.WaitUntilVMIReady(vmiOne, tests.LoggedInFedoraExpecter) + + By("checking KUBEVIRT_RESOURCE_NAME_ variables are defined in pod") + vmiPod := tests.GetRunningPodByVirtualMachineInstance(vmiOne, tests.NamespaceTestDefault) + for _, name := range []string{"sriov", "sriov"} { + out, err := tests.ExecuteCommandOnPod( + virtClient, + vmiPod, + "compute", + []string{"sh", "-c", fmt.Sprintf("echo $KUBEVIRT_RESOURCE_NAME_%s", name)}, + ) + Expect(err).ToNot(HaveOccurred()) + Expect(out).To(Equal("intel.com/sriov\n")) + } + + By("checking default interface is present") + _, err = tests.ExecuteCommandOnPod( + virtClient, + vmiPod, + "compute", + []string{"ip", "address", "show", "eth0"}, + ) + Expect(err).ToNot(HaveOccurred()) + + By("checking default interface is attached to VMI") + _, err = tests.ExecuteCommandOnPod( + virtClient, + vmiPod, + "compute", + []string{"ip", "address", "show", "k6t-eth0"}, + ) + Expect(err).ToNot(HaveOccurred()) + + By("checking virtual machine instance has three interfaces") + checkInterface(vmiOne, "eth0", "#") + checkInterface(vmiOne, "eth1", "#") + checkInterface(vmiOne, "eth2", "#") + + // there is little we can do beyond just checking two devices are present: PCI slots are different inside + // the guest, and DP doesn't pass information about vendor IDs of allocated devices into the pod, so + // it's hard to match them. + }) }) - }) - Context("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]VirtualMachineInstance with ovs-cni plugin interface", func() { - AfterEach(func() { - deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne, vmiTwo}) + Context("VirtualMachineInstance with ovs-cni plugin interface", func() { + AfterEach(func() { + deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne, vmiTwo}) + }) + + It("[test_id:1577]should create two virtual machines with one interface", func() { + By("checking virtual machine instance can ping the secondary virtual machine instance using ovs-cni plugin") + interfaces := []v1.Interface{ovsInterface} + networks := []v1.Network{ovsNetwork} + + vmiOne = createVMIOnNode(interfaces, networks) + vmiTwo = createVMIOnNode(interfaces, networks) + + tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) + tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) + + configInterface(vmiOne, "eth0", "10.1.1.1/24", "localhost:~#") + By("checking virtual machine interface eth0 state") + checkInterface(vmiOne, "eth0", "localhost:~#") + + configInterface(vmiTwo, "eth0", "10.1.1.2/24", "localhost:~#") + By("checking virtual machine interface eth0 state") + checkInterface(vmiTwo, "eth0", "localhost:~#") + + By("ping between virtual machines") + pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#") + }) + + It("[test_id:1578]should create two virtual machines with two interfaces", func() { + By("checking the first virtual machine instance can ping 10.1.1.2 using ovs-cni plugin") + interfaces := []v1.Interface{ + defaultInterface, + ovsInterface, + } + networks := []v1.Network{ + defaultNetwork, + ovsNetwork, + } + + vmiOne = createVMIOnNode(interfaces, networks) + vmiTwo = createVMIOnNode(interfaces, networks) + + tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) + tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) + + configInterface(vmiOne, "eth1", "10.1.1.1/24", "localhost:~#") + By("checking virtual machine interface eth1 state") + checkInterface(vmiOne, "eth1", "localhost:~#") + + configInterface(vmiTwo, "eth1", "10.1.1.2/24", "localhost:~#") + By("checking virtual machine interface eth1 state") + checkInterface(vmiTwo, "eth1", "localhost:~#") + + By("ping between virtual machines") + pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#") + }) }) - It("[test_id:1577]should create two virtual machines with one interface", func() { - By("checking virtual machine instance can ping the secondary virtual machine instance using ovs-cni plugin") + Context("VirtualMachineInstance with ovs-cni plugin interface and custom MAC address.", func() { interfaces := []v1.Interface{ovsInterface} networks := []v1.Network{ovsNetwork} + ovsIfIdx := 0 + customMacAddress := "50:00:00:00:90:0d" + + AfterEach(func() { + deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne, vmiTwo}) + }) - vmiOne = createVMIOnNode(interfaces, networks) - vmiTwo = createVMIOnNode(interfaces, networks) + It("[test_id:676]should configure valid custom MAC address on ovs-cni interface.", func() { + By("Creating a VM with ovs-cni network interface and default MAC address.") + vmiTwo = createVMIOnNode(interfaces, networks) + tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) + + By("Creating another VM with custom MAC address on its ovs-cni interface.") + interfaces[ovsIfIdx].MacAddress = customMacAddress + vmiOne = createVMIOnNode(interfaces, networks) + tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) + + By("Configuring static IP address to the ovs interface.") + configInterface(vmiOne, "eth0", "10.1.1.1/24", "localhost:~#") + configInterface(vmiTwo, "eth0", "10.1.1.2/24", "localhost:~#") + + By("Verifying the desired custom MAC is the one that were actually configured on the interface.") + ipLinkShow := fmt.Sprintf("ip link show eth0 | grep -i \"%s\" | wc -l\n", customMacAddress) + err = tests.CheckForTextExpecter(vmiOne, []expect.Batcher{ + &expect.BSnd{S: ipLinkShow}, + &expect.BExp{R: "1"}, + }, 15) + Expect(err).ToNot(HaveOccurred()) - tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) - tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) + By("Ping from the VM with the custom MAC to the other VM.") + pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#") + }) + }) + Context("Single VirtualMachineInstance with ovs-cni plugin interface", func() { + AfterEach(func() { + deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne}) + }) - configInterface(vmiOne, "eth0", "10.1.1.1/24", "localhost:~#") - By("checking virtual machine interface eth0 state") - checkInterface(vmiOne, "eth0", "localhost:~#") + It("[test_id:1756]should report all interfaces in Status", func() { + interfaces := []v1.Interface{ + defaultInterface, + ovsInterface, + } + networks := []v1.Network{ + defaultNetwork, + ovsNetwork, + } - configInterface(vmiTwo, "eth0", "10.1.1.2/24", "localhost:~#") - By("checking virtual machine interface eth0 state") - checkInterface(vmiTwo, "eth0", "localhost:~#") + vmiOne = createVMIOnNode(interfaces, networks) - By("ping between virtual machines") - pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#") - }) + tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) - It("[test_id:1578]should create two virtual machines with two interfaces", func() { - By("checking the first virtual machine instance can ping 10.1.1.2 using ovs-cni plugin") - interfaces := []v1.Interface{ - defaultInterface, - ovsInterface, - } - networks := []v1.Network{ - defaultNetwork, - ovsNetwork, - } - - vmiOne = createVMIOnNode(interfaces, networks) - vmiTwo = createVMIOnNode(interfaces, networks) - - tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) - tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) - - configInterface(vmiOne, "eth1", "10.1.1.1/24", "localhost:~#") - By("checking virtual machine interface eth1 state") - checkInterface(vmiOne, "eth1", "localhost:~#") - - configInterface(vmiTwo, "eth1", "10.1.1.2/24", "localhost:~#") - By("checking virtual machine interface eth1 state") - checkInterface(vmiTwo, "eth1", "localhost:~#") - - By("ping between virtual machines") - pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#") - }) - }) + updatedVmi, err := virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Get(vmiOne.ObjectMeta.Name, &metav1.GetOptions{}) + Expect(err).ToNot(HaveOccurred()) - Context("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]VirtualMachineInstance with ovs-cni plugin interface and custom MAC address.", func() { - interfaces := []v1.Interface{ovsInterface} - networks := []v1.Network{ovsNetwork} - ovsIfIdx := 0 - customMacAddress := "50:00:00:00:90:0d" + Expect(len(updatedVmi.Status.Interfaces)).To(Equal(2)) + interfacesByName := make(map[string]v1.VirtualMachineInstanceNetworkInterface) + for _, ifc := range updatedVmi.Status.Interfaces { + interfacesByName[ifc.Name] = ifc + } - AfterEach(func() { - deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne, vmiTwo}) + for _, network := range networks { + ifc, is_present := interfacesByName[network.Name] + Expect(is_present).To(BeTrue()) + Expect(ifc.MAC).To(Not(BeZero())) + } + Expect(interfacesByName["default"].MAC).To(Not(Equal(interfacesByName["ovs"].MAC))) + + err = tests.CheckForTextExpecter(updatedVmi, []expect.Batcher{ + &expect.BSnd{S: fmt.Sprintf("ip addr show eth0 | grep %s | wc -l", interfacesByName["default"].MAC)}, + &expect.BExp{R: "1"}, + }, 15) + err = tests.CheckForTextExpecter(updatedVmi, []expect.Batcher{ + &expect.BSnd{S: fmt.Sprintf("ip addr show eth1 | grep %s | wc -l", interfacesByName["ovs"].MAC)}, + &expect.BExp{R: "1"}, + }, 15) + }) }) - It("[test_id:676]should configure valid custom MAC address on ovs-cni interface.", func() { - By("Creating a VM with ovs-cni network interface and default MAC address.") - vmiTwo = createVMIOnNode(interfaces, networks) - tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) - - By("Creating another VM with custom MAC address on its ovs-cni interface.") - interfaces[ovsIfIdx].MacAddress = customMacAddress - vmiOne = createVMIOnNode(interfaces, networks) - tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) - - By("Configuring static IP address to the ovs interface.") - configInterface(vmiOne, "eth0", "10.1.1.1/24", "localhost:~#") - configInterface(vmiTwo, "eth0", "10.1.1.2/24", "localhost:~#") - - By("Verifying the desired custom MAC is the one that were actually configured on the interface.") - ipLinkShow := fmt.Sprintf("ip link show eth0 | grep -i \"%s\" | wc -l\n", customMacAddress) - err = tests.CheckForTextExpecter(vmiOne, []expect.Batcher{ - &expect.BSnd{S: ipLinkShow}, - &expect.BExp{R: "1"}, - }, 15) - Expect(err).ToNot(HaveOccurred()) - - By("Ping from the VM with the custom MAC to the other VM.") - pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#") - }) - }) - Context("Single VirtualMachineInstance with ovs-cni plugin interface", func() { - AfterEach(func() { - deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne}) - }) + Context("VirtualMachineInstance with invalid MAC addres", func() { + BeforeEach(func() { + tests.BeforeTestCleanup() + }) - It("should report all interfaces in Status", func() { - interfaces := []v1.Interface{ - defaultInterface, - ovsInterface, - } - networks := []v1.Network{ - defaultNetwork, - ovsNetwork, - } - - vmiOne = createVMIOnNode(interfaces, networks) - - tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) - - updatedVmi, err := virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Get(vmiOne.ObjectMeta.Name, &metav1.GetOptions{}) - Expect(err).ToNot(HaveOccurred()) - - Expect(len(updatedVmi.Status.Interfaces)).To(Equal(2)) - interfacesByName := make(map[string]v1.VirtualMachineInstanceNetworkInterface) - for _, ifc := range updatedVmi.Status.Interfaces { - interfacesByName[ifc.Name] = ifc - } - - for _, network := range networks { - ifc, is_present := interfacesByName[network.Name] - Expect(is_present).To(BeTrue()) - Expect(ifc.MAC).To(Not(BeZero())) - } - Expect(interfacesByName["default"].MAC).To(Not(Equal(interfacesByName["ovs"].MAC))) - - err = tests.CheckForTextExpecter(updatedVmi, []expect.Batcher{ - &expect.BSnd{S: fmt.Sprintf("ip addr show eth0 | grep %s | wc -l", interfacesByName["default"].MAC)}, - &expect.BExp{R: "1"}, - }, 15) - err = tests.CheckForTextExpecter(updatedVmi, []expect.Batcher{ - &expect.BSnd{S: fmt.Sprintf("ip addr show eth1 | grep %s | wc -l", interfacesByName["ovs"].MAC)}, - &expect.BExp{R: "1"}, - }, 15) - }) - }) + It("[test_id:1713]should failed to start with invalid MAC address", func() { + By("Start VMI") + ovsIfIdx := 1 - Context("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]VirtualMachineInstance with invalid MAC addres", func() { - BeforeEach(func() { - tests.BeforeTestCleanup() - }) + vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskAlpine), "#!/bin/bash\n") + vmi.Spec.Domain.Devices.Interfaces = []v1.Interface{ + defaultInterface, + ovsInterface, + } + vmi.Spec.Domain.Devices.Interfaces[ovsIfIdx].MacAddress = "de:00c:00c:00:00:de:abc" + + vmi.Spec.Networks = []v1.Network{ + defaultNetwork, + ovsNetwork, + } - It("[test_id:1713]should failed to start with invalid MAC address", func() { - By("Start VMI") - ovsIfIdx := 1 - - vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskAlpine), "#!/bin/bash\n") - vmi.Spec.Domain.Devices.Interfaces = []v1.Interface{ - defaultInterface, - ovsInterface, - } - vmi.Spec.Domain.Devices.Interfaces[ovsIfIdx].MacAddress = "de:00c:00c:00:00:de:abc" - - vmi.Spec.Networks = []v1.Network{ - defaultNetwork, - ovsNetwork, - } - - _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi) - Expect(err).To(HaveOccurred()) - testErr := err.(*errors.StatusError) - Expect(testErr.ErrStatus.Reason).To(BeEquivalentTo("Invalid")) + _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi) + Expect(err).To(HaveOccurred()) + testErr := err.(*errors.StatusError) + Expect(testErr.ErrStatus.Reason).To(BeEquivalentTo("Invalid")) + }) }) }) - Describe("VirtualMachineInstance definition", func() { + Describe("[rfe_id:1758][crit:medium][vendor:cnv-qe@redhat.com][level:component]VirtualMachineInstance definition", func() { Context("with quemu guest agent", func() { var agentVMI *v1.VirtualMachineInstance @@ -525,7 +527,7 @@ var _ = Describe("Multus", func() { deleteVMIs(virtClient, []*v1.VirtualMachineInstance{agentVMI}) }) - It("should report guest interfaces in VMI status", func() { + It("[test_id:1757] should report guest interfaces in VMI status", func() { interfaces := []v1.Interface{ defaultInterface, ovsInterface, diff --git a/tests/vmi_networking_test.go b/tests/vmi_networking_test.go index 605504232311..9753f1a79892 100644 --- a/tests/vmi_networking_test.go +++ b/tests/vmi_networking_test.go @@ -44,7 +44,7 @@ import ( "kubevirt.io/kubevirt/tests" ) -var _ = Describe("Networking", func() { +var _ = Describe("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]Networking", func() { flag.Parse() @@ -105,7 +105,7 @@ var _ = Describe("Networking", func() { ExpectWithOffset(1, strings.TrimSpace(output)).To(Equal(expectedValue)) } - Describe("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]Multiple virtual machines connectivity", func() { + Describe("Multiple virtual machines connectivity", func() { tests.BeforeAll(func() { tests.BeforeTestCleanup() @@ -362,7 +362,7 @@ var _ = Describe("Networking", func() { }) }) - Context("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]VirtualMachineInstance with default interface model", func() { + Context("VirtualMachineInstance with default interface model", func() { // Unless an explicit interface model is specified, the default interface model is virtio. It("[test_id:1550]should expose the right device type to the guest", func() { By("checking the device vendor in /sys/class") @@ -390,7 +390,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should expose the right device type to the guest", func() { + It("[test_id:1770]should expose the right device type to the guest", func() { By("checking the device vendor in /sys/class") // Create a machine with e1000 interface model e1000VMI := tests.NewRandomVMIWithe1000NetworkInterface() @@ -408,7 +408,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should configure custom MAC address", func() { + It("[test_id:1771]should configure custom MAC address", func() { By("checking eth0 MAC address") deadbeafVMI := tests.NewRandomVMIWithCustomMacAddress() _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(deadbeafVMI) @@ -424,7 +424,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should configure custom MAC address", func() { + It("[test_id:1772]should configure custom MAC address", func() { By("checking eth0 MAC address") beafdeadVMI := tests.NewRandomVMIWithCustomMacAddress() beafdeadVMI.Spec.Domain.Devices.Interfaces[0].MacAddress = "BE-AF-00-00-DE-AD" @@ -436,7 +436,7 @@ var _ = Describe("Networking", func() { }) }) - Context("[rfe_id:694][crit:medium][vendor:cnv-qe@redhat.com][level:component]VirtualMachineInstance with invalid MAC addres", func() { + Context("VirtualMachineInstance with invalid MAC addres", func() { BeforeEach(func() { tests.BeforeTestCleanup() }) @@ -457,7 +457,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should configure custom MAC address", func() { + It("[test_id:1773]should configure custom MAC address", func() { By("checking eth0 MAC address") deadbeafVMI := tests.NewRandomVMIWithSlirpInterfaceEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskAlpine), "#!/bin/bash\necho 'hello'\n", []v1.Port{}) deadbeafVMI.Spec.Domain.Devices.Interfaces[0].MacAddress = "de:ad:00:00:be:af" @@ -474,7 +474,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should not configure any external interfaces", func() { + It("[test_id:1774]should not configure any external interfaces", func() { By("checking loopback is the only guest interface") autoAttach := false detachedVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") @@ -493,7 +493,7 @@ var _ = Describe("Networking", func() { Expect(err).ToNot(HaveOccurred()) }) - It("should not request a tun device", func() { + It("[test_id:1775]should not request a tun device", func() { By("Creating random VirtualMachineInstance") autoAttach := false vmi := tests.NewRandomVMIWithEphemeralDisk(tests.ContainerDiskFor(tests.ContainerDiskAlpine)) @@ -554,7 +554,7 @@ var _ = Describe("Networking", func() { Expect(err).ToNot(HaveOccurred()) } - It("should configure custom Pci address", func() { + It("[test_id:1776]should configure custom Pci address", func() { By("checking eth0 Pci address") testVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") tests.AddExplicitPodNetworkInterface(testVMI) @@ -572,7 +572,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should disable learning on pod iface", func() { + It("[test_id:1777]should disable learning on pod iface", func() { By("checking learning flag") learningDisabledVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskAlpine), "#!/bin/bash\necho 'hello'\n") _, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(learningDisabledVMI) @@ -588,7 +588,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should offer extra dhcp options to pod iface", func() { + It("[test_id:1778]should offer extra dhcp options to pod iface", func() { userData := "#cloud-config\npassword: fedora\nchpasswd: { expire: False }\n" dhcpVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userData) tests.AddExplicitPodNetworkInterface(dhcpVMI) @@ -633,7 +633,7 @@ var _ = Describe("Networking", func() { BeforeEach(func() { tests.BeforeTestCleanup() }) - It("should have custom resolv.conf", func() { + It("[test_id:1779]should have custom resolv.conf", func() { userData := "#cloud-config\n" dnsVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), userData) @@ -674,7 +674,7 @@ var _ = Describe("Networking", func() { return vmi } - It("should allow regular network connection", func() { + It("[test_id:1780]should allow regular network connection", func() { By("creating two virtual machines") ports := []v1.Port{{Name: "http", Port: 8080}} serverVMI = masqueradeVMI(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n", ports) @@ -739,7 +739,7 @@ var _ = Describe("Networking", func() { tests.BeforeTestCleanup() }) - It("should get turned off for interfaces that serve dhcp", func() { + It("[test_id:1781]should get turned off for interfaces that serve dhcp", func() { vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskAlpine), "#!/bin/bash\necho") vmi.Spec.Domain.Resources.Requests[k8sv1.ResourceName("memory")] = resource.MustParse("1024M")