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/trunk@1662275 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/qpid/cpp/src/tests/brokertest.py b/qpid/cpp/src/tests/brokertest.py
index 598879d..ba65936 100644
--- a/qpid/cpp/src/tests/brokertest.py
+++ b/qpid/cpp/src/tests/brokertest.py
@@ -23,7 +23,6 @@
 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 237216e..e262fae 100755
--- a/qpid/cpp/src/tests/ha_test.py
+++ b/qpid/cpp/src/tests/ha_test.py
@@ -24,6 +24,7 @@
 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 @@
         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 @@
         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 a43b939..1d475eb 100755
--- a/qpid/cpp/src/tests/ha_tests.py
+++ b/qpid/cpp/src/tests/ha_tests.py
@@ -1631,12 +1631,14 @@
                     "*.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"
+
+