-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e_multi_node_LB_test.go
118 lines (101 loc) · 2.95 KB
/
e2e_multi_node_LB_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//go:build integration_large
package main
import (
"asvec/tests"
"context"
"fmt"
"strings"
"testing"
avs "github.com/aerospike/avs-client-go"
"github.com/stretchr/testify/suite"
)
type MultiNodeLBCmdTestSuite struct {
tests.CmdBaseTestSuite
}
func TestMultiNodeLBCmdSuite(t *testing.T) {
avsSeed := "localhost"
avsPort := 10000
avsHostPort := avs.NewHostPort(avsSeed, avsPort)
composeFile := "docker/multi-node-LB/docker-compose.yml"
suites := []*MultiNodeLBCmdTestSuite{
{
CmdBaseTestSuite: tests.CmdBaseTestSuite{
SuiteFlags: []string{
// "--log-level Error",
"--timeout 10s",
},
AvsHostPort: avsHostPort,
ComposeFile: composeFile,
},
},
}
for _, s := range suites {
suite.Run(t, s)
}
}
func (suite *MultiNodeLBCmdTestSuite) TestNodeListCmd() {
about, err := suite.AvsClient.About(context.Background(), nil)
if err != nil {
suite.T().Fatal(err)
}
testCases := []struct {
name string
cmd string
expectErrCoded bool
expectedTable string
expectedWarning string
}{
{
"node ls with LB and seeds",
fmt.Sprintf("node ls --format 1 --no-color --seeds %s", suite.AvsHostPort.String()),
true,
`Nodes
,Node,Roles,Endpoint,Cluster ID,Version,Visible Nodes
1,Seed,[INDEX_QUERY INDEX_UPDATE],localhost:10000,<cluster-id>,<version>,"{
1103823447824: [1.1.1.1:10000]
2207646885648: [2.2.2.2:10000]
3311470323472: [3.3.3.3:10000]
}"`,
`Warning: Not all nodes are visible to asvec.
Asvec can't reach: 1103823447824, 2207646885648, 3311470323472
Possible scenarios:
1. You should use --host instead of --seeds to indicate you are connection through a load balancer.
2. Asvec was able to connect to your seeds but the server(s) are returning unreachable endpoints.
Did you forget --listener-name?
`,
},
{
"node ls with LB and host",
fmt.Sprintf("node ls --format 1 --no-color --host %s", suite.AvsHostPort.String()),
false,
`Nodes
,Node,Roles,Endpoint,Cluster ID,Version,Visible Nodes
1,LB,N/A,localhost:10000,<cluster-id>,<version>,"{
1103823447824: [1.1.1.1:10000]
2207646885648: [2.2.2.2:10000]
3311470323472: [3.3.3.3:10000]
}"`,
"",
},
}
for _, tc := range testCases {
suite.Run(tc.name, func() {
state, err := suite.AvsClient.ClusteringState(context.Background(), nil)
suite.Assert().NoError(err)
clusterIDStr := fmt.Sprintf("%d", state.ClusterId.GetId())
tc.expectedTable = strings.ReplaceAll(tc.expectedTable, "<cluster-id>", clusterIDStr)
tc.expectedTable = strings.ReplaceAll(tc.expectedTable, "<version>", about.Version)
outLines, errLines, err := suite.RunSuiteCmd(strings.Split(tc.cmd, " ")...)
if tc.expectErrCoded {
suite.Assert().Error(err)
} else {
suite.Assert().NoError(err)
}
// expectedTableLines := strings.Split(tc.expectedTable, "\n")
suite.Assert().Contains(outLines, tc.expectedTable)
if tc.expectedWarning != "" {
suite.Assert().Contains(errLines, tc.expectedWarning)
}
})
}
}