Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cnf network: fix test issues #372

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions tests/cnf/core/network/sriov/tests/metricsExporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var _ = Describe("SriovMetricsExporter", Ordered, Label(tsparams.LabelSriovMetri
workerNodeList []*nodes.Builder
sriovmetricsdaemonset *daemonset.Builder
sriovInterfacesUnderTest []string
sriovDeviceID string
sriovVendorID string
)

BeforeAll(func() {
Expand All @@ -71,8 +71,8 @@ var _ = Describe("SriovMetricsExporter", Ordered, Label(tsparams.LabelSriovMetri
Expect(err).ToNot(HaveOccurred(), "Failed to retrieve SR-IOV interfaces for testing")

By("Fetching SR-IOV Device ID for interface under test")
sriovDeviceID = discoverInterfaceUnderTestDeviceID(sriovInterfacesUnderTest[0], workerNodeList[0].Definition.Name)
Expect(sriovDeviceID).ToNot(BeEmpty(), "Expected sriovDeviceID not to be empty")
sriovVendorID = discoverInterfaceUnderTestVendorID(sriovInterfacesUnderTest[0], workerNodeList[0].Definition.Name)
Expect(sriovVendorID).ToNot(BeEmpty(), "Expected sriovDeviceID not to be empty")

By("Enable Sriov Metrics Exporter feature in default SriovOperatorConfig CR")
setMetricsExporter(true)
Expand Down Expand Up @@ -122,15 +122,15 @@ var _ = Describe("SriovMetricsExporter", Ordered, Label(tsparams.LabelSriovMetri
Context("Netdevice to Netdevice", func() {
It("Same PF", reportxml.ID("74762"), func() {
runNettoNetTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[0],
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovVendorID)
})
It("Different PF", reportxml.ID("75929"), func() {
runNettoNetTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[1],
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovVendorID)
})
It("Different Worker", reportxml.ID("75930"), func() {
runNettoNetTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[0],
workerNodeList[0].Object.Name, workerNodeList[1].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[1].Object.Name, sriovVendorID)
})
})

Expand All @@ -152,15 +152,15 @@ var _ = Describe("SriovMetricsExporter", Ordered, Label(tsparams.LabelSriovMetri
})
It("Same PF", reportxml.ID("74797"), func() {
runNettoVfioTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[0],
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovVendorID)
})
It("Different PF", reportxml.ID("75931"), func() {
runNettoVfioTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[1],
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovVendorID)
})
It("Different Worker", reportxml.ID("75932"), func() {
runNettoVfioTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[0],
workerNodeList[0].Object.Name, workerNodeList[1].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[1].Object.Name, sriovVendorID)
})
})

Expand All @@ -183,15 +183,15 @@ var _ = Describe("SriovMetricsExporter", Ordered, Label(tsparams.LabelSriovMetri
})
It("Same PF", reportxml.ID("74800"), func() {
runVfiotoVfioTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[0],
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovVendorID)
})
It("Different PF", reportxml.ID("75933"), func() {
runVfiotoVfioTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[1],
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[0].Object.Name, sriovVendorID)
})
It("Different Worker", reportxml.ID("75934"), func() {
runVfiotoVfioTests(sriovInterfacesUnderTest[0], sriovInterfacesUnderTest[0],
workerNodeList[0].Object.Name, workerNodeList[1].Object.Name, sriovDeviceID)
workerNodeList[0].Object.Name, workerNodeList[1].Object.Name, sriovVendorID)
})
})

Expand Down Expand Up @@ -285,7 +285,7 @@ func definePolicy(role, devType, nicVendor, pfName string, vfRange int) *sriov.P
WithDevType("netdevice").
WithVFRange(vfRange, vfRange)
case "vfiopci":
if !(nicVendor == netparam.MlxDeviceID || nicVendor == netparam.MlxBFDeviceID) {
if nicVendor != netparam.MlxVendorID {
policy = sriov.NewPolicyBuilder(APIClient,
role+devType, NetConfig.SriovOperatorNamespace, role+devType, 2, []string{pfName}, NetConfig.WorkerLabelMap).
WithDevType("vfio-pci").
Expand Down
8 changes: 8 additions & 0 deletions tests/cnf/core/network/sriov/tests/paralleldraining.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/openshift-kni/eco-goinfra/pkg/nad"
"github.com/openshift-kni/eco-goinfra/pkg/namespace"
"github.com/openshift-kni/eco-goinfra/pkg/nodes"
"github.com/openshift-kni/eco-goinfra/pkg/pod"
Expand Down Expand Up @@ -59,6 +60,13 @@ var _ = Describe("ParallelDraining", Ordered, Label(tsparams.LabelParallelDraini
createSriovConfigurationParallelDrain(sriovInterfacesUnderTest[0])

By("Creating test pods and checking connectivity between the them")
Eventually(func() error {
_, err := nad.Pull(APIClient, sriovAndResourceNameParallelDrain, tsparams.TestNamespaceName)

return err
}, 10*time.Second, 1*time.Second).Should(BeNil(), fmt.Sprintf(
"Failed to pull NAD %s", sriovAndResourceNameParallelDrain))

err := sriovenv.CreatePodsAndRunTraffic(workerNodeList[0].Object.Name, workerNodeList[0].Object.Name,
sriovAndResourceNameParallelDrain, sriovAndResourceNameParallelDrain,
tsparams.ClientMacAddress, tsparams.ServerMacAddress,
Expand Down
10 changes: 7 additions & 3 deletions tests/cnf/core/network/sriov/tests/rdmametricsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ var _ = Describe("rdmaMetricsAPI", Ordered, Label(tsparams.LabelRdmaMetricsAPITe
pciAddress, rdmaDevice, err := getInterfacePci(testPod, "net1")
Expect(err).ToNot(HaveOccurred(),
"Could not get PCI Address and/or Rdma device from Pod Annotations")
Expect(pciAddress).To(Not(BeEmpty()), "pci-address field is empty")
Expect(rdmaDevice).To(Not(BeEmpty()), "rdma-device field is empty")

By("Verify Rdma Metrics should not be present inside Pod")
podOutput, err := testPod.ExecCommand(
Expand Down Expand Up @@ -266,19 +268,19 @@ func verifyAllocatableResouces(tPod *pod.Builder, resName string) {
Expect(err).ToNot(HaveOccurred(), "Failed to list sriov device plugin pods")
Expect(len(sriovDevicePluginPods)).To(Equal(1), "Failed to fetch the sriov device plugin pod")

_, err = sriovDevicePluginPods[0].Delete()
_, err = sriovDevicePluginPods[0].DeleteAndWait(1 * time.Minute)
Expect(err).ToNot(HaveOccurred(), "Failed to delete the sriov device plugin pod")

Eventually(func() bool {
sriovDevicePluginPods, err := pod.List(APIClient, NetConfig.SriovOperatorNamespace, metav1.ListOptions{
sriovDevicePluginPods, err = pod.List(APIClient, NetConfig.SriovOperatorNamespace, metav1.ListOptions{
LabelSelector: labels.Set{"app": "sriov-device-plugin"}.String(),
FieldSelector: fields.SelectorFromSet(fields.Set{"spec.nodeName": tPod.Object.Spec.NodeName}).String()})
Expect(err).ToNot(HaveOccurred(), "Failed to list sriov device plugin pods")

return len(sriovDevicePluginPods) == 1
}, 1*time.Minute, 2*time.Second).Should(BeTrue(), "Failed to find the new sriov device plugin pod")

Consistently(func() bool {
Eventually(func() bool {
testNode, err := nodes.Pull(APIClient, tPod.Object.Spec.NodeName)
Expect(err).NotTo(HaveOccurred(), "Failed to pull test pod's host worker node")

Expand Down Expand Up @@ -398,6 +400,8 @@ func verifyRdmaMetrics(inputPod *pod.Builder, iName string) {
pciAddress, rdmaDevice, err := getInterfacePci(inputPod, iName)
Expect(err).ToNot(HaveOccurred(),
"Could not get PCI Address and/or Rdma device from Pod Annotations")
Expect(pciAddress).To(Not(BeEmpty()), "pci-address field is empty")
Expect(rdmaDevice).To(Not(BeEmpty()), "rdma-device field is empty")

By("Rdma metrics should be present inside the Pod")

Expand Down