diff --git a/src/go/Makefile b/src/go/Makefile index b5231f2f..57064f2e 100644 --- a/src/go/Makefile +++ b/src/go/Makefile @@ -18,7 +18,7 @@ BIN_DIR=$(shell git rev-parse --show-toplevel)/bin 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" -TEST_PSMDB_VERSION?=3.6 +TEST_PSMDB_VERSION?=4.0 TEST_MONGODB_FLAVOR?=percona/percona-server-mongodb TEST_MONGODB_ADMIN_USERNAME?=admin TEST_MONGODB_ADMIN_PASSWORD?=admin123456 diff --git a/src/go/mongolib/util/util_test.go b/src/go/mongolib/util/util_test.go index 3f8b2fac..0af6cf1d 100644 --- a/src/go/mongolib/util/util_test.go +++ b/src/go/mongolib/util/util_test.go @@ -14,29 +14,34 @@ import ( func TestGetHostnames(t *testing.T) { testCases := []struct { - name string - uri string - want []string + name string + uri string + want []string + wantError bool }{ { - name: "from_mongos", - 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"}, + name: "from_mongos", + 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"}, + wantError: false, }, { - name: "from_mongod", - 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"}, + name: "from_mongod", + 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"}, + wantError: false, }, { - name: "from_non_sharded", - 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"}, + name: "from_non_sharded", + 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"}, + wantError: false, }, { - name: "from_standalone", - uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBStandalonePort), - want: nil, + name: "from_standalone", + uri: fmt.Sprintf("mongodb://%s:%s@%s:%s", tu.MongoDBUser, tu.MongoDBPassword, tu.MongoDBHost, tu.MongoDBStandalonePort), + want: nil, + wantError: true, }, } @@ -54,8 +59,8 @@ func TestGetHostnames(t *testing.T) { } hostnames, err := GetHostnames(ctx, client) - if err != nil { - t.Errorf("getHostnames: %v", err) + if err != nil && !test.wantError { + t.Errorf("Expecting error=nil, got: %v", err) } if !reflect.DeepEqual(hostnames, test.want) {