Skip to content

Commit d3c75b7

Browse files
authored
sriov: Add WithMetaPluginRdma method (rh-ecosystem-edge#651)
1 parent b23d6a5 commit d3c75b7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

pkg/sriov/network.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ func (builder *NetworkBuilder) WithMetaPluginAllMultiFlag(allMultiFlag bool) *Ne
152152
return builder
153153
}
154154

155+
// WithMetaPluginRdma activates rdma plugin on a SriovNetwork configuration.
156+
func (builder *NetworkBuilder) WithMetaPluginRdma() *NetworkBuilder {
157+
if valid, _ := builder.validate(); !valid {
158+
return builder
159+
}
160+
161+
builder.Definition.Spec.MetaPluginsConfig = `{ "type": "rdma" }`
162+
163+
return builder
164+
}
165+
155166
// WithLinkState sets linkState parameters in the SrIovNetwork definition spec.
156167
func (builder *NetworkBuilder) WithLinkState(linkState string) *NetworkBuilder {
157168
if valid, _ := builder.validate(); !valid {

pkg/sriov/network_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,22 @@ func TestWithMetaPluginAllMultiFlag(t *testing.T) {
345345
}
346346
}
347347

348+
func TestSriovNetworkWithMetaPluginRdma(t *testing.T) {
349+
testCases := []struct {
350+
metaPlugin string
351+
}{
352+
{
353+
metaPlugin: `{ "type": "rdma" }`,
354+
},
355+
}
356+
357+
for _, testCase := range testCases {
358+
testSettings := buildTestClientWithDummyObject()
359+
netBuilder := buildValidSriovNetworkTestBuilder(testSettings).WithMetaPluginRdma()
360+
assert.Equal(t, netBuilder.Definition.Spec.MetaPluginsConfig, testCase.metaPlugin)
361+
}
362+
}
363+
348364
func TestWithLinkState(t *testing.T) {
349365
testCases := []struct {
350366
linkState string

0 commit comments

Comments
 (0)