diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSClientAutobahnTest.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSClientAutobahnTest.scala index d4969eb21d..276c50ce61 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSClientAutobahnTest.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSClientAutobahnTest.scala @@ -57,7 +57,7 @@ object WSClientAutobahnTest extends App { } import Console._ info.flatMap { i ⇒ - val prefix = f"$YELLOW${i.caseInfo.id}%-7s$RESET - $WHITE${i.caseInfo.description}$RESET ... " + val prefix = f"$YELLOW${i.caseInfo.id}%-7s$RESET - $RESET${i.caseInfo.description}$RESET ... " //println(prefix) status.onComplete { @@ -102,6 +102,7 @@ object WSClientAutobahnTest extends App { def echo = Flow[Message].viaMat(completionSignal)(Keep.right) + import Console._ if (args.size >= 1) { // run one val testId = args(0) @@ -111,10 +112,10 @@ object WSClientAutobahnTest extends App { richRunCase(info.index) }.onComplete { case Success(res) ⇒ - println(s"Run successfully finished!") + println(s"[OK] Run successfully finished!") updateReportsAndShutdown() case Failure(e) ⇒ - println("Run failed with this exception") + println(s"[${RED}FAILED$RESET] Run failed with this exception: ") e.printStackTrace() updateReportsAndShutdown() } @@ -127,7 +128,6 @@ object WSClientAutobahnTest extends App { val grouped = results.groupBy(_.status.behavior) - import Console._ println(s"${results.size} tests run.") println() println(s"${GREEN}OK$RESET: ${grouped.getOrElse("OK", Nil).size}") @@ -136,7 +136,7 @@ object WSClientAutobahnTest extends App { case (status, cases) ⇒ println(s"$RED$status$RESET: ${cases.size}") } println() - println("Not OK tests") + println("Not OK tests: ") println() results.filterNot(_.status.behavior == "OK").foreach { r ⇒ println(f"$RED${r.status.behavior}%-20s$RESET $YELLOW${r.info.id}%-7s$RESET - $WHITE${r.info.description}$RESET") diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSServerAutobahnTest.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSServerAutobahnTest.scala index 85a3c26dee..3a352fa407 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSServerAutobahnTest.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/ws/WSServerAutobahnTest.scala @@ -19,6 +19,10 @@ object WSServerAutobahnTest extends App { implicit val system = ActorSystem("WSServerTest") implicit val fm = ActorMaterializer() + val host = sys.env.getOrElse("akka.ws-host", "127.0.0.1") + val port = sys.env.getOrElse("akka.ws-port", "9001").toInt + val mode = sys.env.getOrElse("akka.ws-mode", "read") // read or sleep + try { val binding = Http().bindAndHandleSync({ case req @ HttpRequest(GET, Uri.Path("/"), _, _, _) if req.header[UpgradeToWebsocket].isDefined ⇒ @@ -28,13 +32,16 @@ object WSServerAutobahnTest extends App { } case _: HttpRequest ⇒ HttpResponse(404, entity = "Unknown resource!") }, - interface = "172.17.42.1", // adapt to your docker host IP address if necessary - port = 9001) + interface = host, // adapt to your docker host IP address if necessary + port = port) - Await.result(binding, 1.second) // throws if binding fails - println("Server online at http://172.17.42.1:9001") - println("Press RETURN to stop...") - Console.readLine() + Await.result(binding, 3.second) // throws if binding fails + println(s"Server online at http://${host}:${port}") + mode match { + case "sleep" => while (true) Thread.sleep(1.minute.toMillis) + case "read" => Console.readLine("Press RETURN to stop...") + case _ => throw new Exception("akka.ws-mode MUST be sleep or read.") + } } finally { system.shutdown() }