TestClientConnRPC_WithoutNameResolutionDelay verify that if the resolution has already happened once before at the time of making RPC, the name resolution flag is not set indicating there was no delay in name resolution.
(t *testing.T)
| 118 | // has already happened once before at the time of making RPC, the name |
| 119 | // resolution flag is not set indicating there was no delay in name resolution. |
| 120 | func (s) TestClientConnRPC_WithoutNameResolutionDelay(t *testing.T) { |
| 121 | statsHandler := &testStatsHandler{} |
| 122 | ss := &stubserver.StubServer{ |
| 123 | EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) { |
| 124 | return &testpb.Empty{}, nil |
| 125 | }, |
| 126 | } |
| 127 | if err := ss.Start(nil, grpc.WithStatsHandler(statsHandler)); err != nil { |
| 128 | t.Fatalf("Failed to start StubServer: %v", err) |
| 129 | } |
| 130 | defer ss.Stop() |
| 131 | |
| 132 | rb := manual.NewBuilderWithScheme("instant") |
| 133 | rb.InitialState(resolver.State{Addresses: []resolver.Address{{Addr: ss.Address}}}) |
| 134 | cc := ss.CC |
| 135 | defer cc.Close() |
| 136 | |
| 137 | cc.Connect() |
| 138 | ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) |
| 139 | defer cancel() |
| 140 | testutils.AwaitState(ctx, t, cc, connectivity.Ready) |
| 141 | client := testgrpc.NewTestServiceClient(cc) |
| 142 | // Verify that the RPC succeeds. |
| 143 | if _, err := client.EmptyCall(ctx, &testpb.Empty{}); err != nil { |
| 144 | t.Fatalf("First RPC failed unexpectedly: %v", err) |
| 145 | } |
| 146 | // verifying that RPC was not blocked on resolver indicating there was no |
| 147 | // delay in name resolution. |
| 148 | if statsHandler.nameResolutionDelayed { |
| 149 | t.Fatalf("statsHandler.nameResolutionDelayed = %v; want false", statsHandler.nameResolutionDelayed) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | // TestStatsHandlerDetectsResolutionDelay verifies that if this is the |
| 154 | // first time resolution is happening at the time of making RPC, |
nothing calls this directly
no test coverage detected