You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2017/03/15 15:00:07 UTC
[3/3] qpid-dispatch git commit: DISPATCH_726 - Added system test for
failover lists
DISPATCH_726 - Added system test for failover lists
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/0267607d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/0267607d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/0267607d
Branch: refs/heads/master
Commit: 0267607da1678779d5beb7af5be6161b4208a940
Parents: 06d1c9e
Author: Ted Ross <tr...@redhat.com>
Authored: Wed Mar 15 10:30:59 2017 -0400
Committer: Ted Ross <tr...@redhat.com>
Committed: Wed Mar 15 10:55:13 2017 -0400
----------------------------------------------------------------------
tests/CMakeLists.txt | 1 +
tests/system_tests_failover_list.py | 139 +++++++++++++++++++++++++++++++
2 files changed, 140 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0267607d/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 630646a..2201e22 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -94,6 +94,7 @@ foreach(py_test_module
system_tests_multi_tenancy
system_tests_dynamic_terminus
system_tests_log_message_components
+ system_tests_failover_list
${SYSTEM_TESTS_HTTP}
)
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/0267607d/tests/system_tests_failover_list.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_failover_list.py b/tests/system_tests_failover_list.py
new file mode 100644
index 0000000..b7cc30b
--- /dev/null
+++ b/tests/system_tests_failover_list.py
@@ -0,0 +1,139 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import unittest, os, json
+from subprocess import PIPE, STDOUT
+from proton import Message, PENDING, ACCEPTED, REJECTED, RELEASED, SSLDomain, SSLUnavailable, Timeout
+from system_test import TestCase, Qdrouterd, main_module, DIR, TIMEOUT, Process
+from proton.handlers import MessagingHandler
+from proton.reactor import Container, DynamicNodeProperties
+
+# PROTON-828:
+try:
+ from proton import MODIFIED
+except ImportError:
+ from proton import PN_STATUS_MODIFIED as MODIFIED
+
+
+class RouterTest(TestCase):
+
+ inter_router_port = None
+
+ @classmethod
+ def setUpClass(cls):
+ """Start a router"""
+ super(RouterTest, cls).setUpClass()
+
+ def router(name):
+
+ config = [
+ ('router', {'mode': 'standalone', 'id': name}),
+ ('listener', {'port': cls.tester.get_port()}),
+ ('listener', {'port': cls.tester.get_port(), 'failoverList': 'other-host:25000'}),
+ ('listener', {'port': cls.tester.get_port(), 'failoverList': 'second-host:25000, amqps://third-host:5671'})
+ ]
+
+ config = Qdrouterd.Config(config)
+
+ cls.routers.append(cls.tester.qdrouterd(name, config, wait=True))
+
+ cls.routers = []
+
+ inter_router_port = cls.tester.get_port()
+
+ router('A')
+ cls.routers[0].wait_ready()
+
+
+ def test_01_no_failover_list(self):
+ test = FailoverTest(self.routers[0].addresses[0], 0)
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_02_single_failover_host(self):
+ test = FailoverTest(self.routers[0].addresses[1], 1, [{'network-host':'other-host', 'port':'25000'}])
+ test.run()
+ self.assertEqual(None, test.error)
+
+ def test_03_double_failover_host(self):
+ test = FailoverTest(self.routers[0].addresses[2], 2, \
+ [{'network-host':'second-host', 'port':'25000'}, {'scheme': 'amqps', 'network-host':'third-host', 'port': '5671'}])
+ test.run()
+ self.assertEqual(None, test.error)
+
+
+class Timeout(object):
+ def __init__(self, parent):
+ self.parent = parent
+
+ def on_timer_task(self, event):
+ self.parent.timeout()
+
+
+class FailoverTest(MessagingHandler):
+ def __init__(self, host, count, elements=[]):
+ super(FailoverTest, self).__init__()
+ self.host = host
+ self.count = count
+ self.elements = elements
+ self.conn = None
+ self.error = None
+
+ def timeout(self):
+ self.error = "Timeout Expired"
+ self.conn.close()
+
+ def on_start(self, event):
+ self.timer = event.reactor.schedule(5, Timeout(self))
+ self.conn = event.container.connect(self.host)
+
+ def on_connection_opened(self, event):
+ properties = event.connection.remote_properties
+ fol = None
+ try:
+ fol = properties['failover-server-list']
+ except:
+ fol = None
+
+ if self.count == 0:
+ if fol != None and fol != []:
+ self.error = "Expected no failover-list, got: %r" % fol
+
+ elif fol.__class__ != list:
+ self.error = "Expected list, got: %r" % fol.__class__
+
+ elif self.count != len(fol):
+ self.error = "Expected list of size %d, got size %d" % (self.count, len(fol))
+
+ for i in range(self.count):
+ got = fol[i]
+ want = self.elements[i]
+ if got != want:
+ self.error = "Expected %r, got %r" % (want, got)
+
+ self.timer.cancel()
+ self.conn.close()
+
+
+ def run(self):
+ Container(self).run()
+
+
+if __name__ == '__main__':
+ unittest.main(main_module())
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org