Skip to content

Commit 89e6611

Browse files
authored
Fix load balancing flaky test (#2223)
1 parent a61e11f commit 89e6611

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

test/FunctionalTests/Balancer/PickFirstBalancerTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ Task<HelloReply> UnaryMethod(HelloRequest request, ServerCallContext context)
138138
Logger.LogInformation("Ending " + endpoint.Address);
139139
endpoint.Dispose();
140140

141+
// Wait for client to change to idle state in reaction to server stopping.
142+
await BalancerWaitHelpers.WaitForChannelStateAsync(Logger, channel, ConnectivityState.Idle).DefaultTimeout();
143+
141144
Logger.LogInformation("Restarting");
142145
using var endpointNew = BalancerHelpers.CreateGrpcEndpoint<HelloRequest, HelloReply>(50051, UnaryMethod, nameof(UnaryMethod));
143146

@@ -180,6 +183,9 @@ Task<HelloReply> UnaryMethod(HelloRequest request, ServerCallContext context)
180183
Logger.LogInformation("Ending " + endpoint.Address);
181184
endpoint.Dispose();
182185

186+
// Wait for client to change to idle state in reaction to server stopping.
187+
await BalancerWaitHelpers.WaitForChannelStateAsync(Logger, channel, ConnectivityState.Idle).DefaultTimeout();
188+
183189
var ex = await ExceptionAssert.ThrowsAsync<RpcException>(
184190
() => client.UnaryCall(new HelloRequest { Name = "Balancer" }).ResponseAsync).DefaultTimeout();
185191

0 commit comments

Comments
 (0)