tests/run: fix flaky RunAttachTermination test#5303
Merged
laurazard merged 1 commit intodocker:masterfrom Jul 29, 2024
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5303 +/- ##
==========================================
- Coverage 61.45% 61.45% -0.01%
==========================================
Files 299 299
Lines 20856 20855 -1
==========================================
- Hits 12818 12816 -2
- Misses 7122 7124 +2
+ Partials 916 915 -1 |
Collaborator
Author
|
@thaJeztah @vvoland can you TAL? |
vvoland
reviewed
Jul 29, 2024
thaJeztah
reviewed
Jul 29, 2024
Member
thaJeztah
left a comment
There was a problem hiding this comment.
overall LGTM; left two comments / questions
60f51c1 to
3be9c8f
Compare
3be9c8f to
1b53d4c
Compare
Member
|
oh! LOL, I saw failures, and see you just pushed - probably need to remove the import as well |
1b53d4c to
2290f7a
Compare
Collaborator
Author
|
Turns out the version was set for a reason. I added a comment. Edit: aaahh I commented the wrong SHA. I'll fix it. |
This test was just incorrect (and testing incorrect behavior): it was checking that `docker run` exited with a `context canceled` error after signalling the CLI/cancelling the command's context, but this was incorrect (and was fixed in 991b130 - which was when this test started failing). However, since this test assertion was happening inside of a goroutine, it would sometimes pass if this assertion didn't get to run before the test suite terminated. It was flaky because sometimes this assertion inside the goroutine did get to execute, but after the test finished execution, which is a big no-no. As an aside, assertions inside goroutines are generally bad, and `govet` even has a linter for this (but it only catches `t.Fatal` and `t.FailNow` calls and not `assert.Xx`. Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2290f7a to
eac8357
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What I did
This test was just incorrect (and testing incorrect behavior): it was checking that
docker runexited with acontext cancelederror after signalling the CLI/cancelling the command's context, but this was incorrect (and was fixed in991b130 - which was when this test started failing).
However, since this test assertion was happening inside of a goroutine, it would sometimes pass if it didn't get to run before the test suite terminated. It was flaky because sometimes the assertion inside the goroutine did get to execute, but after the test finished execution, which is a big no-no.
As an aside, assertions inside goroutines are generally bad, and
goveteven has a check for this (but it only catchest.Fatalandt.FailNowcalls and notassert.Xx).- How I did it
Fixed
RunAttachTerminationto test for the correct behavior, and generally cleaned the tests up a bit. Also added another test for the general/not SIGINT'ed case.- How to verify it
go test -v -count=1 -run=TestRunAttach ./cli/command/container/...- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)