test(agent): stop asserting the exit code of SSH sessions closed by agent shutdown (#31058)

This commit is contained in:
Michael Suchacz authored and GitHub committed 2026-10-20 20:45:01 +02:00
1 parent e53cfef864
commit aae5602ef4
2 files changed
+9 -11

No files matched your search

+6 -9
View File
@@ -4763,17 +4763,16 @@ func requireEcho(t *testing.T, conn net.Conn) int {
const (
wantSomeBytes int64 = -1
wantIgnoreBytes int64 = -2
// wantNonZeroCode accepts any non-zero disconnect status code, for
// disconnects whose code depends on how the platform reports a killed
// process.
wantNonZeroCode = -1
// wantIgnoreCode skips the disconnect status code check, for disconnects
// whose code depends on process timing.
wantIgnoreCode = -1
)
// assertConnectionReport expects the provided connect and disconnect events
// have been reported. If the disconnection bytes are wantSomeBytes, assert the
// bytes are > 0, if wantIgnoreBytes do not check the bytes, otherwise assert
// they match exactly. If the disconnect code is wantNonZeroCode, assert the
// status code is non-zero, otherwise assert it matches exactly.
// they match exactly. If the disconnect code is wantIgnoreCode, do not check
// the status code, otherwise assert it matches exactly.
func assertConnectionReport(t testing.TB, agentClient *agenttest.Client,
connect proto.ConnectEvent, disconnect proto.DisconnectEvent,
) {
@@ -4802,9 +4801,7 @@ func assertConnectionReport(t testing.TB, agentClient *agenttest.Client,
assert.NotEmpty(t, reports[0].GetConnection().GetIp(), "connect ip should not be empty")
assert.NotEmpty(t, reports[1].GetConnection().GetIp(), "disconnect ip should not be empty")
assert.Equal(t, 0, int(reports[0].GetConnection().GetStatusCode()), "connect status code should be 0")
if disconnect.Code == wantNonZeroCode {
assert.NotZero(t, reports[1].GetConnection().GetStatusCode(), "disconnect status code should be non-zero")
} else {
if disconnect.Code != wantIgnoreCode {
assert.Equal(t, disconnect.Code, int(reports[1].GetConnection().GetStatusCode()), "disconnect status code should be %d", disconnect.Code)
}
assert.Equal(t, "", reports[0].GetConnection().GetReason(), "connect reason should be empty")
+3 -2
View File
@@ -190,8 +190,9 @@ func TestAgent_SSHUpgrade(t *testing.T) {
// only the agent's report is checked.
require.NoError(t, agnt.Close())
reason = codersdk.DisconnectReasonServerShutdown
// The killed shell's exit code differs between platforms.
code = wantNonZeroCode
// The agent closes the shell's stdin before it signals the
// shell, so the shell can exit 0 first.
code = wantIgnoreCode
rxBytes = 10 // send "echo test\n"
} else {
_, err = stdin.Write([]byte("exit 0\n"))