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

Fixture fails if HOME is not set #37

Open
gdetrez opened this issue May 18, 2017 · 6 comments
Open

Fixture fails if HOME is not set #37

gdetrez opened this issue May 18, 2017 · 6 comments

Comments

@gdetrez
Copy link

gdetrez commented May 18, 2017

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 gdetrez changed the title Fixtur fails if HOME is not set Fixture fails if HOME is not set May 18, 2017
@fizyk
Copy link
Member

fizyk commented May 18, 2017

@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)

@fizyk
Copy link
Member

fizyk commented May 18, 2017

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,,,,

@gdetrez
Copy link
Author

gdetrez commented May 26, 2017

@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.

@fizyk
Copy link
Member

fizyk commented May 29, 2017

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

@fizyk fizyk added the question label May 29, 2017
@PrasadRajuChekuri
Copy link

PrasadRajuChekuri commented Jan 19, 2022

test setup failed
request = <SubRequest 'rabbitmq' for >

@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

@fizyk
Copy link
Member

fizyk commented Jan 19, 2022

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants