diff --git a/README.md b/README.md --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ #### Non Debian-like host -The tests expects `/usr/sbin/cassandra` to exist. +The tests expects the path to `cassandra` to either be unspecified, it is then +looked up at `/usr/sbin/cassandra`, either specified through the environment +variable `SWH_CASSANDRA_BIN`. Optionally, you can avoid running the cassandra tests. diff --git a/swh/storage/tests/test_cassandra.py b/swh/storage/tests/test_cassandra.py --- a/swh/storage/tests/test_cassandra.py +++ b/swh/storage/tests/test_cassandra.py @@ -96,13 +96,15 @@ ) ) - if os.environ.get("LOG_CASSANDRA"): + if os.environ.get("SWH_CASSANDRA_LOG"): stdout = stderr = None else: stdout = stderr = subprocess.DEVNULL + + cassandra_bin = os.environ.get("SWH_CASSANDRA_BIN", "/usr/sbin/cassandra") proc = subprocess.Popen( [ - "/usr/sbin/cassandra", + cassandra_bin, "-Dcassandra.config=file://%s/cassandra.yaml" % cassandra_conf, "-Dcassandra.logdir=%s" % cassandra_log, "-Dcassandra.jmx.local.port=%d" % jmx_port, @@ -123,9 +125,11 @@ if running: yield (["127.0.0.1"], native_transport_port) - if not running or os.environ.get("LOG_CASSANDRA"): - with open(str(cassandra_log.join("debug.log"))) as fd: - print(fd.read()) + if not running or os.environ.get("SWH_CASSANDRA_LOG"): + debug_log_path = str(cassandra_log.join("debug.log")) + if os.path.exists(debug_log_path): + with open(debug_log_path) as fd: + print(fd.read()) if not running: raise Exception("cassandra process stopped unexpectedly.") diff --git a/tox.ini b/tox.ini --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,8 @@ pytest-cov dev: ipdb passenv = - LOG_CASSANDRA + SWH_CASSANDRA_BIN + SWH_CASSANDRA_LOG commands = pytest \ !slow: --hypothesis-profile=fast \