Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-9623 control: Use comma separator for providers #8578

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/control/server/engine/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
maxHelperStreamCount = 2

// MultiProviderSeparator delineates between providers in a multi-provider config.
MultiProviderSeparator = " "
MultiProviderSeparator = ","
)

// FabricConfig encapsulates networking fabric configuration.
Expand Down
41 changes: 23 additions & 18 deletions src/control/server/engine/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -526,6 +527,10 @@ func TestConfig_Validation(t *testing.T) {
}
}

func multiProviderString(comp ...string) string {
return strings.Join(comp, MultiProviderSeparator)
}

func TestConfig_FabricValidation(t *testing.T) {
for name, tc := range map[string]struct {
cfg FabricConfig
Expand Down Expand Up @@ -569,31 +574,31 @@ func TestConfig_FabricValidation(t *testing.T) {
},
"multi provider/interface/port ok": {
cfg: FabricConfig{
Provider: "foo bar",
Interface: "baz net",
InterfacePort: "42 128",
Provider: multiProviderString("foo", "bar"),
Interface: multiProviderString("baz", "net"),
InterfacePort: multiProviderString("42", "128"),
},
},
"mismatched num providers": {
cfg: FabricConfig{
Provider: "foo",
Interface: "bar baz",
InterfacePort: "42 128",
Interface: multiProviderString("baz", "net"),
InterfacePort: multiProviderString("42", "128"),
},
expErr: errors.New("same number"),
},
"mismatched num interfaces": {
cfg: FabricConfig{
Provider: "foo bar",
Provider: multiProviderString("foo", "bar"),
Interface: "baz",
InterfacePort: "42 128",
InterfacePort: multiProviderString("42", "128"),
},
expErr: errors.New("same number"),
},
"mismatched num ports": {
cfg: FabricConfig{
Provider: "foo bar",
Interface: "baz net",
Provider: multiProviderString("foo", "bar"),
Interface: multiProviderString("baz", "net"),
InterfacePort: "42",
},
expErr: errors.New("same number"),
Expand Down Expand Up @@ -825,13 +830,13 @@ func TestFabricConfig_GetProviders(t *testing.T) {
},
"multi": {
cfg: &FabricConfig{
Provider: "p1 p2 p3",
Provider: multiProviderString("p1", "p2", "p3"),
},
expProviders: []string{"p1", "p2", "p3"},
},
"excessive whitespace": {
cfg: &FabricConfig{
Provider: " p1 p2 p3",
Provider: multiProviderString(" ", " p1 ", " p2 ", "p3"),
},
expProviders: []string{"p1", "p2", "p3"},
},
Expand Down Expand Up @@ -868,7 +873,7 @@ func TestFabricConfig_GetPrimaryProvider(t *testing.T) {
},
"multi": {
cfg: &FabricConfig{
Provider: "p1 p2 p3",
Provider: multiProviderString("p1", "p2", "p3"),
},
expProvider: "p1",
},
Expand Down Expand Up @@ -903,13 +908,13 @@ func TestFabricConfig_GetInterfaces(t *testing.T) {
},
"multi": {
cfg: &FabricConfig{
Interface: "net1 net2 net3",
Interface: multiProviderString("net1", "net2", "net3"),
},
expInterfaces: []string{"net1", "net2", "net3"},
},
"excessive whitespace": {
cfg: &FabricConfig{
Interface: " net1 net2 net3 ",
Interface: multiProviderString(" net1 ", "", " net2", "net3", ""),
},
expInterfaces: []string{"net1", "net2", "net3"},
},
Expand Down Expand Up @@ -946,7 +951,7 @@ func TestFabricConfig_GetPrimaryInterface(t *testing.T) {
},
"multi": {
cfg: &FabricConfig{
Interface: "net0 net1 net3",
Interface: multiProviderString("net0", "net1", "net2", "net3"),
},
expInterface: "net0",
},
Expand Down Expand Up @@ -981,19 +986,19 @@ func TestFabricConfig_GetInterfacePorts(t *testing.T) {
},
"multi": {
cfg: &FabricConfig{
InterfacePort: "1234 5678 9012",
InterfacePort: multiProviderString("1234", "5678", "9012"),
},
expPorts: []int{1234, 5678, 9012},
},
"excessive whitespace": {
cfg: &FabricConfig{
InterfacePort: " 1234 5678 9012 ",
InterfacePort: multiProviderString("1234 ", " 5678 ", "", " 9012"),
},
expPorts: []int{1234, 5678, 9012},
},
"non-integer port": {
cfg: &FabricConfig{
InterfacePort: "1234 a123",
InterfacePort: multiProviderString("1234", "a123"),
},
expErr: errors.New("strconv.Atoi"),
},
Expand Down
5 changes: 3 additions & 2 deletions src/control/server/server_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"net"
"os/user"
"strings"
"testing"

"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -779,9 +780,9 @@ func TestServer_getNetDevClass(t *testing.T) {
},
"multi interface": {
configA: configA().
WithFabricInterface("eth0 ib0"),
WithFabricInterface(strings.Join([]string{"eth0", "ib0"}, engine.MultiProviderSeparator)),
configB: configB().
WithFabricInterface("eth1 ib1"),
WithFabricInterface(strings.Join([]string{"eth1", "ib1"}, engine.MultiProviderSeparator)),
expNetDevCls: []hardware.NetDevClass{hardware.Ether, hardware.Infiniband},
},
"mismatching net dev class with primary server as ib0 / Infiniband": {
Expand Down