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

add a way to run multiple test suites #67

Closed
wants to merge 1 commit into from

Conversation

TomasTomecek
Copy link
Contributor

@TomasTomecek TomasTomecek commented Feb 20, 2018

Related: sclorg/s2i-ruby-container#167

Initial version. I'm open to change the workflow & names. Please, advise.

TODO:

  • remove docker invocation
  • add concept of TEST_SUITES := "test1 test2" and then for x in ${TEST_SUITES}; ...
    • make sure all tests are being run and exit 1 if one of them failed
  • TEST env should support: container, local

@centos-ci
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@rhscl-bot
Copy link

Can one of the admins verify this patch?

@omron93
Copy link
Contributor

omron93 commented Feb 21, 2018

Would it be possible to add Dockerfile.tests also in this repo? To be able to share it across containers...

@TomasTomecek
Copy link
Contributor Author

Found some spare time to work on this. Waiting for tests to pass locally.

@TomasTomecek TomasTomecek changed the title add a way to run conu tests in a container add a way to run multiple test suites Mar 8, 2018
@praiskup
Copy link
Contributor

@TomasTomecek if you specified Required-by: s2i-ruby-container#167 tag in commit message (see a068a12 e.g.) we could test directly against s2i-ruby-container.

[test]

@TomasTomecek TomasTomecek force-pushed the add-conu branch 2 times, most recently from b95ff2b to a7a1d72 Compare March 29, 2018 07:39
@TomasTomecek
Copy link
Contributor Author

13:55:52 + false this must fail the whole testsuite

Is it my fault?

(rebased and updated the commit message)

@pkubatrh
Copy link
Member

That was a red herring. The actual error was this:

13:55:52  # FATAL: Can not be --ff merged into origin/master
13:55:52 make: *** [check] Error 1

So should be fixed by the rebase.

[test]

@pkubatrh
Copy link
Member

The ruby PR needs to be rebased as well @TomasTomecek

@TomasTomecek
Copy link
Contributor Author

rebased

@pkubatrh
Copy link
Member

pkubatrh commented Apr 3, 2018

Thanks!

[test]

@pkubatrh
Copy link
Member

pkubatrh commented Apr 3, 2018

Tests are failing now because conu tests are being run for all the image versions, but the ruby PR only provides run-conu for one version (2.4)

@TomasTomecek Can you add the conu tests for other versions as well?

@TomasTomecek
Copy link
Contributor Author

I'm busy atm, I hope I'll take a look and fix this next week.

@TomasTomecek
Copy link
Contributor Author

Updated.

[test]

test.sh Outdated
fi
for test_script in ${TEST_SUITES}; do
if [ "${TEST_MODE}" == "container" ]; then
docker run --net=host -e VERSION=$dir -e IMAGE_NAME --rm -v /dev:/dev:ro -v /var/lib/docker:/var/lib/docker:ro --security-opt label=disable --cap-add SYS_ADMIN -ti -v /var/run/docker.sock:/var/run/docker.sock -v ${PWD}:/src -w /src docker.io/modularitycontainers/conu $test_script
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind to split this into multiple lines, so it can be more human-readble?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

test.sh Outdated

# FIXME: deprecate TEST_OPENSHIFT_MODE and use TEST_SUITES instead?
Copy link
Member

Choose a reason for hiding this comment

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

Yes, this seems like the way to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would do that in dedicated PR since I have no idea how much it has to be done in other repos.

Copy link
Member

Choose a reason for hiding this comment

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

There should not be any changes needed in other repositories afaik.

common.mk Outdated
@@ -64,7 +66,7 @@ $(VERSIONS): % : %/root/help.1
.PHONY: test check
check: test

test: script_env += TEST_MODE=true
test: script_env += TEST_MODE=local
Copy link
Member

Choose a reason for hiding this comment

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

The strange thing is, that this variable now has different meaning...

Previously it was used to switch the test suite on, not to define test variant (or environment). I'd say the variable chosen before was somehow unfortunate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do I invent a new one then?

Copy link
Member

Choose a reason for hiding this comment

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

There is some meaning change behind the variable usage but I do not think it is necessary to introduce a different one just because of that. The variable should only be used in common scripts anyway.

Copy link
Member

Choose a reason for hiding this comment

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

The issue I see with the way it is used now is that there is no way to set this variable to any other value.

test.sh Outdated
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${PWD}:/src \
-w /src \
docker.io/modularitycontainers/conu \
Copy link
Member

Choose a reason for hiding this comment

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

Unable to find image 'docker.io/modularitycontainers/conu:latest' locally
Trying to pull repository docker.io/modularitycontainers/conu ... 
/usr/bin/docker-current: manifest for docker.io/modularitycontainers/conu:latest not found.

Copy link
Member

Choose a reason for hiding this comment

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

Using docker.io/modularitycontainers/conu:0.2.0 instead works.

Copy link
Member

Choose a reason for hiding this comment

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

The image does not seem to have pytest-3 though ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We moved conu to our github org and I can't figure out how to configure automated build there. Seems github changed how apps/services work.

Copy link
Member

Choose a reason for hiding this comment

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

This docker image is still not working:

$ docker pull docker.io/modularitycontainers/conu:latest
Trying to pull repository docker.io/modularitycontainers/conu ... 
Pulling repository docker.io/modularitycontainers/conu
Tag latest not found in repository docker.io/modularitycontainers/conu

Copy link
Member

Choose a reason for hiding this comment

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

Lastest image I've found is dev, which is 5 months old:
https://hub.docker.com/r/modularitycontainers/conu/tags/

@TomasTomecek
Copy link
Contributor Author

Unfortunately, I don't have time to finish this one. What would I need to do to land this one?

@pvalena
Copy link
Member

pvalena commented Sep 19, 2018

I think it just needs to pass the tests- the code looks good.

@TomasTomecek TomasTomecek force-pushed the add-conu branch 4 times, most recently from 7e2ddb3 to 7d05015 Compare November 16, 2018 16:29
@TomasTomecek
Copy link
Contributor Author

Finally found some spare time to finish this. Please see my changes.

test.sh Outdated
-v ${PWD}/../:/src \
-w /src/${dir}/ \
-ti \
docker.io/usercont/conu:0.6.2 \
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't you want to have some floating docker tag here instead of 0.6.2?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually not: in case we accidentally create a breaking change in a new version, we don't want all your conu tests to start failing. I think it's a better approach to systematically update to newer versions once you're sure they work as you expect. Using latest greatest might be pretty adventurous, especially when the container ecosystem is still changing rapidly.

But your call, really.

Copy link
Contributor

@praiskup praiskup Nov 17, 2018

Choose a reason for hiding this comment

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

Using latest greatest might be pretty adventurous

By floating tag I did not mean "latest greatest", but rather "latest stable". Whether we'll update the version here all the time by PR, or you'll tag it into "conu:stable" tag doesn't make much practical difference - API changes will hurt us and PR is only additional work. Btw., conu should simplify our lives so we don't have to take care of ever-changing container API, not that we'll have to take care ever-changing API in conu.

test.sh Outdated
--security-opt label=disable \
--cap-add SYS_ADMIN \
-ti \
-v /var/run/docker.sock:/var/run/docker.sock \
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmpfs, this means we give a lot of trust into that container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what's the difference in running the tests directly on host?

Copy link
Contributor

Choose a reason for hiding this comment

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

I hope we didn't run privileged container, nor UID=0 container in testsuite so far in our suite -- except for build -- but I don't know, I thought docker build isn't mounting insecure things into the container. That said, I thought it is banned policy to give a random container write access to a docker socket. But I'm probably too old school; /me just dropped the UID from docker group, and I'll run the suite in VM.

@praiskup
Copy link
Contributor

The code basically LGTM if that was optional. But ideally, we should give the end-user chance to install conu library on the host. If installing conu isn't possible, user could opt-in running privileged container (e.g. by USE_CONU_CONTAINER=conu:0.6.2?).

@TomasTomecek
Copy link
Contributor Author

TomasTomecek commented Nov 17, 2018

The library is packaged in Fedora so it's not a problem installing it. One thing to note is that we are planning to remove python2 support (no one ever used it actually): I'm not sure if you are planning to use it on CentOS 7 hosts.

If installing conu isn't possible, user could opt-in running privileged container

Please advise me the precise steps, maybe something like this?

if `python3 -c "import conu"`; then
  ./test/run-conu
else
  $start_that_container
fi

Btw +1 on being able to pick the conu version with the env var.

@praiskup
Copy link
Contributor

I'm not sure if you are planning to use it on CentOS 7 hosts.

Yes, but there is Python 3 from RHSCL, so it shouldn't be a problem.

Please advise me the precise steps, maybe something like this?

I'd much rather see something like:

if $THERE_ARE_NO_CONU_TESTS; then
   exit 0
fi
if test -n "$CONU_IMAGE"; then
   docker run --rm -ti .. "$CONU_IMAGE" ..
else
   ./test/run-conu
fi

In other words, I don't think it is problem to see ./tests/run-conu failing by default (if conu is not installed), as long as we have documented this to be a prerequisite (in README.md, with others). I simply don't like the unannounced execution of privileged container -- e.g. I'm in docker group on my system and I'd feel huge discomfort in running make test.

@omron93
Copy link
Contributor

omron93 commented Nov 20, 2018

as long as we have documented this to be a prerequisite (in README.md, with others)

There are other prerequisites, so this shouldn't be a problem as long as rpm is easily installable in Fedora/RHEL/CentOS! Python3 RHSCL is fine, but it's harder to use it as rpm dependency. Using conu in container might have some problems, but user gets running tests out of the box.

How to install conu in RHEL7/Centos7?

@TomasTomecek
Copy link
Contributor Author

TomasTomecek commented Nov 20, 2018

It's packaged in epel7. I can see we haven't updated it in a while: https://src.fedoraproject.org/rpms/conu/blob/epel7/f/conu.spec I don't think it's such a big deal to keep packaging it for epel.

On the other hand, I just realized that python-kubernetes is not available in epel:
user-cont/conu#323

I simply don't like the unannounced execution of privileged container

Yes, that's a fair point: the container has more permissions than your unpriv user.

I updated the code with your suggestions.

The ruby test suite keeps passing:

test/test_s2i.py::TestSuite::test_s2i_apps[/home/tt/g/sclorg/s2i-ruby-container/2.5/test/puma-test-app] PASSED                                                                                              [ 25%]
test/test_s2i.py::TestSuite::test_s2i_apps[/home/tt/g/sclorg/s2i-ruby-container/2.5/test/rack-test-app] PASSED                                                                                              [ 50%]
test/test_s2i.py::TestSuite::test_invoking_container PASSED                                                                                                                                                 [ 75%]
test/test_s2i.py::TestSuite::test_usage PASSED                                                                                                                                                              [100%]

@praiskup
Copy link
Contributor

Thanks!

test.sh Outdated Show resolved Hide resolved
Required-by: s2i-ruby-container#167

Signed-off-by: Tomas Tomecek <[email protected]>
@TomasTomecek
Copy link
Contributor Author

I just realized that the container had too many privileges for no reason, I stripped that down. PTAL

@praiskup
Copy link
Contributor

[test] let's test the Required-by

@praiskup
Copy link
Contributor

Pushed as f1539e9 (fixed $PWD escape).

@praiskup praiskup closed this Nov 20, 2018
@TomasTomecek TomasTomecek deleted the add-conu branch November 20, 2018 15:04
@TomasTomecek
Copy link
Contributor Author

Thank you!

I'll have a beer to celebrate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants