diff options
| -rw-r--r-- | qpid/cpp/src/tests/brokertest.py | 46 | ||||
| -rwxr-xr-x | qpid/cpp/src/tests/ha_test.py | 12 | ||||
| -rw-r--r-- | qpid/tools/src/py/qpidtoollibs/config.py | 4 |
3 files changed, 31 insertions, 31 deletions
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 "<HaBroker:%s:%d>"%(self.log, self.port()) diff --git a/qpid/tools/src/py/qpidtoollibs/config.py b/qpid/tools/src/py/qpidtoollibs/config.py index 328c132a5c..9168215ac3 100644 --- a/qpid/tools/src/py/qpidtoollibs/config.py +++ b/qpid/tools/src/py/qpidtoollibs/config.py @@ -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 |
