ClearcodeHQ/pytest-dbfixtures

verify process existence in the beginning of adequate connection fixture

Closed this issue · 1 comments

The problem is that one of tests in a sequence of them may cause e.g. redis_proc to stop. The next test using the same fixture will fail while trying to connect to this redis. So it happens that the problem from one test leaks to the other and that is hard to debug. Sometimes even one of tests passes but in the end it makes redis/mongo/etc. to exit so the error will occur in the next test trying to connect to one of databases.

I see two solutions:

  • connection fixtures (redisdb, rabbitmq, etc.) try once to restart the process if the connection fails. If second connection attempt ends with failure fixture should raise exception.
  • process fixtures (redis_proc, rabbitmq_proc, etc.) should add a hook (code ref: hookspec.py) that will be fired in the beginning or the end of test verifying if process is running and trying to restart it in case it was down. An advantage of the process fixtures hooks approach would be that whoever will use own connection fixture (and not the one in pytest-dbfixtues) he won't need to solve the issue on his own.
fizyk commented

it should be done preferably at the beginning of a test, and the minimum could be a client fixture checking if process is running, executor should have the ability to tell if it's running or not.