From e57cd3393b842e40f9da989ab4d60142682ba73e Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 1 May 2014 22:20:26 +0000 Subject: NO-JIRA: HA fix hanging ha_tests.test_failover_send_receive on RHEL5 The test was hanging because of a python construct not available in 2.4. It was causing an exception in a strange place because this bit of code was imported at runtime, and that was hanging the test. Fixed and did some cleanup to avoid such mysterious hangs in future: - Fixed qpidtoollibs/config.py to work with python 2.4. - Import qpid-ha script at import time rather than runtime. - Fix Popen.teardown logic to avoid hanging if a process can't be killed. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1591794 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/tests/brokertest.py | 46 +++++++++++++++++++--------------------- qpid/cpp/src/tests/ha_test.py | 12 +++++------ 2 files changed, 28 insertions(+), 30 deletions(-) (limited to 'qpid/cpp') diff --git a/qpid/cpp/src/tests/brokertest.py b/qpid/cpp/src/tests/brokertest.py index ebb1702a05..9d77baebaf 100644 --- a/qpid/cpp/src/tests/brokertest.py +++ b/qpid/cpp/src/tests/brokertest.py @@ -178,29 +178,27 @@ class Popen(subprocess.Popen): raise BadProcessStatus("%s %s%s" % (self.pname, msg, err)) def teardown(self): # Clean up at end of test. - try: - if self.expect == EXPECT_UNKNOWN: - try: self.kill() # Just make sure its dead - except: pass - elif self.expect == EXPECT_RUNNING: - if self.poll() != None: - self.unexpected("expected running, exit code %d" % self.returncode) - else: - try: - self.kill() - except Exception,e: - self.unexpected("exception from kill: %s" % str(e)) - else: - retry(lambda: self.poll() is not None) - if self.returncode is None: # Still haven't stopped - self.kill() - self.unexpected("still running") - elif self.expect == EXPECT_EXIT_OK and self.returncode != 0: - self.unexpected("exit code %d" % self.returncode) - elif self.expect == EXPECT_EXIT_FAIL and self.returncode == 0: - self.unexpected("expected error") - finally: - self.wait() # Clean up the process. + if self.expect == EXPECT_UNKNOWN: + try: self.kill() # Just make sure its dead + except: pass + elif self.expect == EXPECT_RUNNING: + if self.poll() != None: + self.unexpected("expected running, exit code %d" % self.returncode) + else: + try: + self.kill() + except Exception,e: + self.unexpected("exception from kill: %s" % str(e)) + else: + retry(lambda: self.poll() is not None) + if self.returncode is None: # Still haven't stopped + self.kill() + self.unexpected("still running") + elif self.expect == EXPECT_EXIT_OK and self.returncode != 0: + self.unexpected("exit code %d" % self.returncode) + elif self.expect == EXPECT_EXIT_FAIL and self.returncode == 0: + self.unexpected("expected error") + self.wait() def communicate(self, input=None): @@ -325,7 +323,7 @@ class Broker(Popen): self._host = "127.0.0.1" self._agent = None - log.debug("Started broker %s (%s, %s)" % (self.name, self.pname, self.log)) + log.debug("Started broker %s" % self) def host(self): return self._host diff --git a/qpid/cpp/src/tests/ha_test.py b/qpid/cpp/src/tests/ha_test.py index fe1894ecc8..f09a4cd573 100755 --- a/qpid/cpp/src/tests/ha_test.py +++ b/qpid/cpp/src/tests/ha_test.py @@ -153,15 +153,15 @@ acl allow all all if not "--acl-file" in args: args += [ "--acl-file", acl, ] args += ["--socket-fd=%s"%ha_port.fileno, "--listen-disable=tcp"] - Broker.__init__(self, test, args, port=ha_port.port, **kwargs) - self.qpid_ha_path=os.path.join(os.getenv("PYTHON_COMMANDS"), "qpid-ha") - assert os.path.exists(self.qpid_ha_path) - self.qpid_config_path=os.path.join(os.getenv("PYTHON_COMMANDS"), "qpid-config") - assert os.path.exists(self.qpid_config_path) - self.qpid_ha_script=import_script(self.qpid_ha_path) self._agent = None self.client_credentials = client_credentials self.ha_port = ha_port + 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) def __repr__(self): return ""%(self.log, self.port()) -- cgit v1.2.1