From 5b463b89e59931405e31f99dd03cb30235d82100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=8E=E9=B8=A3?= Date: Sun, 8 Mar 2026 18:57:06 +0800 Subject: [PATCH] Fix NonBalancingIntegrationSpec flakiness Port upstream akka/akka-grpc@93c78cd4. Add a 250ms sleep after server termination to allow unbind to fully complete before restarting on the same port. Also simplify the second connection wait to use futureValue with explicit timeout, removing the Netty-specific flakiness workaround. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../grpc/scaladsl/NonBalancingIntegrationSpec.scala | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/interop-tests/src/test/scala/org/apache/pekko/grpc/scaladsl/NonBalancingIntegrationSpec.scala b/interop-tests/src/test/scala/org/apache/pekko/grpc/scaladsl/NonBalancingIntegrationSpec.scala index 1c3079f8f..73089decd 100644 --- a/interop-tests/src/test/scala/org/apache/pekko/grpc/scaladsl/NonBalancingIntegrationSpec.scala +++ b/interop-tests/src/test/scala/org/apache/pekko/grpc/scaladsl/NonBalancingIntegrationSpec.scala @@ -87,20 +87,15 @@ class NonBalancingIntegrationSpec(backend: String) Future.sequence(requestsOnFirstConnection).futureValue server1.terminate(5.seconds).futureValue + // Give it some time to complete unbind (suspected to cause test flakyness) + Thread.sleep(250) // And restart Http().newServerAt("127.0.0.1", server1.localAddress.getPort).bind(GreeterServiceHandler(service1)).futureValue val requestsOnSecondConnection = List.fill(requestsPerConnection)(client.sayHello(HelloRequest(s"Hello"))) - val replies = Future.sequence(requestsOnSecondConnection) - Await.ready(replies, 15.seconds) - - if (this.isInstanceOf[NonBalancingIntegrationSpecNetty] && service1.greetings.get != numberOfRequests) { - system.log.warning( - s"Found only ${service1.greetings.get} requests rather than $numberOfRequests, likely a flaky test") - pending - } else - service1.greetings.get should be(numberOfRequests) + Future.sequence(requestsOnSecondConnection).futureValue(timeout(15.seconds)) + service1.greetings.get should be(numberOfRequests) } "re-discover endpoints on failure" in {