diff --git a/test/conformance/tests/test_sriov_operator.go b/test/conformance/tests/test_sriov_operator.go index 55711b78f..094a95cf0 100644 --- a/test/conformance/tests/test_sriov_operator.go +++ b/test/conformance/tests/test_sriov_operator.go @@ -307,8 +307,12 @@ var _ = Describe("[sriov] operator", func() { node = sriovInfos.Nodes[0] createVanillaNetworkPolicy(node, sriovInfos, numVfs, resourceName) WaitForSRIOVStable() - sriovDevice, err = sriovInfos.FindOneSriovDevice(node) + + // Update info + sriovInfos, err = cluster.DiscoverSriov(clients, operatorNamespace) Expect(err).ToNot(HaveOccurred()) + sriovDevice = findInterface(sriovInfos, node) + By("Using device " + sriovDevice.Name + " on node " + node) Eventually(func() int64 { @@ -1000,6 +1004,44 @@ var _ = Describe("[sriov] operator", func() { return runningPodB.Status.Phase }, 3*time.Minute, time.Second).Should(Equal(corev1.PodRunning)) }) + + It("should reconcile managed VF if status changes", func() { + originalMtu := sriovDevice.Mtu + newMtu := 1000 + + By("manually changing the MTU") + _, errOutput, err := runCommandOnConfigDaemon(node, "/bin/bash", "-c", fmt.Sprintf("echo %d > /sys/bus/pci/devices/%s/net/%s/mtu", newMtu, sriovDevice.PciAddress, sriovDevice.Name)) + Expect(err).ToNot(HaveOccurred()) + Expect(errOutput).To(Equal("")) + + By("waiting for the mtu to be updated in the status") + Eventually(func() sriovv1.InterfaceExts { + nodeState, err := clients.SriovNetworkNodeStates(operatorNamespace).Get(context.Background(), node, metav1.GetOptions{}) + Expect(err).ToNot(HaveOccurred()) + return nodeState.Status.Interfaces + }, 3*time.Minute, 1*time.Second).Should(ContainElement(MatchFields( + IgnoreExtras, + Fields{ + "Name": Equal(sriovDevice.Name), + "Mtu": Equal(newMtu), + "PciAddress": Equal(sriovDevice.PciAddress), + "NumVfs": Equal(sriovDevice.NumVfs), + }))) + + By("waiting for the mtu to be restored") + Eventually(func() sriovv1.InterfaceExts { + nodeState, err := clients.SriovNetworkNodeStates(operatorNamespace).Get(context.Background(), node, metav1.GetOptions{}) + Expect(err).ToNot(HaveOccurred()) + return nodeState.Status.Interfaces + }, 3*time.Minute, 1*time.Second).Should(ContainElement(MatchFields( + IgnoreExtras, + Fields{ + "Name": Equal(sriovDevice.Name), + "Mtu": Equal(originalMtu), + "PciAddress": Equal(sriovDevice.PciAddress), + "NumVfs": Equal(sriovDevice.NumVfs), + }))) + }) }) Context("CNI Logging level", func() { @@ -2486,8 +2528,7 @@ func WaitForSRIOVStable() { }, waitingTime, 1*time.Second).Should(BeTrue()) } -func createVanillaNetworkPolicy(node string, sriovInfos *cluster.EnabledNodes, numVfs int, resourceName string) { - // For the context of tests is better to use a Mellanox card +func findInterface(sriovInfos *cluster.EnabledNodes, node string) *sriovv1.InterfaceExt { // For the context of tests is better to use a Mellanox card // as they support all the virtual function flags // if we don't find a Mellanox card we fall back to any sriov // capability interface and skip the rate limit test. @@ -2497,6 +2538,12 @@ func createVanillaNetworkPolicy(node string, sriovInfos *cluster.EnabledNodes, n Expect(err).ToNot(HaveOccurred()) } + return intf +} + +func createVanillaNetworkPolicy(node string, sriovInfos *cluster.EnabledNodes, numVfs int, resourceName string) { + intf := findInterface(sriovInfos, node) + config := &sriovv1.SriovNetworkNodePolicy{ ObjectMeta: metav1.ObjectMeta{ GenerateName: "test-policy", @@ -2509,6 +2556,7 @@ func createVanillaNetworkPolicy(node string, sriovInfos *cluster.EnabledNodes, n }, NumVfs: numVfs, ResourceName: resourceName, + Mtu: 1500, Priority: 99, NicSelector: sriovv1.SriovNetworkNicSelector{ PfNames: []string{intf.Name},