(t *testing.T, healthy bool)
| 34 | } |
| 35 | |
| 36 | func startMockGRPCServer(t *testing.T, healthy bool) (string, func()) { |
| 37 | lis, err := net.Listen("tcp", "localhost:0") |
| 38 | if err != nil { |
| 39 | t.Fatalf("failed to listen: %v", err) |
| 40 | } |
| 41 | s := grpc.NewServer() |
| 42 | proto.RegisterAgentServiceServer(s, &mockAgentServer{healthy: healthy}) |
| 43 | go func() { |
| 44 | if err := s.Serve(lis); err != nil { |
| 45 | // server might be closed |
| 46 | } |
| 47 | }() |
| 48 | return lis.Addr().String(), func() { |
| 49 | s.Stop() |
| 50 | lis.Close() |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | func TestRegistry_GracefulShutdown(t *testing.T) { |
| 55 | r := NewRegistry() |
no test coverage detected