forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubevirt#2199 from rmohr/prow-preparations
Prepare automation test script for prow
- Loading branch information
Showing
8 changed files
with
54 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ import ( | |
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
k8sv1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
v1 "kubevirt.io/kubevirt/pkg/api/v1" | ||
|
@@ -431,6 +432,9 @@ var _ = Describe("[rfe_id:253][crit:medium][vendor:[email protected]][level:comp | |
By("Verifying the VMI is back up AFTER restart (in Running status with new UID).") | ||
Eventually(func() bool { | ||
vmi, err = virtClient.VirtualMachineInstance(vmObj.Namespace).Get(vmObj.Name, &k8smetav1.GetOptions{}) | ||
if errors.IsNotFound(err) { | ||
return false | ||
} | ||
Expect(err).ToNot(HaveOccurred()) | ||
vmiUIdAfterRestart := vmi.GetObjectMeta().GetUID() | ||
newUId := (vmiUIdAfterRestart != vmiUIdBeforeRestart) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,6 @@ var _ = Describe("Multus", func() { | |
virtClient, err := kubecli.GetKubevirtClient() | ||
tests.PanicOnError(err) | ||
|
||
var detachedVMI *v1.VirtualMachineInstance | ||
var vmiOne *v1.VirtualMachineInstance | ||
var vmiTwo *v1.VirtualMachineInstance | ||
var nodes *k8sv1.NodeList | ||
|
||
defaultInterface := v1.Interface{ | ||
|
@@ -90,6 +87,19 @@ var _ = Describe("Multus", func() { | |
}, | ||
} | ||
|
||
AfterEach(func() { | ||
// Multus tests need to ensure that old VMIs are gone | ||
Expect(virtClient.RestClient().Delete().Namespace(tests.NamespaceTestDefault).Resource("virtualmachineinstances").Do().Error()).To(Succeed()) | ||
Expect(virtClient.RestClient().Delete().Namespace(tests.NamespaceTestAlternative).Resource("virtualmachineinstances").Do().Error()).To(Succeed()) | ||
Eventually(func() int { | ||
list1, err := virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).List(&v13.ListOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
list2, err := virtClient.VirtualMachineInstance(tests.NamespaceTestAlternative).List(&v13.ListOptions{}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
return len(list1.Items) + len(list2.Items) | ||
}, 180*time.Second, 1*time.Second).Should(BeZero()) | ||
}) | ||
|
||
createVMIOnNode := func(interfaces []v1.Interface, networks []v1.Network) *v1.VirtualMachineInstance { | ||
vmi := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskAlpine), "#!/bin/bash\n") | ||
vmi.Spec.Domain.Devices.Interfaces = interfaces | ||
|
@@ -155,18 +165,10 @@ var _ = Describe("Multus", func() { | |
|
||
Describe("[rfe_id:694][crit:medium][vendor:[email protected]][level:component]VirtualMachineInstance using 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("[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 := 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{ | ||
|
@@ -183,7 +185,7 @@ var _ = Describe("Multus", func() { | |
|
||
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 := 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{ | ||
|
@@ -200,7 +202,7 @@ var _ = Describe("Multus", func() { | |
|
||
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 := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
|
||
detachedVMI.Spec.Domain.Devices.Interfaces = []v1.Interface{ | ||
defaultInterface, | ||
|
@@ -236,17 +238,9 @@ var _ = Describe("Multus", func() { | |
}) | ||
|
||
Context("VirtualMachineInstance with multus network as default network", 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 with multus default network definition", func() { | ||
detachedVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n") | ||
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{ | ||
|
@@ -281,9 +275,6 @@ var _ = Describe("Multus", func() { | |
}) | ||
|
||
Context("VirtualMachineInstance with cni ptp plugin interface with custom MAC address", func() { | ||
AfterEach(func() { | ||
deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne}) | ||
}) | ||
|
||
table.DescribeTable("configure valid custom MAC address on ptp interface", func(networkName string) { | ||
customMacAddress := "50:00:00:00:90:0d" | ||
|
@@ -307,7 +298,7 @@ var _ = Describe("Multus", func() { | |
|
||
By("Creating a VM with custom MAC address on its ptp interface.") | ||
interfaces[0].MacAddress = customMacAddress | ||
vmiOne = createVMIOnNode(interfaces, networks) | ||
vmiOne := createVMIOnNode(interfaces, networks) | ||
tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) | ||
|
||
By("Configuring static IP address to ptp interface.") | ||
|
@@ -341,14 +332,11 @@ var _ = Describe("Multus", 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) | ||
vmiOne := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userData) | ||
tests.AddExplicitPodNetworkInterface(vmiOne) | ||
|
||
iface := v1.Interface{Name: "sriov", InterfaceBindingMethod: v1.InterfaceBindingMethod{SRIOV: &v1.InterfaceSRIOV{}}} | ||
|
@@ -404,7 +392,7 @@ var _ = Describe("Multus", func() { | |
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) | ||
vmiOne := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userData) | ||
tests.AddExplicitPodNetworkInterface(vmiOne) | ||
|
||
for _, name := range []string{"sriov", "sriov2"} { | ||
|
@@ -464,17 +452,14 @@ var _ = Describe("Multus", func() { | |
}) | ||
|
||
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) | ||
vmiOne := createVMIOnNode(interfaces, networks) | ||
vmiTwo := createVMIOnNode(interfaces, networks) | ||
|
||
tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) | ||
tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) | ||
|
@@ -502,8 +487,8 @@ var _ = Describe("Multus", func() { | |
ovsNetwork, | ||
} | ||
|
||
vmiOne = createVMIOnNode(interfaces, networks) | ||
vmiTwo = createVMIOnNode(interfaces, networks) | ||
vmiOne := createVMIOnNode(interfaces, networks) | ||
vmiTwo := createVMIOnNode(interfaces, networks) | ||
|
||
tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) | ||
tests.WaitUntilVMIReady(vmiTwo, tests.LoggedInAlpineExpecter) | ||
|
@@ -527,18 +512,14 @@ var _ = Describe("Multus", func() { | |
ovsIfIdx := 0 | ||
customMacAddress := "50:00:00:00:90:0d" | ||
|
||
AfterEach(func() { | ||
deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne, vmiTwo}) | ||
}) | ||
|
||
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) | ||
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) | ||
vmiOne := createVMIOnNode(interfaces, networks) | ||
tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) | ||
|
||
By("Configuring static IP address to the ovs interface.") | ||
|
@@ -569,9 +550,6 @@ var _ = Describe("Multus", func() { | |
}) | ||
}) | ||
Context("Single VirtualMachineInstance with ovs-cni plugin interface", func() { | ||
AfterEach(func() { | ||
deleteVMIs(virtClient, []*v1.VirtualMachineInstance{vmiOne}) | ||
}) | ||
|
||
It("[test_id:1756]should report all interfaces in Status", func() { | ||
interfaces := []v1.Interface{ | ||
|
@@ -583,7 +561,7 @@ var _ = Describe("Multus", func() { | |
ovsNetwork, | ||
} | ||
|
||
vmiOne = createVMIOnNode(interfaces, networks) | ||
vmiOne := createVMIOnNode(interfaces, networks) | ||
|
||
tests.WaitUntilVMIReady(vmiOne, tests.LoggedInAlpineExpecter) | ||
|
||
|
@@ -645,11 +623,6 @@ var _ = Describe("Multus", func() { | |
|
||
Describe("[rfe_id:1758][crit:medium][vendor:[email protected]][level:component]VirtualMachineInstance definition", func() { | ||
Context("with quemu guest agent", func() { | ||
var agentVMI *v1.VirtualMachineInstance | ||
|
||
AfterEach(func() { | ||
deleteVMIs(virtClient, []*v1.VirtualMachineInstance{agentVMI}) | ||
}) | ||
|
||
It("[test_id:1757] should report guest interfaces in VMI status", func() { | ||
interfaces := []v1.Interface{ | ||
|
@@ -665,16 +638,20 @@ var _ = Describe("Multus", func() { | |
ep2Ip := "1.0.0.11/24" | ||
ep1IpV6 := "fe80::ce3d:82ff:fe52:24c0/64" | ||
ep2IpV6 := "fe80::ce3d:82ff:fe52:24c1/64" | ||
agentVMI = tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), fmt.Sprintf(`#!/bin/bash | ||
echo "fedora" |passwd fedora --stdin | ||
ip link add ep1 type veth peer name ep2 | ||
ip addr add %s dev ep1 | ||
userdata := fmt.Sprintf(`#!/bin/bash | ||
echo "fedora" |passwd fedora --stdin | ||
setenforce 0 | ||
ip link add ep1 type veth peer name ep2 | ||
ip addr add %s dev ep1 | ||
ip addr add %s dev ep2 | ||
ip addr add %s dev ep1 | ||
ip addr add %s dev ep2 | ||
yum install -y qemu-guest-agent | ||
systemctl start qemu-guest-agent | ||
`, ep1Ip, ep2Ip, ep1IpV6, ep2IpV6)) | ||
mkdir -p /usr/local/bin | ||
curl %s > /usr/local/bin/qemu-ga | ||
chmod +x /usr/local/bin/qemu-ga | ||
systemd-run --unit=guestagent /usr/local/bin/qemu-ga | ||
`, ep1Ip, ep2Ip, ep1IpV6, ep2IpV6, tests.GuestAgentHttpUrl) | ||
agentVMI := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskFedora), userdata) | ||
|
||
agentVMI.Spec.Domain.Devices.Interfaces = interfaces | ||
agentVMI.Spec.Networks = networks | ||
|
@@ -733,17 +710,6 @@ var _ = Describe("Multus", func() { | |
}) | ||
}) | ||
|
||
func deleteVMIs(virtClient kubecli.KubevirtClient, vmis []*v1.VirtualMachineInstance) { | ||
for _, deleteVMI := range vmis { | ||
virtClient.VirtualMachineInstance("default").Delete(deleteVMI.Name, &v13.DeleteOptions{}) | ||
fmt.Printf("Waiting for vmi %s in %s namespace to be removed, this can take a while ...\n", deleteVMI.Name, tests.NamespaceTestDefault) | ||
EventuallyWithOffset(1, func() bool { | ||
return errors.IsNotFound(virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Delete(deleteVMI.Name, nil)) | ||
}, 180*time.Second, 1*time.Second). | ||
Should(BeTrue()) | ||
} | ||
} | ||
|
||
func configInterface(vmi *v1.VirtualMachineInstance, interfaceName, interfaceAddress, prompt string) { | ||
cmdCheck := fmt.Sprintf("ip addr add %s dev %s\n", interfaceAddress, interfaceName) | ||
err := tests.CheckForTextExpecter(vmi, []expect.Batcher{ | ||
|