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

MySQL containers not starting #141

Open
thearghyadutta opened this issue Aug 31, 2022 · 1 comment
Open

MySQL containers not starting #141

thearghyadutta opened this issue Aug 31, 2022 · 1 comment

Comments

@thearghyadutta
Copy link

I am working on building a test suite of a microservice application using Tox-Docker. Our database is a MySQL DB, so we are trying to create a test DB to run our tests on. I am pulling the image MySQL5.7 from Docker hub. Here's the tox file I have written:

[tox]
envlist = py36
skipsdist = true
isolated_build = true

[docker:db1]
image = mysql:5.7
environment =
    MYSQL_USER = mysql
    MYSQL_PASSWORD = test123
    MYSQL_DB = test_db
ports = 
    3306:3306/tcp

[testenv]
deps =
    pytest==7.0.1
    pymysql
commands =
    sleep 10
    pytest {posargs} test_conn.py
passenv = *
docker = 
    db1

This does not bring up the MySQL DB container, I tried doing docker ps by putting a breakpoint before executing to find out whether the container has come up, but couldn't find any.

I tried the same code with the postgres example, and postgres is absolutely working fine.

I also tried putting a healthcheck in the docker section like this:

healthcheck_cmd = mysql -umysql -ptest123 --command="SELECT 1"
healthcheck_retries = 30
healthcheck_timeout = 1
healthcheck_interval = 1
healthcheck_start_period = 1

And this outrightly sends the output 'health check failed'.

py36 docker: health check 'mysql:5.7' (from 'db1')
py36 docker: remove '2bf94acb5d' (from 'db1')
_____________________________________________________ summary _____________________________________________________
ERROR:   py36: 'mysql:5.7' (from 'db1') failed health check
Traceback (most recent call last):
  File "/usr/local/bin/tox", line 11, in <module>
    sys.exit(cmdline())
  File "/usr/local/lib/python3.6/dist-packages/tox/session/__init__.py", line 44, in cmdline
    main(args)
  File "/usr/local/lib/python3.6/dist-packages/tox/session/__init__.py", line 69, in main
    exit_code = session.runcommand()
  File "/usr/local/lib/python3.6/dist-packages/tox/session/__init__.py", line 197, in runcommand
    return self.subcommand_test()
  File "/usr/local/lib/python3.6/dist-packages/tox/session/__init__.py", line 225, in subcommand_test
    run_sequential(self.config, self.venv_dict)
  File "/usr/local/lib/python3.6/dist-packages/tox/session/commands/run/sequential.py", line 22, in run_sequential
    runtestenv(venv, config)
  File "/usr/local/lib/python3.6/dist-packages/tox/session/commands/run/sequential.py", line 73, in runtestenv
    config.pluginmanager.hook.tox_runtest_pre(venv=venv)
  File "/usr/local/lib/python3.6/dist-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/usr/local/lib/python3.6/dist-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/usr/local/lib/python3.6/dist-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/usr/local/lib/python3.6/dist-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.6/dist-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/usr/local/lib/python3.6/dist-packages/tox_docker/tox3/plugin.py", line 100, in tox_runtest_pre
    docker_health_check(container_config, container, log)
  File "/usr/local/lib/python3.6/dist-packages/tox_docker/plugin.py", line 133, in docker_health_check
    raise HealthCheckFailed(msg)
tox_docker.plugin.HealthCheckFailed: 'mysql:5.7' (from 'db1') failed health check

Wondering if you could figure out if there is any issue deploying MySQL container.
Thanks

@dcrosta
Copy link
Member

dcrosta commented Mar 26, 2023

What output do you get when you try to run tox?

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

No branches or pull requests

2 participants