MCPcopy
hub / github.com/grpc/grpc-go / TestPickFirst_OneServerDown

Method TestPickFirst_OneServerDown

balancer/pickfirst/pickfirst_ext_test.go:195–213  ·  view source on GitHub ↗

TestPickFirst_OneServerDown tests the scenario where we have multiple backends and pick_first is working as expected. Verifies that RPCs get routed to the next backend in the list when the first one goes down.

(t *testing.T)

Source from the content-addressed store, hash-verified

193// backends and pick_first is working as expected. Verifies that RPCs get routed
194// to the next backend in the list when the first one goes down.
195func (s) TestPickFirst_OneServerDown(t *testing.T) {
196 cc, r, backends := setupPickFirst(t, 2)
197
198 addrs := stubBackendsToResolverAddrs(backends)
199 r.UpdateState(resolver.State{Addresses: addrs})
200
201 ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout)
202 defer cancel()
203 if err := pickfirst.CheckRPCsToBackend(ctx, cc, addrs[0]); err != nil {
204 t.Fatal(err)
205 }
206
207 // Stop the backend which is currently being used. RPCs should get routed to
208 // the next backend in the list.
209 backends[0].Stop()
210 if err := pickfirst.CheckRPCsToBackend(ctx, cc, addrs[1]); err != nil {
211 t.Fatal(err)
212 }
213}
214
215// TestPickFirst_AllServersDown tests the scenario where we have multiple
216// backends and pick_first is working as expected. When all backends go down,

Callers

nothing calls this directly

Calls 6

CheckRPCsToBackendFunction · 0.92
setupPickFirstFunction · 0.85
UpdateStateMethod · 0.65
FatalMethod · 0.65
StopMethod · 0.65

Tested by

no test coverage detected