tests: Cleanup candlepin container#224
Conversation
|
[citest] |
9b93f3a to
918739c
Compare
|
[citest] |
da8e1bb to
176bf97
Compare
|
[citest] |
1 similar comment
|
[citest] |
176bf97 to
3d012f5
Compare
|
[citest] |
3d012f5 to
c73c4de
Compare
|
[citest] |
c73c4de to
6bf0844
Compare
|
[citest] |
6bf0844 to
fe058c2
Compare
|
[citest] |
fe058c2 to
8b0ef28
Compare
|
[citest] |
8b0ef28 to
025dd72
Compare
|
[citest] |
|
@ptoscano please take a look when you have time |
There was a problem hiding this comment.
I'd rename this file as "stop_candlepin.yml"
There was a problem hiding this comment.
Since in fact we stop the container to remove it, and since this is specifically for the podman container, I find it clearer to call the file remove_candlepin_container.
| - name: Check if the candlepin container is started | ||
| command: podman container exists candlepin | ||
| register: __rhc_candlepin_cont_started | ||
| failed_when: false | ||
| changed_when: false | ||
|
|
||
| - name: Stop and potentionally remove Candlepin container | ||
| command: podman stop candlepin | ||
| when: __rhc_candlepin_cont_started.rc == 0 | ||
| changed_when: true |
There was a problem hiding this comment.
Instead of these two tasks, simply use the existing Stop and remove Candlepin container task in setup_candlepin.yml, as it does exactly that.
|
@ptoscano re: removing the candlepin image from the local registry
So ideally, the |
I'm fine with this. Could we also tweak tox-lsr (which spawns a new system) to also skip that tag by default?
I guess it also depends on how the tests are run, right? ie tox-lsr vs testing-farm vs something else. |
It's pretty easy to add There are other ways to use tox e.g. with
Right - if we wanted to add something like a "run setup before all role tests" and "run cleanup after all role tests" then we would have to change tox-lsr, testing farm test runner, and the downstream test runners. |
| when: | ||
| - '"candlepin" in __rhc_candlepin_container_stopped.stdout' | ||
|
|
||
| - name: Remove Candlepin container image |
There was a problem hiding this comment.
@richm maybe let's not clean up the image? It won't affect anything, and re-downloading it with each test upstream is a waste of network bandwidth.
There was a problem hiding this comment.
@richm maybe let's not clean up the image? It won't affect anything, and re-downloading it with each test upstream is a waste of network bandwidth.
Ok. That will affect the podman tests, in the scenarios where we run tests from multiple roles - the podman tests expect no images. I guess that means changing this PR to use __rhc_cleanup_image: false (or just omit __rhc_cleanup_image because the default is false)
There was a problem hiding this comment.
I'll fix the podman tests to work if there are images on the system.
|
[citest] |
7c4afed to
cfcda44
Compare
|
I think just get rid of |
cfcda44 to
3ad822a
Compare
|
I'd wait for Pino approval too |
|
[citest] |
ptoscano
left a comment
There was a problem hiding this comment.
Thanks for the updates! I added few more notes that IMHO simplify things a bit, and make the changes more consistent with the current tasks.
Additionally a minor nit common to all the files:
- name: Clean up Candlepin container
include_tasks: tasks/remove_candlepin_container.yml
I suggest Clean up Candlepin instead (mimicks the setup tasks), or even Tear down Candlepin (see my previous comment on the naming of the new task file).
Thanks!
There was a problem hiding this comment.
Since this file now only stops candlepin, better name it stop_candlepin.yml, or maybe even better teardown_candlepin.yml (symmetric with "setup")
There was a problem hiding this comment.
Rather than two tasks, simply try to stop the container, and do not consider the missing container an error. In practice simply move here the single task Stop and remove Candlepin container as currently in setup_candlepin.yml.
There was a problem hiding this comment.
Now this doesn't work because setup_candlepin.yml has the step to remove the container just in case the container was running from the previous playbook. But role always cleans up the container, and this step would fail. Although, it's good to have the step in setup_candlepin.yml for the case when you are testing locally and might have some container running from the previous test.
I think it's better to keep it the Ansible way and keep the task. By importing the task we say bring the system to the state where this container is removed, whether it exists now or not.
There was a problem hiding this comment.
Not sure what you mean here: the existing task that tries to stop the candlepin container also takes care of not erroring out in case the container does not exist. Strictly speaking, doing first the existence check and then stopping it may be a minor TOCTOU issue: https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use.
2b558ee to
96c2daa
Compare
|
[citest] |
96c2daa to
4915a6d
Compare
ptoscano
left a comment
There was a problem hiding this comment.
Thanks for the updates, a couple of final changes, and it should be ready.
Make sure to squash all the commits.
There was a problem hiding this comment.
Not sure what you mean here: the existing task that tries to stop the candlepin container also takes care of not erroring out in case the container does not exist. Strictly speaking, doing first the existence check and then stopping it may be a minor TOCTOU issue: https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use.
490b08c to
36a306e
Compare
In always block, in tests that import the task tests/tasks/setup_candlepin.yml, import a task to cleanup candlepin container
36a306e to
0f59dc1
Compare
|
[citest] |
Enhancement: In always block, import a task to cleanup candlepin container in tests that import the task tests/tasks/setup_candlepin.yml, which starts candlepin container.
Reason: Candlepin container remains after test playbook finishes. If you remove
container-selinuxrpm, you got selinux denials because the container is running but selinux policies for containers are removed.