Skip to content

Commit

Permalink
sriov, tests: Introduce skip to multipe SR-IOV test
Browse files Browse the repository at this point in the history
The new test added in order to check network-status annotation based
mapping of the networks to the appropriate PCI-Address - will
consistently pass only if the annotation exists and holds the pci-data.

In older versions of Multus the network-status annotation does not hold
the PCI-Address data (on version >=3.7 [0])

[0] https://github.com/k8snetworkplumbingwg/multus-cni/releases/tag/v3.7

Signed-off-by: Ram Lavi <ralavi@redhat.com>
  • Loading branch information
RamLavi committed Sep 11, 2022
1 parent c17a115 commit 1825b84
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/network/sriov.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"strings"
"time"

networkv1 "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/apis/k8s.cni.cncf.io/v1"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

Expand Down Expand Up @@ -563,6 +565,11 @@ var _ = Describe("[Serial]SRIOV", func() {
vmi = startVmi(vmi)
vmi = waitVmi(vmi)

// Since there is no consistent way to tell if the network-status Multus annotation contains the
// PCI-Address data for SR-IOV interfaces in the version deployed, manually checking if it exists
if !networkStatusAnnotationContainsPCIData(vmi) {
Skip("Skipping test. network-status annotation doesn't exist or does not contain PCI-Address data")
}
for _, iface := range vmi.Spec.Domain.Devices.Interfaces {
if iface.SRIOV == nil {
continue
Expand Down Expand Up @@ -754,3 +761,9 @@ func findIfaceByMAC(virtClient kubecli.KubevirtClient, vmi *v1.VirtualMachineIns
}
return ifaceName, nil
}

func networkStatusAnnotationContainsPCIData(vmi *v1.VirtualMachineInstance) bool {
vmiPod := tests.GetRunningPodByVirtualMachineInstance(vmi, vmi.Namespace)
networkStatusAnnotation, exist := vmiPod.Annotations[networkv1.NetworkStatusAnnot]
return exist && strings.Contains(networkStatusAnnotation, fmt.Sprintf("\"type\": \"%s\"", networkv1.DeviceInfoTypePCI))
}

0 comments on commit 1825b84

Please sign in to comment.