docker / cli

The Docker CLI
Apache License 2.0
4.95k stars 1.93k forks source link

Flaky test: TestInitTtySizeErrors / TestRunAttachTermination #5254

Open thaJeztah opened 4 months ago

thaJeztah commented 4 months ago

Description

Looks like this test has become flaky again, but .. different; e.g. seen failing on https://github.com/docker/cli/pull/5238

#20 60.67 === FAIL: cli/command/container TestInitTtySizeErrors (unknown)
#20 60.67 Error: write /dev/pts/0: file already closed
#20 60.67 panic: Fail in goroutine after TestRunAttachTermination has completed
#20 60.67 
#20 60.67 goroutine 216 [running]:
#20 60.67 testing.(*common).Fail(0xc00021eb60)
#20 60.67   /usr/local/go/src/testing/testing.go:952 +0xd4
#20 60.67 testing.(*common).FailNow(0xc00021eb60)
#20 60.67   /usr/local/go/src/testing/testing.go:975 +0x26
#20 60.67 github.com/docker/cli/vendor/gotest.tools/v3/assert.ErrorIs({0x1033010, 0xc00021eb60}, {0x102a300?, 0xc00049a0f0}, {0x102a3e0?, 0x16e0f30}, {0x0, 0x0, 0x0})
#20 60.67   /go/src/github.com/docker/cli/vendor/gotest.tools/v3/assert/assert.go:311 +0x159
#20 60.67 github.com/docker/cli/cli/command/container.TestRunAttachTermination.func6()
#20 60.67   /go/src/github.com/docker/cli/cli/command/container/run_test.go:85 +0x85
#20 60.67 created by github.com/docker/cli/cli/command/container.TestRunAttachTermination in goroutine 214
#20 60.67   /go/src/github.com/docker/cli/cli/command/container/run_test.go:84 +0x486
vvoland commented 4 months ago

Looks like the main test goroutine exits before the child goroutine: https://github.com/docker/cli/blob/3f0d90a2a939afa04a784b810dbdb035a0dff669/cli/command/container/run_test.go#L85-L87

Also, the assert.ErrorIs should only be called in the main goroutine .

I gave it a quick try and synchronized this with a channel, see: https://github.com/docker/cli/commit/c032138ab13bc7c0d26b13ad815aec29709d1585

Looks like the cmd.ExecuteContext doesn't return at all:

root@docker-cli-dev$ go test -run TestRunAttachTermination -v .
=== RUN   TestRunAttachTermination
    run_test.go:107: cmd.ExecuteContext was not finished before the 5 second timeout
--- FAIL: TestRunAttachTermination (5.01s)
FAIL
FAIL    github.com/docker/cli/cli/command/container     5.014s
FAIL

@Benehiko PTAL

Benehiko commented 4 months ago

I'll take a look when I get the chance

thaJeztah commented 1 month ago
59.68 === Failed
59.68 === FAIL: cli/command/container TestRunAttachTermination (unknown)
59.68 signal: interrupt
59.68 
59.68 DONE 2006 tests, 3 skipped, 1 failure in 59.329s