Fix integration tests and integration cli to run on older versions#37003
Conversation
|
Please sign your commits following these rules: $ git clone -b "fix-integration-cli-for-e2e" [email protected]:AntaresS/moby.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353342328
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -fAmending updates the existing PR. You DO NOT need to open a new one. |
|
rebase in progress... |
1660bb6 to
53ad53c
Compare
c6781cf to
3c194d9
Compare
Codecov Report
@@ Coverage Diff @@
## master #37003 +/- ##
==========================================
+ Coverage 35.34% 35.35% +<.01%
==========================================
Files 615 615
Lines 45818 45818
==========================================
+ Hits 16196 16199 +3
+ Misses 27470 27468 -2
+ Partials 2152 2151 -1 |
3c194d9 to
7ecac1e
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
didn't do a full review; just some things that stood out
There was a problem hiding this comment.
Both old and new API have the same status code here?
There was a problem hiding this comment.
formatting of else - needs a space
There was a problem hiding this comment.
Wonder if we should actually backport the fix for this status; 500 may be due to a bug / not properly handled condition
There was a problem hiding this comment.
@AntaresS agree that we should look at what the old test was testing, I doubt we were testing for 500.
There was a problem hiding this comment.
@thaJeztah Yeah checked the history of that change - ebcb7d6#diff-ca97ecb464e792b1086fca2ee8af23f8L676
It was not a bug fix but essentially a big change in API error returning code. So we are fine on this.
There was a problem hiding this comment.
Hm, right, it's a bit tricky, because it's effectively not related to the API version, but to the version of the daemon that's running (i.e., the "internal server error" was caused by an unhandled error condition, so defaulted to a 500). i.e. using API version 1.31 (or older) on a current version of the daemon would still have the fix, so will return http.StatusBadRequest.
Was thinking if we should do a statuscode != 200 or status code >= 400, but then we'd miss possible regressions if a 500 is returned on the current codebase.
There was a problem hiding this comment.
I tend to agree with @thaJeztah… if it's not related to the API version we shouldn't check the API version.. We could also check the dockerd version number (or the version field in the info endpoint for a cleaner way of doing the check) and act based on that ?
There was a problem hiding this comment.
@vdemeester @thaJeztah how about we add a TODO explaining the problem. I agree with both of you, there's just not a great way of doing order comparisons between dockerd versions. We can find a proper fix in a followup?
There was a problem hiding this comment.
@AntaresS ok let's fix this by only asserting the correct error, if API ≥ 1.32.
There was a problem hiding this comment.
Discussing with @tiborvass ; perhaps we should do a "negative" check to be more factual; basically, we want to check that the request didn't succeed / wasn't successful, so, e.g.:
c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
or perhaps check for > 404
There was a problem hiding this comment.
(In a follow-up: adding a TODO for now SGTM)
There was a problem hiding this comment.
@thaJeztah @tiborvass OK here is what I did. Let's check the correct status code for only API ≥ 1.32 for now. I added TODO for future reference.
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest)
} else {
c.Assert(res.StatusCode, checker.Not(checker.Equals), http.StatusOK)
}
There was a problem hiding this comment.
may want to look at backporting the fix
8dbfc1c to
417b74f
Compare
There was a problem hiding this comment.
could be a onliner :
skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.31"), "new feature added in 1.31, go version `s", testEnv.DaemonAPIVersion())(not even sure we need to print the current version)
There was a problem hiding this comment.
Ah, yes that's better than the testRequires() 👍
There was a problem hiding this comment.
oh right but it's with check so might not work 😭
There was a problem hiding this comment.
@vdemeester bingo. skip.If won't work here. They use two different interfaces.
There was a problem hiding this comment.
@AntaresS yep sorry about that, was thinking it was on integration tests 😛
There was a problem hiding this comment.
I tend to agree with @thaJeztah… if it's not related to the API version we shouldn't check the API version.. We could also check the dockerd version number (or the version field in the info endpoint for a cleaner way of doing the check) and act based on that ?
There was a problem hiding this comment.
Same as above for oneliner 👼
There was a problem hiding this comment.
Same as the reply above 😸
There was a problem hiding this comment.
Could be;
testRequires(c, MinimumAPIVersion("1.34"))
There was a problem hiding this comment.
Is it API based or docker daemon version dependent ?
There was a problem hiding this comment.
We could have only one assertion and just check and have the Err in a variable 👼
There was a problem hiding this comment.
Same as above for oneliner 👼
There was a problem hiding this comment.
nit: should this be testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) ? (looks like that's the approach taken in other locations)
There was a problem hiding this comment.
This seems a bit brittle (was it only in 18.05, or also in 18.04?). Note that 18.05 was an edge release, and reaches EOL soon, so we should remove this after that
There was a problem hiding this comment.
@thaJeztah Yes. I tend to treat this as a temporary skip check. Because what really happened was this test case was modified 10 days ago according to a bug fix (in 18.06), and it was not backported to 18.05.0. Therefore, ce-test in the e2e test matrix will fail but not ce-nightly.
I'll update this with a todo comment and remove this condition once the versions push forward.
There was a problem hiding this comment.
Would it be sufficient to check for invalid container format container:<name|id>" ?
There was a problem hiding this comment.
@thaJeztah That's actually true. Now I wonder why it was even changed from invalid to Invalid.
Aren't we following the error string convention -https://github.com/golang/go/wiki/CodeReviewComments#error-strings.
But the changes were made in #33320.
There was a problem hiding this comment.
Good question; we should probably change that back
There was a problem hiding this comment.
nit: should this be testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) ? (looks like that's the approach taken in other locations)
There was a problem hiding this comment.
This looks odd; This looks like we're testing if a bug is present. I'd rather skip a test than testing bugs
There was a problem hiding this comment.
@AntaresS would you mind adding an explanatory comment for the negative value, both here...
There was a problem hiding this comment.
See above re: testing for bugs
There was a problem hiding this comment.
Perhaps
if versions.GreaterThan(testEnv.DaemonAPIVersion(), "1.35") && testEnv.OSType != "windows" {
// The ordering here is due to `PATH` being overridden from the container's
// ENV. On windows, the container doesn't have a `PATH` ENV variable so
// the ordering is the same as the cli.
expectedEnv = "[PATH=/foo DEBUG=true test=1]"
}There was a problem hiding this comment.
Slightly less DRY:
res, body, err := request.Post("/containers/"+name+"/start", request.JSONBody(config))
c.Assert(err, checker.IsNil)
c.Assert(res.StatusCode, checker.Equals, http.StatusBadRequest)
if versions.GreaterThanOrEqualTo(testEnv.DaemonAPIVersion(), "1.32") {
// assertions below won't work before 1.32
buf, err := request.ReadBody(body)
c.Assert(err, checker.IsNil)
c.Assert(string(buf), checker.Contains, "was deprecated since API v1.22")
}There was a problem hiding this comment.
Curious: SUSE has /sys/module/apparmor/parameters/enabled, but we consider Apparmor to not be present?
There was a problem hiding this comment.
@thaJeztah yes. I asked @andrewhsu and it seems that we don't really support apparmor stuff on SUSE.
There was a problem hiding this comment.
In that case; should we disable it on the host?
There was a problem hiding this comment.
@thaJeztah In theory, yes, I need to reach out Rusell to disable it when testkit provision the testing environment.
There was a problem hiding this comment.
@thaJeztah I agree it's not ideal. Maybe we could check the existence of the apparmor profile for docker instead of just checking whether apparmor is enabled. Do you think we can do that in a followup?
7d89ca6 to
8047c3f
Compare
thaJeztah
left a comment
There was a problem hiding this comment.
Two minor nits, and it's probably good to add TODO's (as discussed above), but LGTM after those are done
e2709f7 to
d1f525d
Compare
There was a problem hiding this comment.
@AntaresS little typo. We should also explain that this will check that the status is NOT equal to http.StatusCreated.
There was a problem hiding this comment.
@AntaresS comment missing here. You can just copy from the other one.
Signed-off-by: Anda Xu <[email protected]> Co-authored-by: Anda Xu <[email protected]> Co-authored-by: Tibor Vass <[email protected]>
d1f525d to
e440831
Compare
|
LGTM |
- What I did
Fix
integrationtests andintegration-clitests to run on older versions (e.g. 17.06-ee) with @tiborvass- How I did it
Add version requirements in some failed tests and skip tests that are not runnable in older versions.
- How to verify it
Run the whole test suit accross a version/platform matix.
- Description for the changelog
Fixing failed
integrationandintegration-clitests against older engine versions.- A picture of a cute animal (not mandatory but encouraged)