Skip to content

Commit e79bb92

Browse files
committed
JPERF-811: Fix flaky shouldTolerateEarlyFinish test by waiting until OS actually starts (and finishes) the process before interrupting it
1 parent 9e6442e commit e79bb92

File tree

1 file changed

+9
-1
lines changed
  • src/test/kotlin/com/atlassian/performance/tools/ssh/api

1 file changed

+9
-1
lines changed

src/test/kotlin/com/atlassian/performance/tools/ssh/api/SshTest.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class SshTest {
5656
SshContainer().useSsh { sshHost ->
5757
installPing(sshHost)
5858

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

6263
Assert.assertEquals(127, failResult.exitStatus)
@@ -66,4 +67,11 @@ class SshTest {
6667
private fun installPing(sshHost: Ssh) {
6768
sshHost.newConnection().use { it.execute("apt-get update -qq && apt-get install iputils-ping -y") }
6869
}
70+
71+
private fun Ssh.waitForAllProcessesToFinish(
72+
processCommand: String,
73+
timeout: Duration
74+
) = this.newConnection().use {
75+
it.execute("wait `pgrep '$processCommand'`", timeout)
76+
}
6977
}

0 commit comments

Comments
 (0)