Skip to content

Commit

Permalink
Add 'skip_port_validation' flag
Browse files Browse the repository at this point in the history
This allows us to skip port validation for images that publish multiple
ports, not all of which may be active at any given time. We also
introduce reno, which is a release note manager that we can use to
produce a helpful changelog for users.

Signed-off-by: Stephen Finucane <[email protected]>
Closes: tox-dev#35
  • Loading branch information
stephenfin committed Jun 8, 2019
1 parent 3cb9f5b commit 37badf3
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,14 @@ must *exactly* match the image name used in your testenv's ``docker`` setting.
tox-docker will print a message for each container that it is waiting on a
health check from, whether via the container's built-in ``HEALTHCHECK`` or a
custom health check.

Port Scanning
-------------

Since version 1.0, tox-docker has scanned published ports of created containers
to determine when the image is active. However, not all published ports may be
active at a given time which can result in errors. As of version 1.5, tox-docker
allows you to disable this behavior if necessary, in a new section like::

[docker:mysql:5.6]
skip_port_validation = True
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'reno.sphinxext',
]

# -- Options for HTML output -------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.. include:: ../../README.rst

Release notes
-------------

.. release-notes::
11 changes: 11 additions & 0 deletions releasenotes/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
earliest_version: v1.4.0
release_tag_re: 'v\d\.\d\.\d(rc\d+)?'
sections:
# The prelude section is implicitly included.
- [features, New Features]
- [issues, Known Issues]
- [upgrade, Upgrade Notes]
- [deprecations, Deprecation Notes]
- [fixes, Bug Fixes]
- [other, Other Notes]
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
features:
- |
A new ``skip_port_validation`` flag is added. This can be used to disable
port scanning for created instances and is useful for images that provide
optional port. It can be configured for each image in a ``[docker:IMAGE]``
section. For example::
[docker:mysql:8.0]
skip_port_validation = True
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ deps =
sphinx
sphinx_rtd_theme
vcversioner
reno
commands = sphinx-build -W -b html docs/source docs/build/html
commands_pre =
commands_post =
Expand Down
5 changes: 5 additions & 0 deletions tox_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def getint(reader, key):
"healthcheck_timeout": gettime(reader, "healthcheck_timeout"),
"healthcheck_retries": getint(reader, "healthcheck_retries"),
"healthcheck_start_period": gettime(reader, "healthcheck_start_period"),
"skip_port_validation": reader.getbool("skip_port_validation", default=False),
}

config._docker_image_configs = image_configs
Expand Down Expand Up @@ -225,6 +226,10 @@ def tox_runtest_pre(venv):
if proto == "udp":
continue

# skip port validation if user requests it
if image_configs[image]["skip_port_validation"]:
continue

# mostly-busy-loop until we can connect to that port; that
# will be our signal that the container is ready (meh)
start = time.time()
Expand Down

0 comments on commit 37badf3

Please sign in to comment.