Skip to content
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

Container for running tests and Makefile cleanup #385

Merged
merged 5 commits into from
Jan 24, 2017

Conversation

kadel
Copy link
Member

@kadel kadel commented Jan 20, 2017

This adds Dockerfile that can be used to run all Kompose tests locally.

make test will run exactly the same tests as travis-ci but running locally in docker image.
This can be used to tests everything before commiting or submitting PR.
Image is automatically build in docker hub - https://hub.docker.com/r/kompose/tests/ or it can be build locally using make test-image.

Automatic build at docker hub is NOT triggered automatically on push. Only time when rebuild is needed is when Dockerfile is changed.

This PR also includes Makefile and /script/ cleanup.
I've removed all the shell scripts that were just one single command and put those commands directly to Makefile. It is much more easier to figure out what is doing what.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 20, 2017
@@ -0,0 +1,32 @@
# This Dockefile creates image where all Kompose tests can be run

FROM registry.centos.org/centos/centos:7
Copy link
Member

Choose a reason for hiding this comment

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

i think we should use the docker hub centos base images

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking about it. They should be build from same Dockerfile.
I don't know.

Why would you prefer image from docker hub?

Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

LGTM 👍 other than my small changes.

This will make it 100% easier to replicate any tests that need to be ran!

@@ -0,0 +1,32 @@
# This Dockefile creates image where all Kompose tests can be run
Copy link
Member

Choose a reason for hiding this comment

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

missing license at the top

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, thx for noticing

# This Dockefile creates image where all Kompose tests can be run

FROM registry.centos.org/centos/centos:7
MAINTAINER Tomas Kral <tkral@redhat.com>
Copy link
Member

Choose a reason for hiding this comment

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

MAINTAINER has been deprecated in 1.13 of Docker :(.

Better to use LABEL maintainer Tomas Kral <tkral@redhat.com> or remove it all-together

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I didn't know that.
I'll remove it, I don't think that it is something that we need for image. It was just something that I was used to doing.

@cdrage
Copy link
Member

cdrage commented Jan 20, 2017

Just a note though, I feel as though these tests run a lot slower than the original ones? I think it's because there's no cache being passed through?

The part that's reallyyyy taking it's time is here:

# First install packages that are dependencies of the test. 
go test -i -race -cover ./cmd/... ./pkg/... .

Another being that what if I wanted to just run cmd or just run integration?

@kadel
Copy link
Member Author

kadel commented Jan 23, 2017

Just a note though, I feel as though these tests run a lot slower than the original ones? I think it's because there's no cache being passed through?

Yes, no cache being passed through.
I'll look at it in separate PR.

The part that's reallyyyy taking it's time is here:

# First install packages that are dependencies of the test. 
go test -i -race -cover ./cmd/... ./pkg/... .

This pre-compiles all the dependencies for test. So it can take some time, but it will speed up running all the go test.
Calculating coverage for whole project requires running go test separately for every package. If you do it without running go test -i first it takes really long time (20+mins) :-D.

Another being that what if I wanted to just run cmd or just run integration?

Yes, I was thinking about it. I would like to do it in separate PR.

I have some other ideas how to speed this up. But than it will run slightly different commands and tests from what is run in travis-ci. I wanted to replicated same thing that travis is doing first, and than add options to run faster but not complete test later.

If you didn't setup user.email and user.name `git commit` fails.
This configures user.email and user.name for newly created temporary git
repo.
If command is simple command call it from Makefile,
there is no need to have them in separate shell scripts.
@cdrage
Copy link
Member

cdrage commented Jan 23, 2017

I like how you keep the current tests in as well. But perhaps we can do it so that it's "test-container" or something?

Would be easier for using it on travis, etc and for those who choose to run the container vs traditional.

@kadel
Copy link
Member Author

kadel commented Jan 23, 2017

There is make test-all that runs all the tests outside container and make test that runs it inside container.
My idea was that "humans" will run tests in container so i wanted to make command shorter, hence make test :-)

So you are suggesting changing it so make test runs everything without container and creating make test-container that doesn't what make test is doing right now (running it it all inside container)?

@cdrage
Copy link
Member

cdrage commented Jan 23, 2017

@kadel
Yup. That's what I'm suggesting. make test runs it traditionally. make test-container runs it in a container.

@kadel
Copy link
Member Author

kadel commented Jan 23, 2017

@kadel
Yup. That's what I'm suggesting. make test runs it traditionally. make test-container runs it in a container.

done ;-)

There is just one small catch with make test and that it expects that you have $GOPATH/bin in $PATH.
Otherwise test-cmd might fail or run against older binary.

Copy link
Member

@cdrage cdrage left a comment

Choose a reason for hiding this comment

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

LGTM!

# run all test localy in docker image (image can be build by by build-test-image target)
.PHONY: test-container
test-container:
docker run -v `pwd`:/opt/tmp/kompose:ro -it $(TEST_IMAGE)
Copy link
Member

@cdrage cdrage Jan 23, 2017

Choose a reason for hiding this comment

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

woo
Thanks for the change!

@kadel kadel merged commit 001e19c into kubernetes:master Jan 24, 2017
@kadel kadel deleted the test-in-docker branch January 24, 2017 11:18
@kadel kadel restored the test-in-docker branch January 25, 2017 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/testing review needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants