Skip to content

Commit

Permalink
JPERF-811: Fix flaky shouldTolerateEarlyFinish test by waiting until …
Browse files Browse the repository at this point in the history
…OS actually starts (and finishes) the process before interrupting it
  • Loading branch information
pczuj committed Jun 28, 2022
1 parent 9e6442e commit e79bb92
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class SshTest {
SshContainer().useSsh { sshHost ->
installPing(sshHost)

val fail = sshHost.runInBackground("nonexistent-command")
val fail = sshHost.runInBackground("nonexistant-command")
sshHost.waitForAllProcessesToFinish("nonexistant-command", Duration.ofMillis(100))
val failResult = fail.stop(Duration.ofMillis(20))

Assert.assertEquals(127, failResult.exitStatus)
Expand All @@ -66,4 +67,11 @@ class SshTest {
private fun installPing(sshHost: Ssh) {
sshHost.newConnection().use { it.execute("apt-get update -qq && apt-get install iputils-ping -y") }
}

private fun Ssh.waitForAllProcessesToFinish(
processCommand: String,
timeout: Duration
) = this.newConnection().use {
it.execute("wait `pgrep '$processCommand'`", timeout)
}
}

0 comments on commit e79bb92

Please sign in to comment.