Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
39 changes: 25 additions & 14 deletions tests/ocp/sriov/internal/sriovenv/sriovenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ func initVFWithDevType(name, deviceID, interfaceName, vendor, devType string, vf
policy.Definition.Spec.NicSelector.DeviceID = deviceID
}

policy.Definition.Spec.EswitchMode = "legacy"

if _, err := policy.Create(); err != nil {
klog.V(90).Infof("Failed to create policy on node %q: %v", nodeName, err)

Expand Down Expand Up @@ -632,7 +634,7 @@ func VerifyLinkStateConfiguration(networkName, namespace, description string,
// ============================================================================

func verifySpoofCheck(clientPod *pod.Builder, interfaceName, expectedState string) error {
// Get node name and MAC
// Get node name
refreshedPod, err := pod.Pull(APIClient, clientPod.Definition.Name, clientPod.Definition.Namespace)
if err != nil {
return fmt.Errorf("failed to refresh pod: %w", err)
Expand All @@ -643,11 +645,6 @@ func verifySpoofCheck(clientPod *pod.Builder, interfaceName, expectedState strin
return fmt.Errorf("pod node name is empty")
}

mac, err := ExtractPodInterfaceMAC(clientPod, "net1")
if err != nil {
return fmt.Errorf("failed to extract MAC: %w", err)
}

// Execute on node via cluster helper
outputMap, err := cluster.ExecCmdWithStdout(APIClient, fmt.Sprintf("ip link show %s", interfaceName),
metav1.ListOptions{LabelSelector: fmt.Sprintf("kubernetes.io/hostname=%s", nodeName)})
Expand All @@ -671,19 +668,33 @@ func verifySpoofCheck(clientPod *pod.Builder, interfaceName, expectedState strin
}
}

// Find line with MAC and check spoof state
// Search VF lines for the expected spoof check state.
// Note: In switchdev mode (e.g., Mellanox CX6-DX), `ip link show <PF>` reports VF MACs as
// 00:00:00:00:00:00 regardless of the MAC assigned inside the pod, so matching by MAC address
// is unreliable. Instead, we check any VF line for the expected state, since the SR-IOV policy
// applies a uniform spoof checking configuration to all VFs it creates.
vfLinesFound := 0

for _, line := range strings.Split(output, "\n") {
if strings.Contains(line, mac) {
if strings.Contains(line, fmt.Sprintf("spoof checking %s", expectedState)) ||
strings.Contains(line, fmt.Sprintf("spoofchk %s", expectedState)) {
klog.V(90).Infof("Spoof check verified: %s for MAC %s", expectedState, mac)
if !strings.Contains(line, "vf ") {
continue
}

return nil
}
vfLinesFound++

if strings.Contains(line, fmt.Sprintf("spoof checking %s", expectedState)) ||
strings.Contains(line, fmt.Sprintf("spoofchk %s", expectedState)) {
klog.V(90).Infof("Spoof check verified: %s on interface %s", expectedState, interfaceName)

return nil
}
}

return fmt.Errorf("spoof check %s not found for MAC %s", expectedState, mac)
if vfLinesFound == 0 {
return fmt.Errorf("no VF information found in ip link show output for interface %s", interfaceName)
}

return fmt.Errorf("spoof check %s not found for interface %s", expectedState, interfaceName)
}

// ============================================================================
Expand Down
19 changes: 16 additions & 3 deletions tests/ocp/sriov/tests/metricsExporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,22 @@
"Failed to add server mac address in client pod mac table. Output: %s", outputbuf.String()))

By("ICMP check between client and server pods")
Eventually(func() error {
return sriovocpenv.ICMPConnectivityCheck(cPod, []string{tsparams.ServerIPv4IPAddress}, "net1")
}, 1*time.Minute, 2*time.Second).Should(HaveOccurred(), "ICMP fail scenario could not be executed")

// Derive the expected ICMP outcome from the device type that defineMetricsPolicy() actually
// configured on the server policy, rather than re-checking the vendor ID here.
// With true vfio-pci (Intel), the VF is exclusively owned by DPDK and ICMP fails.
// With netdevice+RDMA (Mellanox "vfiopci" mode), the kernel network stack remains active
// on the VF and ICMP succeeds.
if serverResources.sriovPolicy.Definition.Spec.DeviceType == "vfio-pci" {

Check failure on line 313 in tests/ocp/sriov/tests/metricsExporter.go

View workflow job for this annotation

GitHub Actions / build

serverResources.sriovPolicy undefined (type metricsTestResource has no field or method sriovPolicy)

Check failure on line 313 in tests/ocp/sriov/tests/metricsExporter.go

View workflow job for this annotation

GitHub Actions / build

serverResources.sriovPolicy undefined (type metricsTestResource has no field or method sriovPolicy) (typecheck)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Eventually(func() error {
return sriovocpenv.ICMPConnectivityCheck(cPod, []string{tsparams.ServerIPv4IPAddress}, "net1")
}, 1*time.Minute, 2*time.Second).Should(HaveOccurred(), "ICMP fail scenario could not be executed")
} else {
Eventually(func() error {
return sriovocpenv.ICMPConnectivityCheck(cPod, []string{tsparams.ServerIPv4IPAddress}, "net1")
}, 1*time.Minute, 2*time.Second).ShouldNot(HaveOccurred(),
"ICMP connectivity check failed for netdevice+RDMA server")
}
Comment on lines +307 to +322
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend against skipping the traffic test for the Intel device. We should ensure compatibility across both vendors; the defineMetricsPolicy() function should be responsible for generating the correct policy for each.


checkMetricsWithPromQL()
}
Expand Down
Loading