Skip to content

Commit 3ca2c29

Browse files
author
Gregory Kopels
committed
cnf:network add sriov bond mode test cases
1 parent 6b7d464 commit 3ca2c29

4 files changed

Lines changed: 1107 additions & 6 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package sriovenv
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/rh-ecosystem-edge/eco-goinfra/pkg/nad"
7+
. "github.com/rh-ecosystem-edge/eco-gotests/tests/cnf/core/network/internal/netinittools"
8+
"github.com/rh-ecosystem-edge/eco-gotests/tests/cnf/core/network/sriov/internal/tsparams"
9+
)
10+
11+
// CreateBondNAD creates a Bond CNI NAD in the SR-IOV test namespace.
12+
// This follows the same pattern used by sriov/tests/qinq.go.
13+
func CreateBondNAD(
14+
nadName string,
15+
mode string,
16+
mtu int,
17+
slaveCount int,
18+
ipamType string,
19+
vlanInContainer *uint16,
20+
) (*nad.Builder, error) {
21+
if slaveCount < 2 {
22+
return nil, fmt.Errorf("slaveCount must be >= 2, got %d", slaveCount)
23+
}
24+
25+
var links []nad.Link
26+
for i := 1; i <= slaveCount; i++ {
27+
links = append(links, nad.Link{Name: fmt.Sprintf("net%d", i)})
28+
}
29+
30+
plugin := nad.NewMasterBondPlugin(nadName, mode).
31+
WithFailOverMac(1).
32+
WithLinksInContainer(true).
33+
WithMiimon(100).
34+
WithLinks(links).
35+
WithCapabilities(&nad.Capability{IPs: true}).
36+
WithIPAM(&nad.IPAM{Type: ipamType})
37+
38+
if vlanInContainer != nil {
39+
plugin = plugin.WithVLANInContainer(*vlanInContainer)
40+
}
41+
42+
masterPlugin, err := plugin.GetMasterPluginConfig()
43+
if err != nil {
44+
return nil, err
45+
}
46+
47+
if mtu > 0 {
48+
masterPlugin.Mtu = mtu
49+
}
50+
51+
createdNAD, err := nad.NewBuilder(APIClient, nadName, tsparams.TestNamespaceName).
52+
WithMasterPlugin(masterPlugin).
53+
Create()
54+
if err != nil {
55+
return nil, err
56+
}
57+
58+
return createdNAD, nil
59+
}

tests/cnf/core/network/sriov/internal/tsparams/consts.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ const (
3838
// Net1Interface is the name of the first secondary network interface attached to pods.
3939
Net1Interface = "net1"
4040

41+
// MTU500 is used by SR-IOV IPv4 custom MTU tests.
42+
MTU500 = 500
43+
// MTU1280 is the minimum MTU for IPv6.
44+
MTU1280 = 1280
45+
// MTU9000 is used by jumbo MTU tests.
46+
MTU9000 = 9000
47+
4148
// ClientPodMTU500 is the name of the client pod for MTU 500 tests.
4249
ClientPodMTU500 = "client-mtu500"
4350
// ServerPodMTU500 is the name of the server pod for MTU 500 tests.

tests/cnf/core/network/sriov/tests/qinq.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,12 +1077,8 @@ func runQinQDpdkTestCases(nodeName, serverName, clientName, sriovNetworkName, na
10771077

10781078
// defineBondNAD returns network attachment definition for a Bond interface.
10791079
func defineQinQBondNAD(nadname, mode string) *nad.Builder {
1080-
bondNad, err := nad.NewMasterBondPlugin(nadname, mode).WithFailOverMac(1).
1081-
WithLinksInContainer(true).WithVLANInContainer(uint16(100)).WithMiimon(100).
1082-
WithLinks([]nad.Link{{Name: "net1"}, {Name: "net2"}}).WithIPAM(&nad.IPAM{Type: ""}).GetMasterPluginConfig()
1083-
Expect(err).ToNot(HaveOccurred(), "Failed to define Bond NAD for %s", nadname)
1084-
1085-
createdNad, err := nad.NewBuilder(APIClient, nadname, tsparams.TestNamespaceName).WithMasterPlugin(bondNad).Create()
1080+
vlan := uint16(100)
1081+
createdNad, err := sriovenv.CreateBondNAD(nadname, mode, 0, 2, "", &vlan)
10861082
Expect(err).ToNot(HaveOccurred(), "Failed to create Bond NAD for %s", nadname)
10871083

10881084
return createdNad

0 commit comments

Comments
 (0)