File tree Expand file tree Collapse file tree
src/test/kotlin/com/atlassian/performance/tools/ssh/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,14 +56,24 @@ class SshTest {
5656 SshContainer ().useSsh { sshHost ->
5757 installPing(sshHost)
5858
59- val fail = sshHost.runInBackground(" nonexistent-command" )
60- val failResult = fail.stop(Duration .ofMillis(20 ))
59+ repeat(1000 ) {
60+ val fail = sshHost.runInBackground(" nonexistant-command" )
61+ sshHost.waitForAllProcessesToFinish(" nonexistant-command" , Duration .ofMillis(100 ))
62+ val failResult = fail.stop(Duration .ofMillis(20 ))
6163
62- Assert .assertEquals(127 , failResult.exitStatus)
64+ Assert .assertEquals(127 , failResult.exitStatus)
65+ }
6366 }
6467 }
6568
6669 private fun installPing (sshHost : Ssh ) {
6770 sshHost.newConnection().use { it.execute(" apt-get update -qq && apt-get install iputils-ping -y" ) }
6871 }
72+
73+ private fun Ssh.waitForAllProcessesToFinish (
74+ processCommand : String ,
75+ timeout : Duration
76+ ) = this .newConnection().use {
77+ it.execute(" wait `pgrep '$processCommand '`" , timeout)
78+ }
6979}
You can’t perform that action at this time.
0 commit comments