-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TestPostContainersAttach: minor improvements #36612
Conversation
Codecov Report
@@ Coverage Diff @@
## master #36612 +/- ##
=========================================
Coverage ? 35.08%
=========================================
Files ? 615
Lines ? 45780
Branches ? 0
=========================================
Hits ? 16062
Misses ? 27611
Partials ? 2107 |
@kolyshkin could this have any relation to #36517 ? |
OK, the amended test revealed the error is returned from StdRead (that was previously ignored):
|
It certainly might; let's see if reverting it will help |
OK, two rounds with commit 3798392 ("Ensure a hijacked connection implements CloseWrite whenever its underlying") reverted shows no failures (with my modified test). It's still not too many runs though. Let's try without the revert now. |
Win CI timed out, experimental has some unrelated failures. I am currently out of ideas for this one. |
@kolyshkin FYI #36663 |
@tonistiigi thanks! Also, the intermittent nature of the test case failure is explained by whether there's something in the buffer; if it is empty (which in our CI sometimes happens on slower hardware) the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐯
c.Assert(actualStdout.Bytes(), checker.DeepEquals, []byte("hello\nsuccess"), check.Commentf("Attach didn't return the expected data from stdout")) | ||
var outBuf, errBuf bytes.Buffer | ||
_, err = stdcopy.StdCopy(&outBuf, &errBuf, resp.Reader) | ||
if errors.Cause(err).(net.Error).Timeout() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would panic if err
is nil, is that an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you, I have updated the commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
When this test fails, the error looks like this: > FAIL: docker_api_attach_test.go:98: DockerSuite.TestPostContainersAttach > docker_api_attach_test.go:211: > c.Assert(actualStdout.Bytes(), checker.DeepEquals, []byte("hello\nsuccess"), check.Commentf("Attach didn't return the expected data from stdout")) > ... obtained []uint8 = []byte{0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73} > ... expected []uint8 = []byte{0x68, 0x65, 0x6c, 0x6c, 0x6f, 0xa, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73} > ... Attach didn't return the expected data from stdout Let's use strings for comparisons to make the output more readable. While at it, - get the container's stderr as well, and make sure it's empty; - check that stdcopy.StdCopy() did not return an error, except for the timeout which is expected; - move/remove comments, simplify var names. Signed-off-by: Kir Kolyshkin <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The API part of this test (the last test case in TestPostContainerAttach) is flaky, i.e. it sometimes fails on powerpc or s390 like this:
Is seems that "success" is returned but "hello\n" is not (as if ContainerAttachOptions.Logs was false).
After a careful code audit I still can't figure out why it fails. The two major differences from the other cases are:
Nevertheless it looks almost legit, except for ignoring the error from StdCopy. So I don't know how to fix it. Still, there are some things that can be improved here, including:
Get the container's stderr as well, make sure it's empty.
Check that stdcopy.StdCopy() did not return an error.
Use strings, so the test output will be more readable.
Nitpicks; move/remove comments, simplify var names.
This should ultimately fix #36611