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,7 +1,11 @@
package com.atlassian.performance.tools.ssh.api

import org.apache.logging.log4j.Level
import org.junit.Assert
import org.junit.Test
import java.lang.Exception
import java.time.Duration
import java.time.Instant

class SshConnectionTest {

Expand All @@ -14,4 +18,18 @@ class SshConnectionTest {
Assert.assertEquals(sshResult.output, "test\n")
}
}

@Test
fun shouldRespectTimeouts() {
SshContainer().useConnection { ssh: SshConnection ->
val start = Instant.now()
try {
ssh.execute("sleep 100", Duration.ofSeconds(1), Level.OFF, Level.OFF)
}catch (e : Exception){
//ignore
}
val executeDuration = Duration.between( start, Instant.now())
Assert.assertTrue(executeDuration < Duration.ofSeconds(10))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😲

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that sshj sends SSH_MSG_CHANNEL_CLOSE as per https://www.ietf.org/rfc/rfc4254.txt but it doesn't receive the same message in response. Sshj waits 30 seconds before timeout. I need to Wireshark it to get more details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And it seems to be related to our "Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)" problem. Ubuntu doesn't close the connection and doesn't kill the apt process.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, that's super interesting
I'm glad you found it

}
}
}