Skip to content

Commit

Permalink
findLowerUpDevices
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Panattoni <[email protected]>
  • Loading branch information
zeeke committed Dec 2, 2024
1 parent eed6d46 commit c8afb97
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
16 changes: 12 additions & 4 deletions test/conformance/tests/test_policy_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,17 @@ var _ = Describe("[sriov] operator", Ordered, func() {
if err != nil {
Skip(err.Error())
}
intf = unusedSriovDevices[0]

lowerUpDevices, err := findLowerUpDevices(node, unusedSriovDevices)
if err != nil {
Skip(err.Error())
}

if len(lowerUpDevices) == 0 {
Skip("No working NIC found")
}

intf = lowerUpDevices[0]
By("Using device " + intf.Name + " on node " + node)

mtuPolicy := &sriovv1.SriovNetworkNodePolicy{
Expand Down Expand Up @@ -602,7 +612,7 @@ var _ = Describe("[sriov] operator", Ordered, func() {
ResourceName: resourceName,
IPAM: `{"type":"host-local","subnet":"10.10.10.0/24","rangeStart":"10.10.10.171","rangeEnd":"10.10.10.181","routes":[{"dst":"10.10.10.0/24"}],"gateway":"10.10.10.1"}`,
NetworkNamespace: namespaces.Test,
LogLevel: "debug",
LogLevel: "debug",
}}

// We need this to be able to run the connectivity checks on Mellanox cards
Expand Down Expand Up @@ -658,7 +668,6 @@ var _ = Describe("[sriov] operator", Ordered, func() {

secondPod = waitForPodRunning(secondPod)


stdout, _, _ = pod.ExecCommand(clients, firstPod, []string{"ip", "link"}...)
fmt.Println(stdout)
stdout, _, _ = pod.ExecCommand(clients, firstPod, []string{"ip", "route"}...)
Expand Down Expand Up @@ -699,7 +708,6 @@ var _ = Describe("[sriov] operator", Ordered, func() {
fmt.Println(stderr)
fmt.Println(err)


secondPodIPs, err := network.GetSriovNicIPs(secondPod, "net1")
Expect(err).ToNot(HaveOccurred())
Expect(len(firstPodIPs)).To(Equal(1))
Expand Down
22 changes: 22 additions & 0 deletions test/conformance/tests/test_sriov_operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,28 @@ func findUnusedSriovDevices(testNode string, sriovDevices []*sriovv1.InterfaceEx
return filteredDevices, nil
}

func findLowerUpDevices(testNode string, sriovDevices []*sriovv1.InterfaceExt) ([]*sriovv1.InterfaceExt, error) {
filteredDevices := []*sriovv1.InterfaceExt{}

for _, device := range sriovDevices {
command := []string{"chroot", "/host", "ip", "link", "show", "dev", device.Name}
output, stderr, err := runCommandOnConfigDaemon(testNode, command...)
if err != nil {
return nil, fmt.Errorf("failed running %v on node %s: %w\n%s\n%s", command, testNode, err, output, stderr)
}

fmt.Println(device.Name)
fmt.Println(output)
if strings.Contains(output, "LOWER_UP") {
filteredDevices = append(filteredDevices, device)
}
}

return filteredDevices, nil
}


Check failure on line 1894 in test/conformance/tests/test_sriov_operator.go

View workflow job for this annotation

GitHub Actions / Golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)

func isDefaultRouteInterface(intfName string, routes []string) bool {
for _, route := range routes {
if strings.HasPrefix(route, "default") && strings.Contains(route, "dev "+intfName) {
Expand Down

0 comments on commit c8afb97

Please sign in to comment.