You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gm...@apache.org on 2018/04/20 13:47:13 UTC
qpid-dispatch git commit: NO-JIRA - Removed sleep and introduced a
timer to test connector failover urls
Repository: qpid-dispatch
Updated Branches:
refs/heads/master 7952fbf41 -> 5340c545f
NO-JIRA - Removed sleep and introduced a timer to test connector failover urls
Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/5340c545
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/5340c545
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/5340c545
Branch: refs/heads/master
Commit: 5340c545f41bb30a0937c9350b21bbdbd0a6c313
Parents: 7952fbf
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Fri Apr 13 13:36:35 2018 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Fri Apr 20 09:41:51 2018 -0400
----------------------------------------------------------------------
tests/system_tests_handle_failover.py | 53 +++++++++++++++++++++++-------
1 file changed, 42 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/5340c545/tests/system_tests_handle_failover.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_handle_failover.py b/tests/system_tests_handle_failover.py
index 217108c..f8c70e9 100644
--- a/tests/system_tests_handle_failover.py
+++ b/tests/system_tests_handle_failover.py
@@ -17,13 +17,14 @@
# under the License.
#
+from threading import Timer
import unittest2 as unittest
import json, re
-from time import sleep
from system_test import main_module, TIMEOUT
from system_test import TestCase, Qdrouterd, Process, TIMEOUT
from subprocess import PIPE, STDOUT
+
class FailoverTest(TestCase):
inter_router_port = None
@@ -80,6 +81,13 @@ class FailoverTest(TestCase):
cls.routers[1].wait_router_connected('QDR.B')
+ def __init__(self, test_method):
+ TestCase.__init__(self, test_method)
+ self.success = False
+ self.timer_delay = 2
+ self.max_attempts = 5
+ self.attempts = 0
+
def address(self):
return self.routers[1].addresses[0]
@@ -116,6 +124,33 @@ class FailoverTest(TestCase):
output = json.loads(self.run_qdmanage(query_command))
self.assertIn(FailoverTest.failover_list, output[0]['failoverUrls'])
+ def schedule_failover_test(self):
+ if self.attempts < self.max_attempts:
+ if not self.success:
+ Timer(self.timer_delay, self.check_connector).start()
+ self.attempts += 1
+
+ def check_connector(self):
+ # Router A should now try to connect to Router C. Router C does NOT have failoverUrls.
+ # Query Router A which previously had failoverUrls in its connector (because Router B sent it failoverUrls)
+ # does not have it anymore.
+ long_type = 'org.apache.qpid.dispatch.connector'
+ query_command = 'QUERY --type=' + long_type
+ output = json.loads(self.run_qdmanage(query_command, address=self.routers[1].addresses[0]))
+ if output[0].get('failoverUrls') is None:
+ self.success = True
+ else:
+ self.schedule_failover_test()
+
+ def can_terminate(self):
+ if self.attempts == self.max_attempts:
+ return True
+
+ if self.success:
+ return True
+
+ return False
+
def test_remove_router_B(self):
# First make sure there are no inter-router connections on router C
outs = self.run_qdstat(['--connections'], address=self.routers[2].addresses[1])
@@ -126,17 +161,13 @@ class FailoverTest(TestCase):
# Kill the router B
FailoverTest.routers[0].teardown()
- # Make sure that the router B is gone
- # You need to sleep 5 seconds for the router to cycle thru the failover urls and make a successful connection
- # to Router C
- sleep(4)
+ # Schedule a test to make sure that the failover url is empty
+ self.schedule_failover_test()
- long_type = 'org.apache.qpid.dispatch.connector'
- query_command = 'QUERY --type=' + long_type
- output = json.loads(self.run_qdmanage(query_command, address=self.routers[1].addresses[0]))
- # The failoverUrls must now be gone since the backup router does not send a failoverUrls in its
- # connection properties.
- self.assertTrue(output[0].get('failoverUrls') is None)
+ while not self.can_terminate():
+ pass
+
+ self.assertTrue(self.success)
# Since router B has been killed, router A should now try to connect to a listener on router C.
# Use qdstat to connect to router C and determine that there is an inter-router connection with router A.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org