This is an automated email from the ASF dual-hosted git repository.

gmurthy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git


The following commit(s) were added to refs/heads/main by this push:
     new 2af1a67  DISPATCH-2300: Fixed test to not look for contents of 
transfer message. Also a minor fix to the connection creation code
2af1a67 is described below

commit 2af1a676b86cfaf0880cfbfc8b72305758f75d75
Author: Ganesh Murthy <[email protected]>
AuthorDate: Thu Dec 16 10:15:33 2021 -0500

    DISPATCH-2300: Fixed test to not look for contents of transfer message. 
Also a minor fix to the connection creation code
---
 src/router_core/connections.c          |  5 ++-
 src/router_core/router_core_private.h  |  1 +
 tests/system_tests_log_level_update.py | 64 +++++++++++++++++++---------------
 3 files changed, 40 insertions(+), 30 deletions(-)

diff --git a/src/router_core/connections.c b/src/router_core/connections.c
index 08acb51..9d657a2 100644
--- a/src/router_core/connections.c
+++ b/src/router_core/connections.c
@@ -125,6 +125,9 @@ qdr_connection_t *qdr_connection_opened(qdr_core_t          
         *core,
     set_safe_ptr_qdr_connection_t(conn, &action->args.connection.conn);
     action->args.connection.connection_label = qdr_field(label);
     action->args.connection.container_id     = qdr_field(remote_container_id);
+    if (qd_log_enabled(qd_log_source("PROTOCOL"), QD_LOG_TRACE)) {
+        action->args.connection.enable_protocol_trace = true;
+    }
     qdr_action_enqueue(core, action);
 
     char   props_str[1000];
@@ -237,7 +240,6 @@ void *qdr_connection_get_context(const qdr_connection_t 
*conn)
     return conn ? conn->user_context : NULL;
 }
 
-
 const char *qdr_connection_get_tenant_space(const qdr_connection_t *conn, int 
*len)
 {
     *len = conn ? conn->tenant_space_len : 0;
@@ -1408,6 +1410,7 @@ static void qdr_connection_opened_CT(qdr_core_t *core, 
qdr_action_t *action, boo
 
     do {
         DEQ_ITEM_INIT(conn);
+        conn->enable_protocol_trace = 
action->args.connection.enable_protocol_trace;
         DEQ_INSERT_TAIL(core->open_connections, conn);
 
         if (conn->role == QDR_ROLE_NORMAL) {
diff --git a/src/router_core/router_core_private.h 
b/src/router_core/router_core_private.h
index 97dd266..6a0f4ba 100644
--- a/src/router_core/router_core_private.h
+++ b/src/router_core/router_core_private.h
@@ -137,6 +137,7 @@ struct qdr_action_t {
             qd_detach_type_t     dt;
             int                  credit;
             bool                 drain;
+            bool                 enable_protocol_trace;
             qdr_delivery_t      *initial_delivery;
         } connection;
 
diff --git a/tests/system_tests_log_level_update.py 
b/tests/system_tests_log_level_update.py
index fa91c30..5e6bfa2 100644
--- a/tests/system_tests_log_level_update.py
+++ b/tests/system_tests_log_level_update.py
@@ -254,12 +254,21 @@ class EnableConnectionLevelInterRouterTraceTest(TestCase):
 
         cls.address = cls.routers[1].addresses[0]
 
+    def _get_transfer_frame_count(self, conn_id):
+        inter_router_cid = "[C" + conn_id + "]"
+        num_transfers = 0
+        with open(self.routers[1].logfile_path) as router_log:
+            for log_line in router_log:
+                log_components = log_line.split(" ")
+                if len(log_components) > 8 and 'PROTOCOL' in log_components[3]:
+                    if inter_router_cid in log_components[5] and '@transfer' 
in log_components[8]:
+                        num_transfers += 1
+        return num_transfers
+
     def test_inter_router_protocol_trace(self):
         qd_manager = QdManager(self, self.address)
-        # Turn off trace logging on all connections for Router B.
-        qd_manager.update("org.apache.qpid.dispatch.log", {"enable": "info+"},
-                          name="log/DEFAULT")
 
+        # The router already has trace logging turned on for all connections.
         # Get the connection id of the inter-router connection
         results = qd_manager.query("org.apache.qpid.dispatch.connection")
         conn_id = None
@@ -267,45 +276,42 @@ class EnableConnectionLevelInterRouterTraceTest(TestCase):
             if result['role'] == 'inter-router':
                 conn_id = result['identity']
 
-        # Turn on trace logging for the inter-router connection
-        qd_manager.update("org.apache.qpid.dispatch.connection", 
{"enableProtocolTrace": "true"}, identity=conn_id)
+        # Turn off trace logging for the inter-router connection. This update 
command is run async by the router
+        # so we need to sleep a bit before the operation is actually completed.
+        qd_manager.update("org.apache.qpid.dispatch.connection", 
{"enableProtocolTrace": "false"}, identity=conn_id)
+        time.sleep(1)
+
+        num_transfers = self._get_transfer_frame_count(conn_id)
 
-        # Create a receiver and make sure the MAU update is seen on the 
inter-router connection log
+        # Create a receiver. This will send an MAU update to the other router 
but we should not see any of that
+        # in the log since the trace logging for the inter-router connection 
has been turned off.
         TEST_ADDR_1 = "EnableConnectionLevelProtocolTraceTest1"
         conn_2 = BlockingConnection(self.address)
-        blocking_receiver_1 = conn_2.create_receiver(address=TEST_ADDR_1)
-
-        # Give some time for the MAU to go over the inter-router link
+        conn_2.create_receiver(address=TEST_ADDR_1)
+        # Give some time for the MAU to go over the inter-router connection.
         time.sleep(2)
-        logs = qd_manager.get_log()
-        mau_found = False
-        for log in logs:
-            if 'PROTOCOL' in log[0]:
-                if "@transfer" in log[2] and TEST_ADDR_1 in log[2] and "MAU" 
in log[2]:
-                    mau_found = True
-                    break
+        num_transfers_after_update = self._get_transfer_frame_count(conn_id)
 
-        self.assertTrue(mau_found)
+        # Since there will be no transfer frames printed in the log, there 
should be no more new transfers in the
+        # log file.
+        self.assertEqual(num_transfers_after_update, num_transfers)
 
-        # Turn off trace logging for the inter-router connection
-        qd_manager.update("org.apache.qpid.dispatch.connection", 
{"enableProtocolTrace": "no"}, identity=conn_id)
+        # Turn on trace logging for the inter-router connection
+        qd_manager.update("org.apache.qpid.dispatch.connection", 
{"enableProtocolTrace": "yes"}, identity=conn_id)
 
         # Create a receiver and make sure the MAU update is NOT seen on the 
inter-router connection log
         TEST_ADDR_2 = "EnableConnectionLevelProtocolTraceTest2"
         conn_1 = BlockingConnection(self.address)
-        blocking_receiver_2 = conn_1.create_receiver(address=TEST_ADDR_2)
+        conn_1.create_receiver(address=TEST_ADDR_2)
 
-        time.sleep(1)
+        # Give time for the MAU to be generated.
+        time.sleep(2)
 
-        logs = qd_manager.get_log()
-        mau_found = False
-        for log in logs:
-            if 'PROTOCOL' in log[0]:
-                if "@transfer" in log[2] and TEST_ADDR_2 in log[2] and "MAU" 
in log[2]:
-                    mau_found = True
-                    break
+        num_transfers_after_update = self._get_transfer_frame_count(conn_id)
 
-        self.assertFalse(mau_found)
+        # Since we have now turned on trace logging for the inter-router 
connection, we should see
+        # additional transfer frames in the log and we check that here.
+        self.assertGreater(num_transfers_after_update, num_transfers)
         conn_1.close()
         conn_2.close()
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to