Skip to content

Commit

Permalink
Add e2e test for reconciliation when status changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlguerrero12 committed Apr 18, 2024
1 parent deebe55 commit 2885578
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions test/conformance/tests/test_sriov_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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.
Expand All @@ -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",
Expand All @@ -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},
Expand Down

0 comments on commit 2885578

Please sign in to comment.