Merge pull request #19073 from ktoso/wip-jenkins-autobahn-ktoso

=htc #18563 small fixes to make autobahn tests nicer to Jenkins
This commit is contained in:
Konrad Malawski 2015-12-03 02:13:40 +01:00
commit b01ab24959
2 changed files with 18 additions and 11 deletions

View file

@ -57,7 +57,7 @@ object WSClientAutobahnTest extends App {
} }
import Console._ import Console._
info.flatMap { i 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) //println(prefix)
status.onComplete { status.onComplete {
@ -102,6 +102,7 @@ object WSClientAutobahnTest extends App {
def echo = Flow[Message].viaMat(completionSignal)(Keep.right) def echo = Flow[Message].viaMat(completionSignal)(Keep.right)
import Console._
if (args.size >= 1) { if (args.size >= 1) {
// run one // run one
val testId = args(0) val testId = args(0)
@ -111,10 +112,10 @@ object WSClientAutobahnTest extends App {
richRunCase(info.index) richRunCase(info.index)
}.onComplete { }.onComplete {
case Success(res) case Success(res)
println(s"Run successfully finished!") println(s"[OK] Run successfully finished!")
updateReportsAndShutdown() updateReportsAndShutdown()
case Failure(e) case Failure(e)
println("Run failed with this exception") println(s"[${RED}FAILED$RESET] Run failed with this exception: ")
e.printStackTrace() e.printStackTrace()
updateReportsAndShutdown() updateReportsAndShutdown()
} }
@ -127,7 +128,6 @@ object WSClientAutobahnTest extends App {
val grouped = val grouped =
results.groupBy(_.status.behavior) results.groupBy(_.status.behavior)
import Console._
println(s"${results.size} tests run.") println(s"${results.size} tests run.")
println() println()
println(s"${GREEN}OK$RESET: ${grouped.getOrElse("OK", Nil).size}") 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}") case (status, cases) println(s"$RED$status$RESET: ${cases.size}")
} }
println() println()
println("Not OK tests") println("Not OK tests: ")
println() println()
results.filterNot(_.status.behavior == "OK").foreach { r 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") println(f"$RED${r.status.behavior}%-20s$RESET $YELLOW${r.info.id}%-7s$RESET - $WHITE${r.info.description}$RESET")

View file

@ -19,6 +19,10 @@ object WSServerAutobahnTest extends App {
implicit val system = ActorSystem("WSServerTest") implicit val system = ActorSystem("WSServerTest")
implicit val fm = ActorMaterializer() 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 { try {
val binding = Http().bindAndHandleSync({ val binding = Http().bindAndHandleSync({
case req @ HttpRequest(GET, Uri.Path("/"), _, _, _) if req.header[UpgradeToWebsocket].isDefined 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!") case _: HttpRequest HttpResponse(404, entity = "Unknown resource!")
}, },
interface = "172.17.42.1", // adapt to your docker host IP address if necessary interface = host, // adapt to your docker host IP address if necessary
port = 9001) port = port)
Await.result(binding, 1.second) // throws if binding fails Await.result(binding, 3.second) // throws if binding fails
println("Server online at http://172.17.42.1:9001") println(s"Server online at http://${host}:${port}")
println("Press RETURN to stop...") mode match {
Console.readLine() 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 { } finally {
system.shutdown() system.shutdown()
} }