From 054960f07d5533073bdac7da5d9b601de628f424 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 2 Aug 2023 14:49:17 +0800 Subject: [PATCH 1/2] Fix load balancing flaky test --- test/FunctionalTests/Balancer/PickFirstBalancerTests.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs b/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs index f26685e12..2bc4553b0 100644 --- a/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs +++ b/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs @@ -138,6 +138,8 @@ Task UnaryMethod(HelloRequest request, ServerCallContext context) Logger.LogInformation("Ending " + endpoint.Address); endpoint.Dispose(); + await BalancerWaitHelpers.WaitForChannelStateAsync(Logger, channel, ConnectivityState.Idle).DefaultTimeout(); + Logger.LogInformation("Restarting"); using var endpointNew = BalancerHelpers.CreateGrpcEndpoint(50051, UnaryMethod, nameof(UnaryMethod)); @@ -180,6 +182,9 @@ Task UnaryMethod(HelloRequest request, ServerCallContext context) Logger.LogInformation("Ending " + endpoint.Address); endpoint.Dispose(); + // Wait for client to change to idle state in reaction to server stopping. + await BalancerWaitHelpers.WaitForChannelStateAsync(Logger, channel, ConnectivityState.Idle).DefaultTimeout(); + var ex = await ExceptionAssert.ThrowsAsync( () => client.UnaryCall(new HelloRequest { Name = "Balancer" }).ResponseAsync).DefaultTimeout(); From bb032bb5420d792717eabff111f06e8c0e3d7f7f Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 2 Aug 2023 14:49:54 +0800 Subject: [PATCH 2/2] Update --- test/FunctionalTests/Balancer/PickFirstBalancerTests.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs b/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs index 2bc4553b0..611f68349 100644 --- a/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs +++ b/test/FunctionalTests/Balancer/PickFirstBalancerTests.cs @@ -138,6 +138,7 @@ Task UnaryMethod(HelloRequest request, ServerCallContext context) Logger.LogInformation("Ending " + endpoint.Address); endpoint.Dispose(); + // Wait for client to change to idle state in reaction to server stopping. await BalancerWaitHelpers.WaitForChannelStateAsync(Logger, channel, ConnectivityState.Idle).DefaultTimeout(); Logger.LogInformation("Restarting");