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 manual publications of ports #49

Merged
merged 1 commit into from
Apr 19, 2020
Merged

add manual publications of ports #49

merged 1 commit into from
Apr 19, 2020

Conversation

jzelinskie
Copy link
Contributor

I really needed to solve #35. Thus this PR applies the feedback from #36 to add a configurable ports section to the image config. When it is not provided or the empty string is provided, it falls back to publishing all ports, so the change entirely backwards compatible. Ports are expected to be space separated and are formatted $HOSTPORT:$CONTAINERPORT/$PROTOCOL.

A working example using MySQL 5.7:

[docker:mysql:5.7]
healthcheck_cmd = mysql -uroot -D information_schema -e "SELECT * FROM plugins LIMIT 0;"
healthcheck_interval = 25
healthcheck_timeout = 10
healthcheck_retries = 3
healthcheck_start_period = 25
ports = 3306:3306/tcp

tox_docker.py Outdated Show resolved Hide resolved
tox_docker.py Show resolved Hide resolved
@jzelinskie jzelinskie force-pushed the ports branch 4 times, most recently from 8251f2f to 7533156 Compare April 1, 2020 20:23
@dcrosta
Copy link
Member

dcrosta commented Apr 1, 2020

Thanks this looks pretty good -- can you add a test (and relevant config in the tox.ini), and a note on how to use it in the README (which becomes the sphinx docs)? Then I'll merge. Thanks for doing this!

@jzelinskie jzelinskie force-pushed the ports branch 3 times, most recently from 3397d79 to 6a931d4 Compare April 6, 2020 19:15
@jzelinskie
Copy link
Contributor Author

The CI is returning success, but the processes are all crashing for what looks like healthchecking code. Do you think my change caused this and I should fix it?

@dcrosta
Copy link
Member

dcrosta commented Apr 7, 2020

Yeah, looks like tox_configure assumes that if a [docker:foo] section exists at all, it must contain all keys. I'm confused why CI is not failing, because I can reproduce it consistently locally.

If you'd like to take a stab at a fix, I'd appreciate that; otherwise I can probably find some time in the next couple of days. My recommendation is to make all the healthcheck configs required as a group (either all must be present or all absent), and the port listing is optional in either case.

@jzelinskie jzelinskie force-pushed the ports branch 2 times, most recently from aa4efb1 to 12b6478 Compare April 7, 2020 20:54
@jzelinskie
Copy link
Contributor Author

I'm going to just get the tests working with a healthcheck for now and the other issue can be fixed in a follow up PR.

@dcrosta
Copy link
Member

dcrosta commented Apr 8, 2020

I'm currently getting this error running tests locally:

GLOB sdist-make: /Users/dcrosta/src/tox-docker/setup.py
ports inst-nodeps: /Users/dcrosta/src/tox-docker/.tox/.tmp/package/1/tox-docker-1.4.1.post6.zip
ports installed: appdirs==1.4.3,attrs==19.3.0,certifi==2020.4.5.1,chardet==3.0.4,distlib==0.3.0,docker==4.2.0,filelock==3.0.12,idna==2.9,more-itertools==8.2.0,packaging==20.3,pluggy==0.13.1,py==1.8.1,pyparsing==2.4.7,pytest==5.4.1,requests==2.23.0,six==1.14.0,toml==0.10.0,tox==3.14.6,tox-docker==1.4.1.post6,urllib3==1.25.8,virtualenv==20.0.16,wcwidth==0.1.9,websocket-client==0.57.0
ports docker: run 'mysql:5.7'
ports docker: health check: 'mysql:5.7'
____________________________________________________________________________________ summary _____________________________________________________________________________________
  ports: commands succeeded
  congratulations :)
Traceback (most recent call last):
  File "/Users/dcrosta/.pyenv/versions/tox-docker-3.8/bin/tox", line 8, in <module>
    sys.exit(cmdline())
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/tox/session/__init__.py", line 68, in main
    exit_code = session.runcommand()
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/tox/session/__init__.py", line 194, in runcommand
    return self.subcommand_test()
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/tox/session/__init__.py", line 222, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/tox/session/commands/run/sequential.py", line 22, in run_sequential
    runtestenv(venv, config)
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/tox/session/commands/run/sequential.py", line 73, in runtestenv
    config.pluginmanager.hook.tox_runtest_pre(venv=venv)
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/pluggy/manager.py", line 93, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/pluggy/manager.py", line 84, in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/dcrosta/.pyenv/versions/3.8.2/envs/tox-docker-3.8/lib/python3.8/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/Users/dcrosta/src/tox-docker/tox_docker.py", line 215, in tox_runtest_pre
    raise HealthCheckFailed("{!r} failed health check".format(image))
tox_docker.HealthCheckFailed: 'mysql:5.7' failed health check```

@dcrosta
Copy link
Member

dcrosta commented Apr 19, 2020

I've created branch https://github.com/tox-dev/tox-docker/commits/ports with a few minor follow-up tweaks. I'll merge this once CI passes. Thanks for your help here!

@dcrosta dcrosta merged commit 059849a into tox-dev:master Apr 19, 2020
@dcrosta
Copy link
Member

dcrosta commented Apr 19, 2020

I'm going to try to do one more thing before cutting a new release, to make it so that you don't have to specify a full healthcheck to use the ports configuration. I think I will have time for this after dinner tonight. I appreciate your patience and realize this small fix has taken a while to get through, but the end is in sight! Thanks for your help & contribution, @jzelinskie!

@dcrosta
Copy link
Member

dcrosta commented Apr 19, 2020

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.

2 participants