python-zk / kazoo

Kazoo is a high-level Python library that makes it easier to use Apache Zookeeper.
https://kazoo.readthedocs.io
Apache License 2.0
1.3k stars 387 forks source link

KazooTestHarness leading to chroot path error #522

Closed nakulpathak3 closed 6 years ago

nakulpathak3 commented 6 years ago

Hey, I'm running kazoo 2.5 on Flask 0.12.4 on my mac running High Sierra (10.13.6). I'm trying to add the KazooTestHarness to my integration tests. This is the code for doing so -

from kazoo.testing import KazooTestHarness
from os import environ

class TestListStuff(KazooTestHarness):

  def setUp(self):
    environ['ZOOKEEPER_PATH'] = '/usr/local/Cellar/zookeeper/3.4.12/libexec'
    self.setup_zookeeper()

  def tearDown(self):
    self.teardown_zookeeper()

  def test_list_stuff_runs(self, connection):
      connection.fetch_stuff_that_uses_kazoo()

My zookeeper path has both a zookeeper-3.4.12.jar and a lib directory with a log4j-1.2.17.jar file. The error that I'm getting from running the test is

venv/3.6/lib/python3.6/site-packages/kazoo/testing/harness.py:124: in setup_zookeeper
    self.client.start()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <kazoo.client.KazooClient object at 0x110f06710>, timeout = 15

    def start(self, timeout=15):
        """Initiate connection to ZK.

            :param timeout: Time in seconds to wait for connection to
                            succeed.
            :raises: :attr:`~kazoo.interfaces.IHandler.timeout_exception`
                     if the connection wasn't established within `timeout`
                     seconds.

            """
        event = self.start_async()
        event.wait(timeout=timeout)
        if not self.connected:
            # We time-out, ensure we are disconnected
            self.stop()
            raise self.handler.timeout_exception("Connection time-out")

        if self.chroot and not self.exists("/"):
>           warnings.warn("No chroot path exists, the chroot path "
                          "should be created before normal use.")
E           UserWarning: No chroot path exists, the chroot path should be created before normal use.

venv/3.6/lib/python3.6/site-packages/kazoo/client.py:563: UserWarning

Has this occurred for other people? Am I just doing something wrong here? I followed the documentation at https://github.com/python-zk/kazoo/blob/master/docs/testing.rst

StephenSorriaux commented 6 years ago

Hi,

I'm not sure this problem comes from your code since this warning always appears on the first test (check on travis or locally launch any single test). But this should not raise an exception. What are you using for your tests? Is there an option handling warnings as exceptions?

nakulpathak3 commented 6 years ago

Hey! What you said makes sense. It does seem to be just a warning. I also don't have the code branch that I ran into this on so I'll have a hard time reproducing this right now. Probably something to do with warnings being treated as exceptions in the codebase. Going to close it. Thank you!