mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-11 21:51:21 +00:00
PT-1822 fixed test
This commit is contained in:
@@ -18,7 +18,7 @@ BIN_DIR=$(shell git rev-parse --show-toplevel)/bin
|
|||||||
SRC_DIR=$(shell git rev-parse --show-toplevel)/src/go
|
SRC_DIR=$(shell git rev-parse --show-toplevel)/src/go
|
||||||
LDFLAGS="-X main.Version=${VERSION} -X main.Build=${BUILD} -X main.GoVersion=${GOVERSION} -X main.Commit=${COMMIT} -s -w"
|
LDFLAGS="-X main.Version=${VERSION} -X main.Build=${BUILD} -X main.GoVersion=${GOVERSION} -X main.Commit=${COMMIT} -s -w"
|
||||||
|
|
||||||
TEST_PSMDB_VERSION?=3.6
|
TEST_PSMDB_VERSION?=4.0
|
||||||
TEST_MONGODB_FLAVOR?=percona/percona-server-mongodb
|
TEST_MONGODB_FLAVOR?=percona/percona-server-mongodb
|
||||||
TEST_MONGODB_ADMIN_USERNAME?=admin
|
TEST_MONGODB_ADMIN_USERNAME?=admin
|
||||||
TEST_MONGODB_ADMIN_PASSWORD?=admin123456
|
TEST_MONGODB_ADMIN_PASSWORD?=admin123456
|
||||||
|
@@ -14,29 +14,34 @@ import (
|
|||||||
|
|
||||||
func TestGetHostnames(t *testing.T) {
|
func TestGetHostnames(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
uri string
|
uri string
|
||||||
want []string
|
want []string
|
||||||
|
wantError bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "from_mongos",
|
name: "from_mongos",
|
||||||
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBMongosPort),
|
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBMongosPort),
|
||||||
want: []string{"127.0.0.1:17001", "127.0.0.1:17002", "127.0.0.1:17004", "127.0.0.1:17005", "127.0.0.1:17007"},
|
want: []string{"127.0.0.1:17001", "127.0.0.1:17002", "127.0.0.1:17004", "127.0.0.1:17005", "127.0.0.1:17007"},
|
||||||
|
wantError: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "from_mongod",
|
name: "from_mongod",
|
||||||
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBShard1PrimaryPort),
|
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBShard1PrimaryPort),
|
||||||
want: []string{"127.0.0.1:17001", "127.0.0.1:17002", "127.0.0.1:17003"},
|
want: []string{"127.0.0.1:17001", "127.0.0.1:17002", "127.0.0.1:17003"},
|
||||||
|
wantError: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "from_non_sharded",
|
name: "from_non_sharded",
|
||||||
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBShard3PrimaryPort),
|
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBShard3PrimaryPort),
|
||||||
want: []string{"127.0.0.1:17021", "127.0.0.1:17022", "127.0.0.1:17023"},
|
want: []string{"127.0.0.1:17021", "127.0.0.1:17022", "127.0.0.1:17023"},
|
||||||
|
wantError: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "from_standalone",
|
name: "from_standalone",
|
||||||
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBStandalonePort),
|
uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBStandalonePort),
|
||||||
want: nil,
|
want: nil,
|
||||||
|
wantError: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,8 +59,8 @@ func TestGetHostnames(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
hostnames, err := GetHostnames(ctx, client)
|
hostnames, err := GetHostnames(ctx, client)
|
||||||
if err != nil {
|
if err != nil && !test.wantError {
|
||||||
t.Errorf("getHostnames: %v", err)
|
t.Errorf("Expecting error=nil, got: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(hostnames, test.want) {
|
if !reflect.DeepEqual(hostnames, test.want) {
|
||||||
|
Reference in New Issue
Block a user