diff options
author | Alan Conway <aconway@apache.org> | 2015-02-26 21:55:57 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2015-02-26 21:55:57 +0000 |
commit | 4140b2c9a713f12667d02ce7a84a257b754a2329 (patch) | |
tree | 7f1fd4fb797741ed2d86f45d38da09faa59ddacf | |
parent | 46abec8a404f17b2d2f2ab18f3d67ca7ceef6165 (diff) | |
download | qpid-python-4140b2c9a713f12667d02ce7a84a257b754a2329.tar.gz |
QPID-6414: Skip HA tests if qpid-ha or qpid-config tools are not available.
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/0.32@1662579 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/tests/brokertest.py | 1 | ||||
-rwxr-xr-x | qpid/cpp/src/tests/ha_test.py | 23 | ||||
-rwxr-xr-x | qpid/cpp/src/tests/ha_tests.py | 14 |
3 files changed, 24 insertions, 14 deletions
diff --git a/qpid/cpp/src/tests/brokertest.py b/qpid/cpp/src/tests/brokertest.py index 598879d4ad..ba65936df7 100644 --- a/qpid/cpp/src/tests/brokertest.py +++ b/qpid/cpp/src/tests/brokertest.py @@ -23,7 +23,6 @@ import os, signal, string, tempfile, subprocess, socket, threading, time, imp, r import qpid, traceback, signal from qpid import connection, util from qpid.compat import format_exc -from qpid.harness import Skipped from unittest import TestCase from copy import copy from threading import Thread, Lock, Condition diff --git a/qpid/cpp/src/tests/ha_test.py b/qpid/cpp/src/tests/ha_test.py index 237216e208..e262faea40 100755 --- a/qpid/cpp/src/tests/ha_test.py +++ b/qpid/cpp/src/tests/ha_test.py @@ -24,6 +24,7 @@ from brokertest import * from threading import Thread, Lock, Condition from logging import getLogger, WARN, ERROR, DEBUG, INFO from qpidtoollibs import BrokerAgent +from qpid.harness import Skipped log = getLogger(__name__) @@ -156,13 +157,20 @@ acl allow all all Broker.__init__(self, test, args, port=ha_port.port, **kwargs) # Do some static setup to locate the qpid-config and qpid-ha tools. - qpid_ha_script=import_script(os.path.join(os.getenv("PYTHON_COMMANDS"),"qpid-ha")) - qpid_config_path=os.path.join(os.getenv("PYTHON_COMMANDS"), "qpid-config") - assert os.path.isfile(qpid_config_path) + @property + def qpid_ha_script(self): + if not hasattr(self, "_qpid_ha_script"): + qpid_ha_exec = os.getenv("QPID_HA_EXEC") + if not qpid_ha_exec or not os.path.isfile(qpid_ha_exec): + raise Skipped("qpid-ha not available") + self._qpid_ha_script = import_script(qpid_ha_exec) + return self._qpid_ha_script def __repr__(self): return "<HaBroker:%s:%d>"%(self.log, self.port()) def qpid_ha(self, args): + if not self.qpid_ha_script: + raise Skipped("qpid-ha not available") try: cred = self.client_credentials url = self.host_port() @@ -216,12 +224,13 @@ acl allow all all agent = self.agent assert retry(lambda: agent.getQueue(queue) is None, timeout=timeout), "%s: queue %s still present"%(msg,queue) - # TODO aconway 2012-05-01: do direct python call to qpid-config code. def qpid_config(self, args): + qpid_config_exec = os.getenv("QPID_CONFIG_EXEC") + if not qpid_config_exec or not os.path.isfile(qpid_config_exec): + raise Skipped("qpid-config not available") assert subprocess.call( - [self.qpid_config_path, "--broker", self.host_port()]+args, - stdout=1, stderr=subprocess.STDOUT - ) == 0 + [qpid_config_exec, "--broker", self.host_port()]+args, stdout=1, stderr=subprocess.STDOUT + ) == 0, "qpid-config failed" def config_replicate(self, from_broker, queue): self.qpid_config(["add", "queue", "--start-replica", from_broker, queue]) diff --git a/qpid/cpp/src/tests/ha_tests.py b/qpid/cpp/src/tests/ha_tests.py index a43b939ee3..1d475ebfe7 100755 --- a/qpid/cpp/src/tests/ha_tests.py +++ b/qpid/cpp/src/tests/ha_tests.py @@ -1631,12 +1631,14 @@ class TransactionTests(HaBrokerTest): "*.tx.*"]).assert_exit_ok() if __name__ == "__main__": - outdir = "ha_tests.tmp" - shutil.rmtree(outdir, True) - qpid_ha = os.getenv("QPID_HA_EXEC") - if qpid_ha and os.path.exists(qpid_ha): + qpid_ha_exec = os.getenv("QPID_HA_EXEC") + if qpid_ha_exec and os.path.isfile(qpid_ha_exec): + outdir = "ha_tests.tmp" + shutil.rmtree(outdir, True) os.execvp("qpid-python-test", - ["qpid-python-test", "-m", "ha_tests", "-DOUTDIR=%s"%outdir] + ["qpid-python-test", "-m", "ha_tests", "-DOUTDIR=%s"%outdir] + sys.argv[1:]) else: - print "Skipping ha_tests, %s not available"%(qpid_ha) + print "Skipping ha_tests, qpid-ha not available" + + |