spanner: fix grpc race in MockCloudSpanner
It was possible to start serving from a gRPC server before
registering it. Some combination of the race detector and recent
gRPC changes tickled the bug.
@@ -230,13 +230,13 @@ func (m *MockCloudSpanner) Serve() {
if err != nil {
m.t.Fatalf("Failed to listen: %v", err)
}
- go m.s.Serve(lis)
_, port, err := net.SplitHostPort(lis.Addr().String())
if err != nil {
m.t.Fatalf("Failed to parse listener address: %v", err)
}
sppb.RegisterSpannerServer(m.s, m)
m.addr = "localhost:" + port
+ go m.s.Serve(lis)
}
// Stop terminates MockCloudSpanner and closes the serving port.
