pytest-rabbitmq
pytest-rabbitmq copied to clipboard
Fixture fails if HOME is not set
What action do you want to perform
Run any tests with the rabbitmq fixture using tox. E.g.:
def test_foo(rabbitmq):
pass
What are the results
Exception:
E mirakuru.exceptions.ProcessExitedWithError: The process invoked by the <pytest_rabbitmq.factories.process.RabbitMqExecutor: "/usr/lib/rabbitmq/bin/rabbitmq-server"> executor has exited with a non-zero code: 1.
.tox/py3/lib/python3.5/site-packages/mirakuru/base.py:425: ProcessExitedWithError
-------------------------------------------------------------------- Captured stderr setup --------------------------------------------------------------------
erlexec: HOME must be set
What are the expected results
Test should pass
It seems that rabbitmq requires HOME to be set but tox unsets all environment variables. Maybe the fixture could set HOME to a safe location to avoid the problem.
A workarrout is to set HOME in tox.ini:
setenv =
HOME = {envtmpdir}
@gdetrez what system you're running your tests on? How do you run tests and can you start rabbimq on this system by yourself? (install and run as a service)
Can't find what does the rabbitmq looks for in HOME unfortuantely. It seems like setting up this env to a work directory would do though,
Not sure though if this can be treated like a standard config option,,,,
@fizyk from the error message, it looks like it's erlexec that complains for HOME. I'm not sure why either.
I run my tests on ubuntu, more specifically in a ubuntu docker image.
this doc shows https://marketplace.automic.com/details/rabbitmq-official-docker-image there's a running a deamon sections and a home dir section in configuration...
official Docerfile mentiones HOME specifically https://github.com/docker-library/rabbitmq/blob/master/3.6/debian/Dockerfile
test setup failed request = <SubRequest 'rabbitmq' for <Function test_rabbitmq>>
@pytest.fixture
def rabbitmq_factory(request):
"""
Client fixture for RabbitMQ.
#. Get module and config.
#. Connect to RabbitMQ using the parameters from config.
:param TCPExecutor rabbitmq_proc: tcp executor
:param FixtureRequest request: fixture request object
:rtype: rabbitpy.adapters.blocking_connection.BlockingConnection
:returns: instance of :class:`BlockingConnection`
"""
# load required process fixture
process = request.getfixturevalue(process_fixture_name)
...............virtualenvs\python-C16yBDVe\lib\site-packages\pytest_rabbitmq\factories\client.py:102:
...............virtualenvs\python-C16yBDVe\lib\site-packages\pytest_rabbitmq\factories\process.py:112: in rabbitmq_proc_fixture rabbit_executor.start() ...............virtualenvs\python-C16yBDVe\lib\site-packages\mirakuru\base.py:525: in start self.wait_for(self.check_subprocess) ...............virtualenvs\python-C16yBDVe\lib\site-packages\mirakuru\base.py:445: in wait_for if wait_for():
self = <pytest_rabbitmq.factories.executor.RabbitMqExecutor: "/usr/lib/r..." 0x273161ff5e0>
def check_subprocess(self) -> bool:
"""
Make sure the process didn't exit with an error and run the checks.
:rtype: bool
:return: the actual check status or False before starting the process
:raise ProcessExitedWithError: when the main process exits with
an error
"""
if self.process is None: # pragma: no cover
# No process was started.
return False
exit_code = self.process.poll()
if exit_code is not None and exit_code != 0:
# The main process exited with an error. Clean up the children
# if any.
self._kill_all_kids(self._kill_signal)
self._clear_process()
raise ProcessExitedWithError(self, exit_code)
E mirakuru.exceptions.ProcessExitedWithError: The process invoked by the <pytest_rabbitmq.factories.executor.RabbitMqExecutor: "/usr/lib/rabbitmq/bin/rabbitmq-server" 0x273161ff5e0> executor has exited with a non-zero code: 1.
...............virtualenvs\python-C16yBDVe\lib\site-packages\mirakuru\base.py:546: ProcessExitedWithError
============================== 1 error in 5.41s ===============================
Process finished with exit code 1
I have installed pytest-rabbitmq latest version rabbitpy = "==2.0.1"
I want to unit test my python pika rabbitmq client .After lot of googling I came here
why It is asking to set path ? I am using windows machine I want to test code with rabbitmq client from pytest-rabbitmq
My question is will it create same rabbitmq client with all the connections ? If not how it works actually ? @fizyk
@leofiore @zawadzinski
@PrasadRajuChekuri for clarity, it would be good to create separate issue. Plugin isn't tested on WIndows. But in case, you use connection from the plugin to set up queue and check it's state after the test (run asserts) and at the same time, you can use any different client to use the queue in your own code. Both connections are disjoint but to the same instance.