Skip to content

Fix integration tests and integration cli to run on older versions#37003

Merged
anusha-ragunathan merged 1 commit intomoby:masterfrom
AntaresS:fix-integration-cli-for-e2e
May 16, 2018
Merged

Fix integration tests and integration cli to run on older versions#37003
anusha-ragunathan merged 1 commit intomoby:masterfrom
AntaresS:fix-integration-cli-for-e2e

Conversation

@AntaresS
Copy link
Copy Markdown
Contributor

@AntaresS AntaresS commented May 4, 2018

- What I did
Fix integration tests and integration-cli tests 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 integration and integration-cli tests against older engine versions.

- A picture of a cute animal (not mandatory but encouraged)

@AntaresS AntaresS requested a review from vdemeester as a code owner May 4, 2018 21:07
@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label May 4, 2018
@GordonTheTurtle
Copy link
Copy Markdown

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ 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 -f

Amending updates the existing PR. You DO NOT need to open a new one.

@GordonTheTurtle GordonTheTurtle added status/0-triage dco/no Automatically set by a bot when one of the commits lacks proper signature labels May 4, 2018
@AntaresS
Copy link
Copy Markdown
Contributor Author

AntaresS commented May 4, 2018

rebase in progress...

@AntaresS AntaresS force-pushed the fix-integration-cli-for-e2e branch from 1660bb6 to 53ad53c Compare May 4, 2018 21:13
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label May 4, 2018
@AntaresS AntaresS force-pushed the fix-integration-cli-for-e2e branch 4 times, most recently from c6781cf to 3c194d9 Compare May 4, 2018 22:01
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2018

Codecov Report

Merging #37003 into master will increase coverage by <.01%.
The diff coverage is n/a.

@@            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

Comment thread pkg/term/proxy_test.go Outdated
Copy link
Copy Markdown
Contributor

@tiborvass tiborvass May 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS Why these changes in pkg/term?

@AntaresS AntaresS force-pushed the fix-integration-cli-for-e2e branch from 3c194d9 to 7ecac1e Compare May 4, 2018 23:20
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

didn't do a full review; just some things that stood out

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both old and new API have the same status code here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting of else - needs a space

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here (space)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should actually backport the fix for this status; 500 may be due to a bug / not properly handled condition

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS agree that we should look at what the old test was testing, I doubt we were testing for 500.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS ok let's fix this by only asserting the correct error, if API ≥ 1.32.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(In a follow-up: adding a TODO for now SGTM)

Copy link
Copy Markdown
Contributor Author

@AntaresS AntaresS May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here (space)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here (couple more below)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may want to look at backporting the fix

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah not in this PR

@AntaresS AntaresS force-pushed the fix-integration-cli-for-e2e branch 9 times, most recently from 8dbfc1c to 417b74f Compare May 12, 2018 05:55
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes that's better than the testRequires() 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right but it's with check so might not work 😭

Copy link
Copy Markdown
Contributor Author

@AntaresS AntaresS May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vdemeester bingo. skip.If won't work here. They use two different interfaces.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS yep sorry about that, was thinking it was on integration tests 😛

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ?

Comment thread integration-cli/docker_api_logs_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above for oneliner 👼

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the reply above 😸

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be;

testRequires(c, MinimumAPIVersion("1.34"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it API based or docker daemon version dependent ?

Comment thread integration-cli/docker_cli_ps_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have only one assertion and just check and have the Err in a variable 👼

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread integration-cli/docker_cli_ps_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above for oneliner 👼

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😓

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vdemeester lolz..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this be testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) ? (looks like that's the approach taken in other locations)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be sufficient to check for invalid container format container:<name|id>" ?

Copy link
Copy Markdown
Contributor Author

@AntaresS AntaresS May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question; we should probably change that back

Comment thread integration-cli/docker_cli_ps_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray blank line here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread integration-cli/docker_cli_ps_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should this be testRequires(c, DaemonIsLinux, MinimumAPIVersion("1.31")) ? (looks like that's the approach taken in other locations)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd; This looks like we're testing if a bug is present. I'd rather skip a test than testing bugs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS would you mind adding an explanatory comment for the negative value, both here...

Copy link
Copy Markdown
Contributor Author

@AntaresS AntaresS May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiborvass yes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above re: testing for bugs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS ... and here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]"
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread integration-cli/requirements_test.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious: SUSE has /sys/module/apparmor/parameters/enabled, but we consider Apparmor to not be present?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah yes. I asked @andrewhsu and it seems that we don't really support apparmor stuff on SUSE.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case; should we disable it on the host?

Copy link
Copy Markdown
Contributor Author

@AntaresS AntaresS May 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thaJeztah In theory, yes, I need to reach out Rusell to disable it when testkit provision the testing environment.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

@AntaresS AntaresS force-pushed the fix-integration-cli-for-e2e branch 2 times, most recently from 7d89ca6 to 8047c3f Compare May 15, 2018 21:35
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use strings.ToLower() here

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor nits, and it's probably good to add TODO's (as discussed above), but LGTM after those are done

@AntaresS AntaresS force-pushed the fix-integration-cli-for-e2e branch 3 times, most recently from e2709f7 to d1f525d Compare May 15, 2018 22:52
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS little typo. We should also explain that this will check that the status is NOT equal to http.StatusCreated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Copy Markdown
Contributor

@tiborvass tiborvass May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AntaresS comment missing here. You can just copy from the other one.

Copy link
Copy Markdown
Contributor Author

@AntaresS AntaresS May 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Signed-off-by: Anda Xu <[email protected]>

Co-authored-by: Anda Xu <[email protected]>
Co-authored-by: Tibor Vass <[email protected]>
@AntaresS AntaresS force-pushed the fix-integration-cli-for-e2e branch from d1f525d to e440831 Compare May 15, 2018 23:05
@tiborvass
Copy link
Copy Markdown
Contributor

LGTM

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants