Skip to content

Commit

Permalink
cnf network: multi-netpolicy bond cni tests (#311)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajaggapa authored Dec 22, 2024
1 parent 2edc924 commit ec23344
Show file tree
Hide file tree
Showing 11 changed files with 819 additions and 72 deletions.
2 changes: 1 addition & 1 deletion images/cnf/network/eco-gotests-network-client/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ RUN make build
FROM registry.access.redhat.com/ubi9/ubi:latest

LABEL description="eco-gotests cnf network test client image"
RUN dnf install -y nginx iproute iputils procps-ng ethtool shadow-utils libpcap net-tools
RUN dnf install -y nginx iproute iputils procps-ng ethtool shadow-utils libpcap net-tools nmap
RUN curl -s https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/tcpdump-4.99.0-9.el9.x86_64.rpm -o tcpdump-4.99.0-9.el9.x86_64.rpm
RUN rpm -i tcpdump-4.99.0-9.el9.x86_64.rpm
RUN dnf clean all
Expand Down
62 changes: 62 additions & 0 deletions tests/cnf/core/network/internal/netenv/netenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/openshift-kni/eco-goinfra/pkg/nodes"
"github.com/openshift-kni/eco-goinfra/pkg/nto"
"github.com/openshift-kni/eco-goinfra/pkg/pod"
"github.com/openshift-kni/eco-goinfra/pkg/sriov"
"github.com/openshift-kni/eco-gotests/tests/cnf/core/network/internal/netconfig"
"github.com/openshift-kni/eco-gotests/tests/cnf/core/network/internal/netinittools"
"github.com/openshift-kni/eco-gotests/tests/cnf/core/network/internal/netparam"
v2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -172,3 +174,63 @@ func DeployPerformanceProfile(

return mcp.WaitToBeStableFor(time.Minute, netparam.MCOWaitTimeout)
}

// RemoveSriovConfigurationAndWaitForSriovAndMCPStable removes all SR-IOV networks
// and policies in SR-IOV operator namespace.
func RemoveSriovConfigurationAndWaitForSriovAndMCPStable() error {
glog.V(90).Infof("Removing all SR-IOV networks and policies")

err := RemoveAllSriovNetworks()
if err != nil {
glog.V(90).Infof("Failed to remove all SR-IOV networks")

return err
}

err = RemoveAllPoliciesAndWaitForSriovAndMCPStable()
if err != nil {
glog.V(90).Infof("Failed to remove all SR-IOV policies")

return err
}

return nil
}

// RemoveAllSriovNetworks removes all SR-IOV networks.
func RemoveAllSriovNetworks() error {
glog.V(90).Infof("Removing all SR-IOV networks")

sriovNs, err := namespace.Pull(netinittools.APIClient, netinittools.NetConfig.SriovOperatorNamespace)
if err != nil {
glog.V(90).Infof("Failed to pull SR-IOV operator namespace")

return err
}

err = sriovNs.CleanObjects(
netparam.DefaultTimeout,
sriov.GetSriovNetworksGVR())
if err != nil {
glog.V(90).Infof("Failed to remove SR-IOV networks from SR-IOV operator namespace")

return err
}

return nil
}

// RemoveAllPoliciesAndWaitForSriovAndMCPStable removes all SriovNetworkNodePolicies and waits until
// SR-IOV and MCP become stable.
func RemoveAllPoliciesAndWaitForSriovAndMCPStable() error {
glog.V(90).Infof("Deleting all SriovNetworkNodePolicies and waiting for SR-IOV and MCP become stable.")

err := sriov.CleanAllNetworkNodePolicies(netinittools.APIClient, netinittools.NetConfig.SriovOperatorNamespace)
if err != nil {
return err
}

return WaitForSriovAndMCPStable(
netinittools.APIClient, netparam.MCOWaitTimeout, time.Minute,
netinittools.NetConfig.CnfMcpLabel, netinittools.NetConfig.SriovOperatorNamespace)
}
2 changes: 1 addition & 1 deletion tests/cnf/core/network/internal/netparam/netvars.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
// DefaultTimeout represents the default timeout for most of Eventually/PollImmediate functions.
DefaultTimeout = 300 * time.Second
// MCOWaitTimeout represent timeout for mco operations.
MCOWaitTimeout = 60 * time.Minute
MCOWaitTimeout = 35 * time.Minute
// VtySh represents default vtysh cmd prefix.
VtySh = []string{"vtysh", "-c"}
// MlxDeviceID is the Mellanox SRIOV device ID.
Expand Down
Loading

0 comments on commit ec23344

Please sign in to comment.