chaostoolkit-lib icon indicating copy to clipboard operation
chaostoolkit-lib copied to clipboard

Attempt to fix `test/test_exit.py` tests by using `pytest-docker`

Open ciaranevans opened this issue 2 years ago • 1 comments

Due to the threading used in tests/test_exit.py, the tests always hang on server.join()

Rather than running an http service in a thread, I'm trying out using pytest-docker to run a http service in a container alongside the tests. Whilst this introduces the need to have docker and docker-compose locally (I don't think that's a massive ask for developers...), it reduces the complexity of the test and doesn't rely on some scary threading

Update

I can confirm that this unblocks the tests locally AND we can now run them in CI builds too (🤙 🤙 🤙 )

To summarise, this PR:

  • Removes scary threading in test_exit.py in favour of running a very lightweight FastAPI container which does the exact same thing
  • Unblocks local running of test_exit.py and enables running them in CI
  • Adds pytest-docker as a dev dependency (and because of it, docker and docker-compose)
  • Removes nasty handling of os.environ which would affect any test being run, not just the tests in test_configuration.py

Signed-off-by: Ciaran Evans [email protected]

ciaranevans avatar Oct 15 '21 09:10 ciaranevans

@Lawouach sure, can do!

ciaranevans avatar Oct 20 '21 08:10 ciaranevans