-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e_multi_node_test.go
90 lines (78 loc) · 2.25 KB
/
e2e_multi_node_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
//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 MultiNodeCmdTestSuite struct {
tests.CmdBaseTestSuite
}
func TestMultiNodeCmdSuite(t *testing.T) {
avsSeed := "localhost"
avsPort := 10000
avsHostPort := avs.NewHostPort(avsSeed, avsPort)
composeFile := "docker/multi-node/docker-compose.yml"
suites := []*MultiNodeCmdTestSuite{
{
CmdBaseTestSuite: tests.CmdBaseTestSuite{
SuiteFlags: []string{
"--timeout 10s",
},
AvsHostPort: avsHostPort,
ComposeFile: composeFile,
},
},
}
for _, s := range suites {
suite.Run(t, s)
}
}
func (suite *MultiNodeCmdTestSuite) TestNodeListCmd() {
about, err := suite.AvsClient.About(context.Background(), nil)
if err != nil {
suite.T().Fatal(err)
}
testCases := []struct {
name string
cmd string
expectedTable string
}{
{
"node ls with multiple nodes and seeds",
fmt.Sprintf("node ls --format 1 --no-color --seeds %s", suite.AvsHostPort.String()),
`Nodes
,Node,Roles,Endpoint,Cluster ID,Version,Visible Nodes
1,139637976803088,[INDEX_QUERY],127.0.0.1:10000,<cluster-id>,<version>,"{
139637976803089: [127.0.0.1:10001]
139637976803090: [127.0.0.1:10002]
}"
2,139637976803089,[INDEX_QUERY INDEX_UPDATE],127.0.0.1:10001,<cluster-id>,<version>,"{
139637976803088: [127.0.0.1:10000]
139637976803090: [127.0.0.1:10002]
}"
3,139637976803090,[INDEX_QUERY INDEX_UPDATE],127.0.0.1:10002,<cluster-id>,<version>,"{
139637976803088: [127.0.0.1:10000]
139637976803089: [127.0.0.1:10001]
}"
`,
},
}
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, _, err := suite.RunSuiteCmd(strings.Split(tc.cmd, " ")...)
// suite.Assert().NoError(err, "error: %s, stdout/err: %s", err,
// lines
suite.Assert().Contains(outLines, tc.expectedTable)
})
}
}