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)
| 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. |
| 195 | func (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, |
nothing calls this directly
no test coverage detected