tests: Fix pytest container networking issues #1856
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contributes fixes I described here when investigating test failures from running pytest via the supported Docker container method (my preference).
I've scoped changes out to individual commits as usual, with commit messages adding context. The final commit does a little housekeeping with white-space so it might be a cleaner diff if you disable white-space when viewing.
Roughly the changes are:
pytest
via container (pytest.sh
) by using ENV instead of the deprecated internal file check that Docker no longer supports. We only need it for running tests and control thepytest
Dockerfile, seems the right way to approach it 馃憤$HOSTNAME
//etc/hostname
, not the containers ID, thus thepytest
container would accidentally remove itself. We now match by setting a container name inpytest.sh
to compare against instead.pytest
container should connect to other container networks (specifically thenginx-proxy
one, typically a bridge network with name based on the docker-compose file name). This wasn't happening because of a missing arg to request networks with their associated containers, and once that was corrected, several other parts were found to not be working properly, such as avoiding connecting to a network that was already connected, or avoidingnone
network (different from passingNone
).Behaviour of the
pytest
container is now at parity with running it locally on the host.Fixes #1615