You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2014/05/02 00:20:26 UTC
svn commit: r1591794 - in /qpid/trunk/qpid: cpp/src/tests/brokertest.py
cpp/src/tests/ha_test.py tools/src/py/qpidtoollibs/config.py
Author: aconway
Date: Thu May 1 22:20:26 2014
New Revision: 1591794
URL: http://svn.apache.org/r1591794
Log:
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.
Modified:
qpid/trunk/qpid/cpp/src/tests/brokertest.py
qpid/trunk/qpid/cpp/src/tests/ha_test.py
qpid/trunk/qpid/tools/src/py/qpidtoollibs/config.py
Modified: qpid/trunk/qpid/cpp/src/tests/brokertest.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/brokertest.py?rev=1591794&r1=1591793&r2=1591794&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/brokertest.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/brokertest.py Thu May 1 22:20:26 2014
@@ -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
Modified: qpid/trunk/qpid/cpp/src/tests/ha_test.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/ha_test.py?rev=1591794&r1=1591793&r2=1591794&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/ha_test.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/ha_test.py Thu May 1 22:20:26 2014
@@ -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 "<HaBroker:%s:%d>"%(self.log, self.port())
Modified: qpid/trunk/qpid/tools/src/py/qpidtoollibs/config.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpidtoollibs/config.py?rev=1591794&r1=1591793&r2=1591794&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpidtoollibs/config.py (original)
+++ qpid/trunk/qpid/tools/src/py/qpidtoollibs/config.py Thu May 1 22:20:26 2014
@@ -24,10 +24,12 @@ QPID_ENV_PREFIX="QPID_"
def parse_qpidd_conf(config_file):
"""Parse a qpidd.conf configuration file into a dictionary"""
- with open(config_file) as f:
+ f = open(config_file)
+ try:
clean = filter(None, [line.split("#")[0].strip() for line in f]) # Strip comments and blanks
def item(line): return [x.strip() for x in line.split("=")]
config = dict(item(line) for line in clean if "=" in line)
+ finally: f.close()
def name(env_name): return env_name[len(QPID_ENV_PREFIX):].lower()
env = dict((name(i[0]), i[1]) for i in os.environ.iteritems() if i[0].startswith(QPID_ENV_PREFIX))
config.update(env) # Environment takes precedence
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org