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 7bd8717
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion proxy/grpcproxy/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ func newClusterProxyServer(endpoints []string, t *testing.T) *clusterproxyTestSe
}
var opts []grpc.ServerOption
cts.server = grpc.NewServer(opts...)
go cts.server.Serve(cts.l)
ready := make(chan struct{})
go func() {
<-ready
cts.server.Serve(cts.l)
}()

// wait some time for free port 0 to be resolved
time.Sleep(500 * time.Millisecond)
Expand All @@ -116,6 +120,7 @@ func newClusterProxyServer(endpoints []string, t *testing.T) *clusterproxyTestSe
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(ready)

return cts
}

0 comments on commit 7bd8717

Please sign in to comment.