Skip to content

Commit

Permalink
Retry one failure when switching servers
Browse files Browse the repository at this point in the history
  • Loading branch information
arjan-bal committed Jun 27, 2024
1 parent 028bf08 commit 503a123
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions xds/internal/balancer/clusterimpl/tests/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ func (s) TestLoadReportingPickFirstMultiLocality(t *testing.T) {
}

// Create a ClientConn and make a successful RPC.
cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(resolverBuilder))
cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName),
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithResolvers(resolverBuilder))
if err != nil {
t.Fatalf("failed to dial local test server: %v", err)
}
Expand Down Expand Up @@ -318,7 +320,14 @@ func (s) TestLoadReportingPickFirstMultiLocality(t *testing.T) {

// Stop server 1 and send one more rpc. Now the request should go to server 2.
server1.Stop()
client.EmptyCall(ctx, &testpb.Empty{}, grpc.Peer(&peer))
// The first call may go to server 1 and fail, so we send two requests.
if _, err := client.EmptyCall(ctx, &testpb.Empty{}, grpc.Peer(&peer)); err != nil {
t.Logf("First rpc EmptyCall() failed: %v", err)
}

if _, err := client.EmptyCall(ctx, &testpb.Empty{}, grpc.Peer(&peer)); err != nil {
t.Fatalf("rpc EmptyCall() failed: %v", err)
}

// Verify that the request was sent to server 2.
if got, want := testutils.ParsePort(t, peer.Addr.String()), port2; got != want {
Expand Down

0 comments on commit 503a123

Please sign in to comment.