Skip to content

Commit

Permalink
Avoid using specific port in ut (milvus-io#16398)
Browse files Browse the repository at this point in the history
Signed-off-by: yangxuan <xuan.yang@zilliz.com>
  • Loading branch information
XuanYang-cn authored Apr 6, 2022
1 parent 4cb7c28 commit 909dd73
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions internal/distributed/connection_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ func TestConnectionManager(t *testing.T) {
cm.Start()

t.Run("rootCoord", func(t *testing.T) {
lis, err := net.Listen("tcp", ":9999")
lis, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
defer lis.Close()
rootCoord := &testRootCoord{}
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
rootcoordpb.RegisterRootCoordServer(grpcServer, rootCoord)
go grpcServer.Serve(lis)
session.Init(typeutil.RootCoordRole, "127.0.0.1:9999", true, false)
session.Init(typeutil.RootCoordRole, lis.Addr().String(), true, false)
session.Register()
assert.Eventually(t, func() bool {
rootCoord, ok := cm.GetRootCoordClient()
Expand All @@ -72,15 +72,15 @@ func TestConnectionManager(t *testing.T) {
})

t.Run("queryCoord", func(t *testing.T) {
lis, err := net.Listen("tcp", ":9999")
lis, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
defer lis.Close()
queryCoord := &testQueryCoord{}
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
querypb.RegisterQueryCoordServer(grpcServer, queryCoord)
go grpcServer.Serve(lis)
session.Init(typeutil.QueryCoordRole, "127.0.0.1:9999", true, false)
session.Init(typeutil.QueryCoordRole, lis.Addr().String(), true, false)
session.Register()
assert.Eventually(t, func() bool {
queryCoord, ok := cm.GetQueryCoordClient()
Expand All @@ -89,15 +89,15 @@ func TestConnectionManager(t *testing.T) {
})

t.Run("dataCoord", func(t *testing.T) {
lis, err := net.Listen("tcp", ":9999")
lis, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
defer lis.Close()
dataCoord := &testDataCoord{}
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
datapb.RegisterDataCoordServer(grpcServer, dataCoord)
go grpcServer.Serve(lis)
session.Init(typeutil.DataCoordRole, "127.0.0.1:9999", true, false)
session.Init(typeutil.DataCoordRole, lis.Addr().String(), true, false)
session.Register()
assert.Eventually(t, func() bool {
dataCoord, ok := cm.GetDataCoordClient()
Expand All @@ -106,15 +106,15 @@ func TestConnectionManager(t *testing.T) {
})

t.Run("indexCoord", func(t *testing.T) {
lis, err := net.Listen("tcp", ":9999")
lis, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
defer lis.Close()
indexCoord := &testIndexCoord{}
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
indexpb.RegisterIndexCoordServer(grpcServer, indexCoord)
go grpcServer.Serve(lis)
session.Init(typeutil.IndexCoordRole, "127.0.0.1:9999", true, false)
session.Init(typeutil.IndexCoordRole, lis.Addr().String(), true, false)
session.Register()
assert.Eventually(t, func() bool {
indexCoord, ok := cm.GetIndexCoordClient()
Expand All @@ -123,15 +123,15 @@ func TestConnectionManager(t *testing.T) {
})

t.Run("queryNode", func(t *testing.T) {
lis, err := net.Listen("tcp", ":9999")
lis, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
defer lis.Close()
queryNode := &testQueryNode{}
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
querypb.RegisterQueryNodeServer(grpcServer, queryNode)
go grpcServer.Serve(lis)
session.Init(typeutil.QueryNodeRole, "127.0.0.1:9999", true, false)
session.Init(typeutil.QueryNodeRole, lis.Addr().String(), true, false)
session.Register()
assert.Eventually(t, func() bool {
queryNodes, ok := cm.GetQueryNodeClients()
Expand All @@ -140,15 +140,15 @@ func TestConnectionManager(t *testing.T) {
})

t.Run("dataNode", func(t *testing.T) {
lis, err := net.Listen("tcp", ":9999")
lis, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
defer lis.Close()
dataNode := &testDataNode{}
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
datapb.RegisterDataNodeServer(grpcServer, dataNode)
go grpcServer.Serve(lis)
session.Init(typeutil.DataNodeRole, "127.0.0.1:9999", true, false)
session.Init(typeutil.DataNodeRole, lis.Addr().String(), true, false)
session.Register()
assert.Eventually(t, func() bool {
dataNodes, ok := cm.GetDataNodeClients()
Expand All @@ -157,15 +157,15 @@ func TestConnectionManager(t *testing.T) {
})

t.Run("indexNode", func(t *testing.T) {
lis, err := net.Listen("tcp", ":9999")
lis, err := net.Listen("tcp", "127.0.0.1:")
assert.Nil(t, err)
defer lis.Close()
indexNode := &testIndexNode{}
grpcServer := grpc.NewServer()
defer grpcServer.Stop()
indexpb.RegisterIndexNodeServer(grpcServer, indexNode)
go grpcServer.Serve(lis)
session.Init(typeutil.IndexNodeRole, "127.0.0.1:9999", true, false)
session.Init(typeutil.IndexNodeRole, lis.Addr().String(), true, false)
session.Register()
assert.Eventually(t, func() bool {
indexNodes, ok := cm.GetIndexNodeClients()
Expand Down

0 comments on commit 909dd73

Please sign in to comment.