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/04/24 20:59:03 UTC

svn commit: r1589834 - in /qpid/trunk/qpid: cpp/src/tests/ha_test.py cpp/src/tests/ha_tests.py tools/src/py/qpid-ha

Author: aconway
Date: Thu Apr 24 18:59:03 2014
New Revision: 1589834

URL: http://svn.apache.org/r1589834
Log:
NO-JIRA: HA minor cleanup of qpid-ha tool

- Remove some dead code.
- Removed "set" command - not ready for production. All settings in qpidd.conf.
  - Removed related tests in ha_tests
- Improved help on promote command.
- Made option group for common broker connection options.

Modified:
    qpid/trunk/qpid/cpp/src/tests/ha_test.py
    qpid/trunk/qpid/cpp/src/tests/ha_tests.py
    qpid/trunk/qpid/tools/src/py/qpid-ha

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=1589834&r1=1589833&r2=1589834&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/ha_test.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/ha_test.py Thu Apr 24 18:59:03 2014
@@ -177,8 +177,6 @@ acl allow all all
             raise Exception("Error in qpid_ha -b %s %s: %s"%(url, args,e))
 
     def promote(self): self.ready(); self.qpid_ha(["promote"])
-    def set_public_url(self, url): self.qpid_ha(["set", "--public-url", url])
-    def set_brokers_url(self, url): self.qpid_ha(["set", "--brokers-url", url]);
     def replicate(self, from_broker, queue): self.qpid_ha(["replicate", from_broker, queue])
     @property
     def agent(self):
@@ -343,7 +341,6 @@ class HaCluster(object):
         if i == len(self._ports): # Adding new broker after cluster init
             self._ports.append(HaPort(self.test))
             self._set_url()
-            self._update_urls()
         b = self._ha_broker(i, self.next_name())
         self._brokers.append(b)
         return b
@@ -351,11 +348,6 @@ class HaCluster(object):
     def _set_url(self):
         self.url = ",".join("127.0.0.1:%s"%(p.port) for p in self._ports)
 
-    def _update_urls(self):
-        for b in self:
-            b.set_brokers_url(self.url)
-            b.set_public_url(self.url)
-
     def connect(self, i, **kwargs):
         """Connect with reconnect_urls"""
         return self[i].connect(reconnect=True, reconnect_urls=self.url.split(","), **kwargs)

Modified: qpid/trunk/qpid/cpp/src/tests/ha_tests.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/ha_tests.py?rev=1589834&r1=1589833&r2=1589834&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/ha_tests.py (original)
+++ qpid/trunk/qpid/cpp/src/tests/ha_tests.py Thu Apr 24 18:59:03 2014
@@ -1222,55 +1222,6 @@ class RecoveryTests(HaBrokerTest):
         s.sender("q;{create:always}").send("x")
         self.assertEqual("x", s.receiver("q").fetch(0).content)
 
-class ConfigurationTests(HaBrokerTest):
-    """Tests for configuration settings."""
-
-    def test_client_broker_url(self):
-        """Check that setting of broker and public URLs obeys correct defaulting
-        and precedence"""
-
-        def check(broker, brokers, public):
-            qmf = broker.qmf()
-            self.assertEqual(brokers, qmf.brokersUrl)
-            self.assertEqual(public, qmf.publicUrl)
-
-        def start(brokers, public, known=None):
-            args=[]
-            if brokers: args.append("--ha-brokers-url="+brokers)
-            if public: args.append("--ha-public-url="+public)
-            if known: args.append("--known-hosts-url="+known)
-            return HaBroker(self, args=args)
-
-        # Both set explictily, no defaulting
-        b = start("foo:123", "bar:456")
-        check(b, "amqp:tcp:foo:123", "amqp:tcp:bar:456")
-        b.set_brokers_url("foo:999")
-        check(b, "amqp:tcp:foo:999", "amqp:tcp:bar:456")
-        b.set_public_url("bar:999")
-        check(b, "amqp:tcp:foo:999", "amqp:tcp:bar:999")
-
-        # Allow "none" to mean "not set"
-        b = start("none", "none")
-        check(b, "", "")
-
-    def test_failover_exchange(self):
-        """Verify that the failover exchange correctly reports cluster membership"""
-
-        def strip_url(url): return re.sub('amqp:|tcp:', '', url)
-
-        def assert_url(m, url):
-            urls = m.properties['amq.failover']
-            self.assertEqual(1, len(urls))
-            self.assertEqual(strip_url(urls[0]), url)
-
-        cluster = HaCluster(self, 1, args=["--ha-public-url=foo:1234"])
-        r = cluster[0].connect().session().receiver("amq.failover")
-        assert_url(r.fetch(1), "foo:1234")
-        cluster[0].set_public_url("bar:1234")
-        assert_url(r.fetch(1), "bar:1234")
-        cluster[0].set_brokers_url(cluster.url+",xxx:1234")
-        self.assertRaises(qm.Empty, r.fetch, 0) # Not updated for brokers URL
-
 class StoreTests(HaBrokerTest):
     """Test for HA with persistence."""
 

Modified: qpid/trunk/qpid/tools/src/py/qpid-ha
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/tools/src/py/qpid-ha?rev=1589834&r1=1589833&r2=1589834&view=diff
==============================================================================
--- qpid/trunk/qpid/tools/src/py/qpid-ha (original)
+++ qpid/trunk/qpid/tools/src/py/qpid-ha Thu Apr 24 18:59:03 2014
@@ -44,9 +44,6 @@ class ExitStatus(Exception):
 class Command:
     commands = {}
 
-    def add(self, optname, metavar, type, help):
-        self.op.add_option(optname, metavar=metavar, type=type, help=help)
-
     def __init__(self, name, help, arg_names=[], connect_agent=True):
         """@param connect_agent true if we should establish a QMF agent connection"""
         Command.commands[name] = self
@@ -56,13 +53,15 @@ class Command:
         usage="%s [options] %s\n\n%s"%(name, " ".join(arg_names), help)
         self.help = help
         self.op=optparse.OptionParser(usage)
+        common = optparse.OptionGroup(self.op, "Broker connection options")
         def help_default(what): return " (Default %s)"%DEFAULTS[what]
-        self.op.add_option("-b", "--broker", metavar="<address>", help="Address of qpidd broker with syntax: [username/password@] hostname | ip-address [:<port>]"+help_default("broker"))
-        self.op.add_option("--timeout", type="float", metavar="<seconds>", help="Give up if the broker does not respond within the timeout. 0 means wait forever"+help_default("timeout"))
-        self.op.add_option("--sasl-mechanism", metavar="<mech>", help="SASL mechanism for authentication (e.g. EXTERNAL, ANONYMOUS, PLAIN, CRAM-MD5, DIGEST-MD5, GSSAPI). SASL automatically picks the most secure available mechanism - use this option to override")
-        self.op.add_option("--ssl-certificate", metavar="<cert>", help="Client SSL certificate (PEM Format)")
-        self.op.add_option("--ssl-key", metavar="<key>", help="Client SSL private key (PEM Format)")
-        self.op.add_option("--config", metavar="<path/to/qpidd.conf>", help="Connect to the local qpidd by reading its configuration file.")
+        common.add_option("-b", "--broker", metavar="<address>", help="Address of qpidd broker with syntax: [username/password@] hostname | ip-address [:<port>]"+help_default("broker"))
+        common.add_option("--timeout", type="float", metavar="<seconds>", help="Give up if the broker does not respond within the timeout. 0 means wait forever"+help_default("timeout"))
+        common.add_option("--sasl-mechanism", metavar="<mech>", help="SASL mechanism for authentication (e.g. EXTERNAL, ANONYMOUS, PLAIN, CRAM-MD5, DIGEST-MD5, GSSAPI). SASL automatically picks the most secure available mechanism - use this option to override")
+        common.add_option("--ssl-certificate", metavar="<cert>", help="Client SSL certificate (PEM Format)")
+        common.add_option("--ssl-key", metavar="<key>", help="Client SSL private key (PEM Format)")
+        common.add_option("--config", metavar="<path/to/qpidd.conf>", help="Read default connection configuration from the qpidd.conf broker configuration file. Defaults are overridden by command-line options.)")
+        self.op.add_option_group(common)
 
     def connect(self, opts):
         conn_options = {}
@@ -118,7 +117,7 @@ PingCmd()
 
 class PromoteCmd(Command):
     def __init__(self):
-        Command.__init__(self, "promote","Promote broker from backup to primary")
+        Command.__init__(self, "promote","Promote a backup broker to primary. Note this command will not detect if another broker is already primary, and creating a second primary will make the cluster inconsistent. It is up to the caller (normally the cluster resource manager) to ensure there is only one primary.")
     def do_execute(self, qmf_broker, ha_broker, opts, args):
         qmf_broker._method("promote", {}, HA_BROKER)
 PromoteCmd()
@@ -165,18 +164,6 @@ class ReplicateCmd(Command):
         qmf_broker._method("replicate", {"broker":args[1], "queue":args[2]}, HA_BROKER)
 ReplicateCmd()
 
-class SetCmd(Command):
-    def __init__(self):
-        Command.__init__(self, "set", "Set HA configuration settings")
-        self.add("--brokers-url", "<url>", "string", "URL with address of each broker in the cluster. Used by brokers to connect to each other.")
-        self.add("--public-url", "<url>", "string", "URL advertised to clients to connect to the cluster. May be a list or a VIP.")
-
-    def do_execute(self, qmf_broker, ha_broker, opts, args):
-        if (opts.brokers_url): qmf_broker._method("setBrokersUrl", {"url":opts.brokers_url}, HA_BROKER)
-        if (opts.public_url): qmf_broker._method("setPublicUrl", {"url":opts.public_url}, HA_BROKER)
-
-SetCmd()
-
 class QueryCmd(Command):
     def __init__(self):
         Command.__init__(self, "query", "Print HA configuration and status")



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org