Skip to content

Commit

Permalink
Don't return from the client until nailgun server is down
Browse files Browse the repository at this point in the history
I think this is one of the reasons why our nailgun-based test infrastructure has been traditionally not very stable. Let's see if this fixes it.
  • Loading branch information
jvican committed May 2, 2018
1 parent 6ae0e49 commit 42d0f10
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/test/scala/bloop/nailgun/NailgunTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ abstract class NailgunTest {
val errStream = new PrintStream(ProcessLogger.toOutputStream(log.serverError))

val serverIsStarted = scala.concurrent.Promise[Unit]()
val serverIsFinished = scala.concurrent.Promise[Unit]()
val serverLogic = Task {
var optServer: Option[NGServer] = None

Expand All @@ -63,6 +64,7 @@ abstract class NailgunTest {
val server = optServer.getOrElse(sys.error("The nailgun server failed to initialize!"))
serverIsStarted.success(())
server.run()
serverIsFinished.success(())
}

val client = new Client(TEST_PORT, log, config)
Expand All @@ -75,8 +77,10 @@ abstract class NailgunTest {
errStream.flush()
})

val trigger = Task.fromFuture(serverIsStarted.future)
val f = Task.zip2(serverLogic, trigger.flatMap(_ => clientLogic)).runAsync(nailgunPool)
val startTrigger = Task.fromFuture(serverIsStarted.future)
val endTrigger = Task.fromFuture(serverIsFinished.future)
val runClient = startTrigger.flatMap(_ => clientLogic.flatMap(_ => endTrigger))
val f = Task.zip2(serverLogic, startTrigger.flatMap(_ => clientLogic)).runAsync(nailgunPool)
Await.result(f, FiniteDuration(60, TimeUnit.SECONDS))._2
}

Expand Down

0 comments on commit 42d0f10

Please sign in to comment.