From efa7dd8422ca712cbd73d014f45f9718e3e04cb7 Mon Sep 17 00:00:00 2001 From: Peter Vlugter Date: Tue, 2 Feb 2021 13:49:34 +1300 Subject: [PATCH] Report last error on waiting for TCK implementation start --- .../testkit/discovery/InterceptEntityDiscovery.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/testkit/src/main/scala/io/cloudstate/testkit/discovery/InterceptEntityDiscovery.scala b/testkit/src/main/scala/io/cloudstate/testkit/discovery/InterceptEntityDiscovery.scala index c0d8111d0..3562cb3c9 100644 --- a/testkit/src/main/scala/io/cloudstate/testkit/discovery/InterceptEntityDiscovery.scala +++ b/testkit/src/main/scala/io/cloudstate/testkit/discovery/InterceptEntityDiscovery.scala @@ -29,7 +29,7 @@ import io.cloudstate.testkit.InterceptService.InterceptorContext import scala.concurrent.duration.FiniteDuration import scala.concurrent.{Await, Future} -import scala.util.{Failure, Success} +import scala.util.{Failure, Success, Try} final class InterceptEntityDiscovery(context: InterceptorContext) { import InterceptEntityDiscovery._ @@ -88,7 +88,13 @@ object InterceptEntityDiscovery { def expectOnline(context: InterceptorContext, timeout: FiniteDuration): Unit = { val client = EntityDiscoveryClient(context.clientSettings)(context.system) - try TestKit.awaitCond(Await.ready(client.discover(testProxyInfo), timeout).value.get.isSuccess, timeout) - finally client.close() + try { + var discovery: Try[EntitySpec] = null + if (!TestKit.awaitCond({ + discovery = Await.ready(client.discover(testProxyInfo), timeout).value.get + discovery.isSuccess + }, timeout, noThrow = true)) + throw new AssertionError(s"No discovery after $timeout, last error: ${discovery.failed.get.getMessage}") + } finally client.close() } }