Skip to content

Move test-unit out of hack/make#33987

Merged
thaJeztah merged 2 commits intomoby:masterfrom
dnephin:cleanup-more-hack
Jul 26, 2017
Merged

Move test-unit out of hack/make#33987
thaJeztah merged 2 commits intomoby:masterfrom
dnephin:cleanup-more-hack

Conversation

@dnephin
Copy link
Copy Markdown
Member

@dnephin dnephin commented Jul 6, 2017

This is similar to the changes we made to hack/validate. Running tests shouldn't require hack/make.sh. Moving them to hack/test/ will allow us to run them directly with less overhead. It also makes the scripts much easier to read because there's no hidden state provided by a "runner" (hack/make.sh).

Also:

  • Fixed a couple problems I found in Add test coverage to pkg/term #33520 (tests leaving the terminal broken, and remove the test flag)
  • Moved some functions out of hack/make.sh to where they are used. The less global state provided by hack/make.sh the easier these scripts are to read.
  • remove HAVE_GO_TEST_COVER which was dead code.

I'll address test-integration and test-docker-py as part of carrying #33344

hack/make.sh 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.

Looks like this is using spaces; can you use tabs for indenting?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oops, it was using spaces before, I think I tried to convert it to a tab, but I ended will with just 4 spaces. Will fix

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed

@thaJeztah
Copy link
Copy Markdown
Member

Let's ping our resident bashologists

@tianon @albers PTAL

@dnephin dnephin force-pushed the cleanup-more-hack branch from ccaf862 to e4acf9a Compare July 11, 2017 16:01
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 think it's confusing to have the redirection in front of the command. In fact I did not even know that this is possible. I'd prefer to have it at the end of the command.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good, moved to the end

@albers
Copy link
Copy Markdown
Member

albers commented Jul 11, 2017

I'm not familiar with the build and test options, so almost every invocation variant I tried ended up in error messages. That's probably because I'm not familiar with go yet.
I'm also confused about the relationship between the makefiles, hack/make.sh and the files under hack/. There are hidden files, like .binary. Strange.
Is there a current documentation of how the scripts should be used?

The script changes all look reasonable to me, Most of it was shifted unchanged, so there is no point in commenting these parts. Only found a small nit, but this is not important. So LGTM.

@dnephin
Copy link
Copy Markdown
Member Author

dnephin commented Jul 11, 2017

Re docs, hack/README.sh has some information which I think was added recently.

The relationship is something like this:

  • Makefile - builds images and runs containers
  • hack/make.sh - is a driver for most tasks. It sets some variables and sets a bundle/ path for any artifacts created by the task. Generally should be run from inside a container created by make shell or will be invoked by some other make target.
  • hack/make/* - scripts which are intended to be run by the hack/make.sh driver
  • hack/* - other scripts that aren't run by hack/make.sh

@albers
Copy link
Copy Markdown
Member

albers commented Jul 12, 2017

While being at it, could you please remove from the ./hack/make.sh test example from hack/make/README.md?

@albers
Copy link
Copy Markdown
Member

albers commented Jul 12, 2017

@dnephin thanks a lot for your hints. Now I could successfully execute the changed/new scripts.
I suppose the hidden files in hack/make are hidden because they do not correspond with make targets.

@dnephin
Copy link
Copy Markdown
Member Author

dnephin commented Jul 12, 2017

Yes, I think a lot of the hidden files are meant to be like libraries that can be sourced, but do run directly.

@dnephin
Copy link
Copy Markdown
Member Author

dnephin commented Jul 12, 2017

Removed the test example from the README

Copy link
Copy Markdown
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

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

Seems sane to me!

hack/test/unit 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.

Missed one 😄 (spaces vs tabs)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks! fixed

dnephin added 2 commits July 17, 2017 11:38
Signed-off-by: Daniel Nephin <dnephin@docker.com>
Also remove the test flag from pkg/term and jsut checkuid directly.
Fixed a problem with a pkg/term test that was leaving the terminal in a bad
state.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
@dnephin dnephin force-pushed the cleanup-more-hack branch from c356e6c to 1fb6155 Compare July 17, 2017 15:39
@dnephin
Copy link
Copy Markdown
Member Author

dnephin commented Jul 26, 2017

ping for another LGTM

var rootEnabled bool

func init() {
flag.BoolVar(&rootEnabled, "test.root", false, "enable tests that require root")
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.

do we know why this was here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The intent was to only run some tests if the flag was set. I think the correct behaviour is to optimistically run the tests that can be run when the user is correct.

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 it be related to running the tests bare-metal? I seem to recall there were some tests in the past that could screw up the host (we had a fun one changing system time to verify certificate expiry)

ping @tiborvass @andrewhsu could you have a quick look to verify we can remove this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These tests work with the terminal, so any failure to cleanup should be isolated to the terminal. This patch also includes a fix for a test that did not cleanup properly (defer RestoreTerminal()).

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 @dnephin I think it's fine like this. We could do what dnephin said in https://github.com/moby/moby/pull/33520/files#r125954995 but honestly if you don't run it as root, you'll see the tests as skipped with a reason. The person reading the test logs should pay attention to skipped tests and take the decision of whether that is acceptable or not. That's how they would discover this behavior.

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.

Thanks for looking; wanted to be sure I didn't miss anything 👍

@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

@thaJeztah thaJeztah merged commit f8c4343 into moby:master Jul 26, 2017
@dnephin dnephin deleted the cleanup-more-hack branch July 26, 2017 22:43
set -eu -o pipefail

TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
BUILDFLAGS=( -tags "netgo seccomp libdm_no_deferred_remove" )
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.

Looks like I missed this; this changes the unit-tests to no longer use the BUILDFLAGS that were passed as env-var (and also changes them to be dynamically linked (previously statically))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not using BUILDFLAGS was the intent. Those are the flags for building a binary, not necessarily running tests.

Does that cause a problem?

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.

Caused me some digging why a backport didn't work, but worked on master 😂

Perhaps we should rename the variable here, to prevent it from being confused with the BUILDFLAGS in the Makefile and so on 🤔

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.

7 participants