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/06/28 13:56:26 UTC

qpid-dispatch git commit: DISPATCH-1008 - Original connection information is preserved in the failover list and a connection is attempted via round robin when the router fails over

Repository: qpid-dispatch
Updated Branches:
  refs/heads/master 5d7304f2c -> e92dab3c5


DISPATCH-1008 - Original connection information is preserved in the failover list and a connection is attempted via round robin when the router fails over


Project: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/commit/e92dab3c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/tree/e92dab3c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-dispatch/diff/e92dab3c

Branch: refs/heads/master
Commit: e92dab3c5a06b20760e11d1dd702fdb0b4c84b94
Parents: 5d7304f
Author: Ganesh Murthy <gm...@redhat.com>
Authored: Fri May 25 15:07:44 2018 -0400
Committer: Ganesh Murthy <gm...@redhat.com>
Committed: Thu Jun 28 09:48:07 2018 -0400

----------------------------------------------------------------------
 include/qpid/dispatch/failoverlist.h  |   1 +
 src/connection_manager.c              |  94 +++++++++++++++-------
 src/router_node.c                     |  46 +++++++----
 src/server.c                          |  65 ++++++++++------
 tests/system_tests_handle_failover.py | 120 +++++++++++++++++++++--------
 5 files changed, 231 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e92dab3c/include/qpid/dispatch/failoverlist.h
----------------------------------------------------------------------
diff --git a/include/qpid/dispatch/failoverlist.h b/include/qpid/dispatch/failoverlist.h
index d321445..369066a 100644
--- a/include/qpid/dispatch/failoverlist.h
+++ b/include/qpid/dispatch/failoverlist.h
@@ -32,6 +32,7 @@ typedef struct qd_failover_item_t {
     char *port;
     char *hostname;
     char *host_port;
+    int   retries;
 } qd_failover_item_t;
 
 DEQ_DECLARE(qd_failover_item_t, qd_failover_item_list_t);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e92dab3c/src/connection_manager.c
----------------------------------------------------------------------
diff --git a/src/connection_manager.c b/src/connection_manager.c
index 628379f..066146e 100644
--- a/src/connection_manager.c
+++ b/src/connection_manager.c
@@ -660,12 +660,18 @@ qd_error_t qd_entity_refresh_listener(qd_entity_t* entity, void *impl)
 }
 
 
+/**
+ * Calculates the total length of the failover  list string.
+ * For example, the failover list string can look like this - "amqp://0.0.0.0:62616, amqp://0.0.0.0:61616"
+ * This function calculates the length of the above string by adding up the scheme (amqp or qmqps) and host_port for each failover item.
+ * It also assumes that there will be a comma and a space between each failover item.
+ *
+ */
 static int get_failover_info_length(qd_failover_item_list_t   conn_info_list)
 {
     int arr_length = 0;
     qd_failover_item_t *item = DEQ_HEAD(conn_info_list);
 
-    item = DEQ_NEXT(item);
     while(item) {
         if (item->scheme) {
             // The +3 is for the '://'
@@ -676,7 +682,7 @@ static int get_failover_info_length(qd_failover_item_list_t   conn_info_list)
         }
         item = DEQ_NEXT(item);
         if (item) {
-            // This is for the comma between the items
+            // This is for the comma and space between the items
             arr_length += 2;
         }
     }
@@ -688,27 +694,50 @@ static int get_failover_info_length(qd_failover_item_list_t   conn_info_list)
     return arr_length;
 }
 
+/**
+ *
+ * Creates a failover url list. This comma separated failover list shows a list of urls that the router will attempt
+ * to connect to in case the primary connection fails. The router will attempt these failover connections to urls in
+ * the order that they appear in the list.
+ *
+ */
 qd_error_t qd_entity_refresh_connector(qd_entity_t* entity, void *impl)
 {
     qd_connector_t *ct = (qd_connector_t*) impl;
 
-    if (DEQ_SIZE(ct->conn_info_list) > 1) {
-        qd_failover_item_list_t   conn_info_list = ct->conn_info_list;
+    int conn_index = ct->conn_index;
 
-        qd_failover_item_t *item = DEQ_HEAD(conn_info_list);
+    int i = 1;
+    int num_items = 0;
 
-        //
-        // As you can see we are skipping the head of the list. The
-        // first item in the list is always the original connection information
-        // and we dont want to display that information as part of the failover list.
-        //
-        int arr_length = get_failover_info_length(conn_info_list);
-        char failover_info[arr_length];
-        memset(failover_info, 0, sizeof(failover_info));
+    qd_failover_item_list_t   conn_info_list = ct->conn_info_list;
 
-        item = DEQ_NEXT(item);
+    int conn_info_len = DEQ_SIZE(conn_info_list);
+
+    qd_failover_item_t *item = DEQ_HEAD(conn_info_list);
+
+    int arr_length = get_failover_info_length(conn_info_list);
+
+    // This is the string that will contain the comma separated failover list
+    char failover_info[arr_length];
+
+    memset(failover_info, 0, sizeof(failover_info));
 
-        while(item) {
+    while(item) {
+
+        // Break out of the loop when we have hit all items in the list.
+        if (num_items >= conn_info_len)
+            break;
+
+        if (num_items >= 1) {
+            strcat(failover_info, ", ");
+        }
+
+        // We need to go to the elements in the list to get to the
+        // element that matches the connection index. This is the first
+        // url that the router will try to connect on ffailover.
+        if (conn_index == i) {
+            num_items += 1;
             if (item->scheme) {
                 strcat(failover_info, item->scheme);
                 strcat(failover_info, "://");
@@ -716,20 +745,30 @@ qd_error_t qd_entity_refresh_connector(qd_entity_t* entity, void *impl)
             if (item->host_port) {
                 strcat(failover_info, item->host_port);
             }
-            item = DEQ_NEXT(item);
-            if (item) {
-                strcat(failover_info, ", ");
+        }
+        else {
+            if (num_items > 0) {
+                num_items += 1;
+                if (item->scheme) {
+                    strcat(failover_info, item->scheme);
+                    strcat(failover_info, "://");
+                }
+                if (item->host_port) {
+                    strcat(failover_info, item->host_port);
+                }
             }
         }
 
-        if (qd_entity_set_string(entity, "failoverUrls", failover_info) == 0)
-            return QD_ERROR_NONE;
-    }
-    else {
-        if (qd_entity_clear(entity, "failoverUrls") == 0)
-            return QD_ERROR_NONE;
+        i += 1;
+
+        item = DEQ_NEXT(item);
+        if (item == 0)
+            item = DEQ_HEAD(conn_info_list);
     }
 
+    if (qd_entity_set_string(entity, "failoverUrls", failover_info) == 0)
+        return QD_ERROR_NONE;
+
     return qd_error_code();
 }
 
@@ -749,10 +788,13 @@ qd_connector_t *qd_dispatch_configure_connector(qd_dispatch_t *qd, qd_entity_t *
         //
         qd_failover_item_t *item = NEW(qd_failover_item_t);
         ZERO(item);
-        item->scheme   = 0;
+        if (ct->config.ssl_required)
+            item->scheme   = strdup("amqps");
+        else
+            item->scheme   = strdup("amqp");
+
         item->host     = strdup(ct->config.host);
         item->port     = strdup(ct->config.port);
-        item->hostname = 0;
 
         int hplen = strlen(item->host) + strlen(item->port) + 2;
         item->host_port = malloc(hplen);

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e92dab3c/src/router_node.c
----------------------------------------------------------------------
diff --git a/src/router_node.c b/src/router_node.c
index c305e54..fd45435 100644
--- a/src/router_node.c
+++ b/src/router_node.c
@@ -856,32 +856,52 @@ static void AMQP_opened_handler(qd_router_t *router, qd_connection_t *conn, bool
 
     bool found_failover = false;
 
+
     if (conn->connector && DEQ_SIZE(conn->connector->conn_info_list) > 1) {
-        // Here we are simply removing all other failover information except the one we used to make a successful connection.
+        // Here we are simply removing all other failover information except the original connection information and the one we used to make a successful connection.
         int i = 1;
         qd_failover_item_t *item = DEQ_HEAD(conn->connector->conn_info_list);
         qd_failover_item_t *next_item = 0;
+
+        bool match_found = false;
+        int dec_conn_index=0;
+
         while(item) {
+
+            //The first item on this list is always the original connector, so we want to keep that item in place
+            // We have to delete items in the list that were left over from the previous failover list from the previous connection
+            // because the new connection might have its own failover list.
             if (i != conn->connector->conn_index) {
-                next_item = DEQ_NEXT(item);
-                free(item->scheme);
-                free(item->host);
-                free(item->port);
-                free(item->hostname);
-                free(item->host_port);
-                DEQ_REMOVE(conn->connector->conn_info_list, item);
-
-                free(item);
-                item = next_item;
+                if (item != DEQ_HEAD(conn->connector->conn_info_list)) {
+                    next_item = DEQ_NEXT(item);
+                    free(item->scheme);
+                    free(item->host);
+                    free(item->port);
+                    free(item->hostname);
+                    free(item->host_port);
+
+                    DEQ_REMOVE(conn->connector->conn_info_list, item);
+
+                    free(item);
+                    item = next_item;
+
+                    // We are removing an item from the list before the conn_index match was found. We need to
+                    // decrement the conn_index
+                    if (!match_found)
+                        dec_conn_index += 1;
+                }
+                else {
+                    item = DEQ_NEXT(item);
+                }
             }
             else {
+                match_found = true;
                 item = DEQ_NEXT(item);
             }
             i += 1;
         }
-        conn->connector->conn_index = 0;
 
-        // By the end of this loop we should be left with only one element in the conn_info_list.
+        conn->connector->conn_index -= dec_conn_index;
     }
 
     if (props) {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e92dab3c/src/server.c
----------------------------------------------------------------------
diff --git a/src/server.c b/src/server.c
index b3a4202..f065be3 100644
--- a/src/server.c
+++ b/src/server.c
@@ -94,6 +94,7 @@ char *COMPONENT_SEPARATOR = ";";
 static const int BACKLOG = 50;  /* Listening backlog */
 
 static void setup_ssl_sasl_and_open(qd_connection_t *ctx);
+static qd_failover_item_t *qd_connector_get_conn_info(qd_connector_t *ct);
 
 /**
  * This function is set as the pn_transport->tracer and is invoked when proton tries to write the log message to pn_transport->tracer
@@ -656,6 +657,7 @@ static void on_connection_bound(qd_server_t *server, pn_event_t *e) {
     } else if (ctx->connector) { /* Establishing an outgoing connection */
         config = &ctx->connector->config;
         setup_ssl_sasl_and_open(ctx);
+
     } else {                    /* No connector and no listener */
         connect_fail(ctx, QD_AMQP_COND_INTERNAL_ERROR, "unknown Connection");
         return;
@@ -769,13 +771,8 @@ static void qd_connection_free(qd_connection_t *ctx)
         ctx->connector->ctx = 0;
         // Increment the connection index by so that we can try connecting to the failover url (if any).
         bool has_failover = qd_connector_has_failover_info(ctx->connector);
-        if (has_failover) {
-            if (DEQ_SIZE(ctx->connector->conn_info_list) == ctx->connector->conn_index)
-                // Start round robin again
-                ctx->connector->conn_index = 1;
-            else
-                ctx->connector->conn_index += 1;
 
+        if (has_failover) {
             // Go thru the failover list round robin.
             // IMPORTANT: Note here that we set the re-try timer to 1 second.
             // We want to quickly keep cycling thru the failover urls every second.
@@ -839,6 +836,22 @@ static void startup_timer_handler(void *context)
     qd_connection_invoke_deferred(ctx, timeout_on_handhsake, context);
 }
 
+static void qd_increment_conn_index(qd_connection_t *ctx)
+{
+    if (ctx->connector) {
+        qd_failover_item_t *item = qd_connector_get_conn_info(ctx->connector);
+
+        if (item->retries == 1) {
+            ctx->connector->conn_index += 1;
+            if (ctx->connector->conn_index > DEQ_SIZE(ctx->connector->conn_info_list))
+                ctx->connector->conn_index = 1;
+            item->retries = 0;
+        }
+        else
+            item->retries += 1;
+    }
+
+}
 
 /* Events involving a connection or listener are serialized by the proactor so
  * only one event per connection / listener will be processed at a time.
@@ -892,6 +905,9 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e) {
             ctx->opened = true;
             if (ctx->connector) {
                 ctx->connector->delay = 2000;  // Delay re-connect in case there is a recurring error
+                qd_failover_item_t *item = qd_connector_get_conn_info(ctx->connector);
+                if (item)
+                    item->retries = 0;
             }
         }
         break;
@@ -902,24 +918,26 @@ static bool handle(qd_server_t *qd_server, pn_event_t *e) {
 
     case PN_TRANSPORT_ERROR:
         {
-        pn_transport_t *transport = pn_event_transport(e);
-        pn_condition_t* condition = transport ? pn_transport_condition(transport) : NULL;
-        if (ctx && ctx->connector) { /* Outgoing connection */
-            const qd_server_config_t *config = &ctx->connector->config;
-            if (condition  && pn_condition_is_set(condition)) {
-                qd_log(qd_server->log_source, QD_LOG_INFO, "Connection to %s failed: %s %s", config->host_port,
-                       pn_condition_get_name(condition), pn_condition_get_description(condition));
-            } else {
-                qd_log(qd_server->log_source, QD_LOG_INFO, "Connection to %s failed", config->host_port);
-            }
-        } else if (ctx && ctx->listener) { /* Incoming connection */
-            if (condition && pn_condition_is_set(condition)) {
-                qd_log(ctx->server->log_source, QD_LOG_INFO, "Connection from %s (to %s) failed: %s %s",
-                       ctx->rhost_port, ctx->listener->config.host_port, pn_condition_get_name(condition),
-                       pn_condition_get_description(condition));
+            qd_increment_conn_index(ctx);
+
+            pn_transport_t *transport = pn_event_transport(e);
+            pn_condition_t* condition = transport ? pn_transport_condition(transport) : NULL;
+            if (ctx && ctx->connector) { /* Outgoing connection */
+                const qd_server_config_t *config = &ctx->connector->config;
+                if (condition  && pn_condition_is_set(condition)) {
+                    qd_log(qd_server->log_source, QD_LOG_INFO, "Connection to %s failed: %s %s", config->host_port,
+                           pn_condition_get_name(condition), pn_condition_get_description(condition));
+                } else {
+                    qd_log(qd_server->log_source, QD_LOG_INFO, "Connection to %s failed", config->host_port);
+                }
+            } else if (ctx && ctx->listener) { /* Incoming connection */
+                if (condition && pn_condition_is_set(condition)) {
+                    qd_log(ctx->server->log_source, QD_LOG_INFO, "Connection from %s (to %s) failed: %s %s",
+                           ctx->rhost_port, ctx->listener->config.host_port, pn_condition_get_name(condition),
+                           pn_condition_get_description(condition));
+                }
             }
         }
-        }
         break;
 
     default:
@@ -953,7 +971,7 @@ static void *thread_run(void *arg)
 }
 
 
-qd_failover_item_t *qd_connector_get_conn_info(qd_connector_t *ct) {
+static qd_failover_item_t *qd_connector_get_conn_info(qd_connector_t *ct) {
 
     qd_failover_item_t *item = DEQ_HEAD(ct->conn_info_list);
 
@@ -1368,6 +1386,7 @@ qd_connector_t *qd_server_connector(qd_server_t *server)
     qd_failover_item_list_t conn_info_list;
     DEQ_INIT(conn_info_list);
     ct->conn_info_list = conn_info_list;
+    ct->conn_index = 1;
     ct->lock = sys_mutex();
     ct->timer = qd_timer(ct->server->qd, try_open_cb, ct);
     if (!ct->lock || !ct->timer) {

http://git-wip-us.apache.org/repos/asf/qpid-dispatch/blob/e92dab3c/tests/system_tests_handle_failover.py
----------------------------------------------------------------------
diff --git a/tests/system_tests_handle_failover.py b/tests/system_tests_handle_failover.py
index f2615c2..2f6b296 100644
--- a/tests/system_tests_handle_failover.py
+++ b/tests/system_tests_handle_failover.py
@@ -34,20 +34,23 @@ class FailoverTest(TestCase):
     inter_router_port = None
 
     @classmethod
-    def setUpClass(cls):
-        super(FailoverTest, cls).setUpClass()
+    def router(cls, name, config):
+        config = Qdrouterd.Config(config)
 
-        def router(name, config):
-            config = Qdrouterd.Config(config)
+        cls.routers.append(cls.tester.qdrouterd(name, config, wait=True))
 
-            cls.routers.append(cls.tester.qdrouterd(name, config, wait=True))
+    @classmethod
+    def setUpClass(cls):
+        super(FailoverTest, cls).setUpClass()
 
         cls.routers = []
 
-        inter_router_port = cls.tester.get_port()
+        cls.inter_router_port = cls.tester.get_port()
         cls.inter_router_port_1 = cls.tester.get_port()
         cls.backup_port = cls.tester.get_port()
-        cls.failover_list = 'amqp://third-host:5671, ' + 'amqp://localhost:' + str(cls.backup_port)
+        cls.backup_url = 'amqp://0.0.0.0:' + str(cls.backup_port)
+
+        cls.failover_list = 'amqp://third-host:5671, ' + cls.backup_url
 
         #
         # Router A tries to connect to Router B via its connectorToB. Router B responds with an open frame which will
@@ -56,35 +59,36 @@ class FailoverTest(TestCase):
         # idle-time-out=8000, offered-capabilities=:"ANONYMOUS-RELAY",
         # properties={:product="qpid-dispatch-router", :version="1.0.0",
         #  :"failover-server-list"=[{:"network-host"="some-host", :port="35000"},
-        #  {:"network-host"="localhost", :port="25000"}]}]
+        #  {:"network-host"="0.0.0.0", :port="25000"}]}]
         #
         # The suite of tests determine if the router receiving this open frame stores it properly and if the
         # original connection goes down, check that the router is trying to make connections to the failover urls.
         #
-        router('QDR.B', [
-                        ('router', {'mode': 'interior', 'id': 'QDR.B'}),
-                        ('listener', {'role': 'inter-router', 'port': inter_router_port,
+        FailoverTest.router('B', [
+                        ('router', {'mode': 'interior', 'id': 'B'}),
+                        ('listener', {'host': '0.0.0.0', 'role': 'inter-router', 'port': cls.inter_router_port,
                                       'failoverUrls': cls.failover_list}),
-                        ('listener', {'role': 'normal', 'port': cls.tester.get_port()}),
+                        ('listener', {'host': '0.0.0.0', 'role': 'normal', 'port': cls.tester.get_port()}),
                         ]
               )
-        router('QDR.A',
+
+        FailoverTest.router('A',
                     [
-                        ('router', {'mode': 'interior', 'id': 'QDR.A'}),
-                        ('listener', {'role': 'normal', 'port': cls.tester.get_port()}),
+                        ('router', {'mode': 'interior', 'id': 'A'}),
+                        ('listener', {'host': '0.0.0.0', 'role': 'normal', 'port': cls.tester.get_port()}),
                         ('connector', {'name': 'connectorToB', 'role': 'inter-router',
-                                       'port': inter_router_port, 'verifyHostname': 'no'}),
+                                       'port': cls.inter_router_port, 'verifyHostname': 'no'}),
                     ]
                )
 
-        router('QDR.C', [
-                            ('router', {'mode': 'interior', 'id': 'QDR.C'}),
-                            ('listener', {'role': 'inter-router', 'port': cls.backup_port}),
-                            ('listener', {'role': 'normal', 'port': cls.tester.get_port()}),
+        FailoverTest.router('C', [
+                            ('router', {'mode': 'interior', 'id': 'C'}),
+                            ('listener', {'host': '0.0.0.0', 'role': 'inter-router', 'port': cls.backup_port}),
+                            ('listener', {'host': '0.0.0.0', 'role': 'normal', 'port': cls.tester.get_port()}),
                         ]
               )
 
-        cls.routers[1].wait_router_connected('QDR.B')
+        cls.routers[1].wait_router_connected('B')
 
     def __init__(self, test_method):
         TestCase.__init__(self, test_method)
@@ -120,7 +124,7 @@ class FailoverTest(TestCase):
         if regexp: assert re.search(regexp, out, re.I), "Can't find '%s' in '%s'" % (regexp, out)
         return out
 
-    def test_connector_has_failover_list(self):
+    def test_1_connector_has_failover_list(self):
         """
         Makes a qdmanage connector query and checks if Router A is storing the failover information received from
         Router B.
@@ -129,25 +133,29 @@ class FailoverTest(TestCase):
         long_type = 'org.apache.qpid.dispatch.connector'
         query_command = 'QUERY --type=' + long_type
         output = json.loads(self.run_qdmanage(query_command))
-        self.assertIn(FailoverTest.failover_list, output[0]['failoverUrls'])
+        self.assertEqual("amqp://127.0.0.1:" + str(FailoverTest.inter_router_port) + ", " + FailoverTest.failover_list,
+                         output[0]['failoverUrls'])
 
-    def schedule_failover_test(self):
+    def schedule_B_to_C_failover_test(self):
         if self.attempts < self.max_attempts:
             if not self.success:
-                Timer(self.timer_delay, self.check_connector).start()
+                Timer(self.timer_delay, self.check_C_connector).start()
                 self.attempts += 1
 
-    def check_connector(self):
+    def check_C_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:
+
+        expected = FailoverTest.backup_url  + ", " + "amqp://127.0.0.1:" + str(FailoverTest.inter_router_port)
+
+        if output[0].get('failoverUrls') == expected:
             self.success = True
         else:
-            self.schedule_failover_test()
+            self.schedule_B_to_C_failover_test()
 
     def can_terminate(self):
         if self.attempts == self.max_attempts:
@@ -158,7 +166,7 @@ class FailoverTest(TestCase):
 
         return False
 
-    def test_remove_router_B(self):
+    def test_2_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])
 
@@ -168,8 +176,8 @@ class FailoverTest(TestCase):
         # Kill the router B
         FailoverTest.routers[0].teardown()
 
-        # Schedule a test to make sure that the failover url is empty
-        self.schedule_failover_test()
+        # Schedule a test to make sure that the failover url is available
+        self.schedule_B_to_C_failover_test()
 
         while not self.can_terminate():
             pass
@@ -178,8 +186,54 @@ class FailoverTest(TestCase):
 
         # 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.
-        self.run_qdstat(['--connections'], regexp=r'QDR.A.*inter-router.*', address=self.routers[2].addresses[1])
+        self.run_qdstat(['--connections'], regexp=r'A.*inter-router.*', address=self.routers[2].addresses[1])
+
+    def schedule_C_to_B_failover_test(self):
+        if self.attempts < self.max_attempts:
+            if not self.success:
+                Timer(self.timer_delay, self.check_B_connector).start()
+                self.attempts += 1
+
+    def check_B_connector(self):
+        # Router A should now try to connect to Router B again since we killed Router C.
+        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]))
+
+        expected = "amqp://127.0.0.1:" + str(FailoverTest.inter_router_port) + ", " + FailoverTest.failover_list
+
+        if output[0].get('failoverUrls') == expected:
+            self.success = True
+        else:
+            self.schedule_C_to_B_failover_test()
+
+    def test_3_reinstate_router_B(self):
+        FailoverTest.router('B', [
+                        ('router', {'mode': 'interior', 'id': 'B'}),
+                        ('listener', {'host': '0.0.0.0', 'role': 'inter-router', 'port': FailoverTest.inter_router_port,
+                                      'failoverUrls': FailoverTest.failover_list}),
+                        ('listener', {'host': '0.0.0.0', 'role': 'normal', 'port': FailoverTest.tester.get_port()}),
+                        ]
+              )
+
+        FailoverTest.routers[3].wait_ready()
+
+        # Kill the router C.
+        # Now since Router B is up and running, router A should try to re-connect to Router B.
+        # This will prove that the router A is preserving the original connector information specified in its config.
+        FailoverTest.routers[2].teardown()
+
+        self.success = False
+        self.attempts = 0
+
+        # Schedule a test to make sure that the failover url is available
+        self.schedule_C_to_B_failover_test()
+
+        while not self.can_terminate():
+            pass
+
+        self.assertTrue(self.success)
 
 
 if __name__ == '__main__':
-    unittest.main(main_module())
+    unittest.main(main_module())
\ No newline at end of file


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