Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.atlassian.performance.tools.ssh.api

import org.hamcrest.CoreMatchers.containsString
import org.junit.Assert
import org.junit.Test
import java.time.Duration
Expand Down Expand Up @@ -63,6 +64,29 @@ class SshTest {
}
}

@Test
fun shouldTimeOutWhenStopping() {
val uninterruptibleSleep = """
trap 'echo "got interrupted"' INT
for i in {1..10}
do
echo "sleeping... `date`"
sleep 1
done
""".trimIndent()
SshContainer().useSsh { sshHost ->
val backgroundSleep = sshHost.runInBackground(uninterruptibleSleep)
Thread.sleep(Duration.ofSeconds(3).toMillis())
try {
backgroundSleep.stop(Duration.ofSeconds(2))
Assert.fail("Expected to throw")
} catch (e: Exception) {
Assert.assertThat(e.message, containsString("sleeping"));
Assert.assertThat(e.message, containsString("^Cgot interrupted"));
}
}
}

private fun installPing(sshHost: Ssh) {
sshHost.newConnection().use { it.execute("apt-get update -qq && apt-get install iputils-ping -y") }
}
Expand Down