Skip to content

Commit

Permalink
proxy/grpcproxy: wait until register before Serve
Browse files Browse the repository at this point in the history
It was fatal-ing with:

grpclog.Fatalf("grpc: Server.RegisterService after Server.Serve for %q", sd.ServiceName)

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Nov 16, 2017
1 parent a8c84ff commit 91335d0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions proxy/grpcproxy/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,20 @@ func newClusterProxyServer(endpoints []string, t *testing.T) *clusterproxyTestSe
}
var opts []grpc.ServerOption
cts.server = grpc.NewServer(opts...)
go cts.server.Serve(cts.l)

// wait some time for free port 0 to be resolved
time.Sleep(500 * time.Millisecond)
servec := make(chan struct{})
go func() {
<-servec
cts.server.Serve(cts.l)
}()

Register(client, "test-prefix", cts.l.Addr().String(), 7)
cts.cp, cts.donec = NewClusterProxy(client, cts.l.Addr().String(), "test-prefix")
cts.caddr = cts.l.Addr().String()
pb.RegisterClusterServer(cts.server, cts.cp)
close(servec)

// wait some time for free port 0 to be resolved
time.Sleep(500 * time.Millisecond)

return cts
}

0 comments on commit 91335d0

Please sign in to comment.