startBackendsForBalancerSwitch spins up a bunch of stub server backends exposing the TestService. Returns a cleanup function to be invoked by the caller.
(t *testing.T)
| 101 | // exposing the TestService. Returns a cleanup function to be invoked by the |
| 102 | // caller. |
| 103 | func startBackendsForBalancerSwitch(t *testing.T) ([]*stubserver.StubServer, func()) { |
| 104 | t.Helper() |
| 105 | |
| 106 | backends := make([]*stubserver.StubServer, backendCount) |
| 107 | for i := 0; i < backendCount; i++ { |
| 108 | backend := &stubserver.StubServer{ |
| 109 | EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) { return &testpb.Empty{}, nil }, |
| 110 | } |
| 111 | if err := backend.StartServer(); err != nil { |
| 112 | t.Fatalf("Failed to start backend: %v", err) |
| 113 | } |
| 114 | t.Logf("Started TestService backend at: %q", backend.Address) |
| 115 | backends[i] = backend |
| 116 | } |
| 117 | return backends, func() { |
| 118 | for _, b := range backends { |
| 119 | b.Stop() |
| 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | // TestBalancerSwitch_Basic tests the basic scenario of switching from one LB |
| 125 | // policy to another, as specified in the service config. |
no test coverage detected