Skip to content

Commit aec6df8

Browse files
authored
fix: e2e/alloc_logs: fail test if error is nil (#26980)
The comment was correct: // Run the alloc logs command which we expect to capture both stdout and // stderr logs. The command will reach its timeout and therefore return an // error. We want to ignore this, as it's expected. Any other error is // terminal. but the test was actually passing if the command was not returning an error.
1 parent 12f6941 commit aec6df8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

e2e/alloc_logs/alloc_logs_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ func testMixedFollow(t *testing.T) {
4141
// error. We want to ignore this, as it's expected. Any other error is
4242
// terminal.
4343
out, err := e2eutil.Command("nomad", "alloc", "logs", "-f", allocStubs[0].ID)
44-
if err != nil {
45-
must.ErrorContains(t, err, "failed: signal: killed")
46-
}
44+
must.ErrorContains(t, err, "failed: signal: killed")
4745
must.StrContains(t, out, "stdout\nstderr")
4846
}

e2e/e2eutil/cli.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ import (
2020
)
2121

2222
// Command sends a command line argument to Nomad and returns the unbuffered
23-
// stdout as a string (or, if there's an error, the stderr)
23+
// stdout as a string (or, if there's an error, the stderr).
24+
// If the timeout expires, exec.CommandContext will send a kill signal to the process,
25+
// so the error will contain the string "signal: killed".
2426
func Command(cmd string, args ...string) (string, error) {
2527
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
2628
defer cancel()

0 commit comments

Comments
 (0)