You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by GitBox <gi...@apache.org> on 2021/12/16 20:26:19 UTC

[GitHub] [qpid-dispatch] kgiusti commented on a change in pull request #1463: DISPATCH-2300: Fixed test to not look for contents of transfer messag…

kgiusti commented on a change in pull request #1463:
URL: https://github.com/apache/qpid-dispatch/pull/1463#discussion_r770897086



##########
File path: tests/system_tests_log_level_update.py
##########
@@ -256,56 +256,72 @@ def router(name, connection):
 
     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
         for result in results:
             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)
 
-        # Create a receiver and make sure the MAU update is seen on the inter-router connection log
+        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) > 2 and 'PROTOCOL' in log_components[3]:
+                    if inter_router_cid in log_components[5] and '@transfer' in log_components[8]:
+                        num_transfers += 1
+
+        # 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
-
-        self.assertTrue(mau_found)
+        num_transfers_after_update = 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) > 2 and 'PROTOCOL' in log_components[3]:
+                    if inter_router_cid in log_components[5] and '@transfer' in log_components[8]:
+                        num_transfers_after_update += 1
+
+        # 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 = 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) > 2 and 'PROTOCOL' in log_components[3]:

Review comment:
       and here as well (maybe make the count code a private method to this test so you don't have to copy & pasta it multiple times).

##########
File path: tests/system_tests_log_level_update.py
##########
@@ -256,56 +256,72 @@ def router(name, connection):
 
     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
         for result in results:
             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)
 
-        # Create a receiver and make sure the MAU update is seen on the inter-router connection log
+        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) > 2 and 'PROTOCOL' in log_components[3]:
+                    if inter_router_cid in log_components[5] and '@transfer' in log_components[8]:
+                        num_transfers += 1
+
+        # 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
-
-        self.assertTrue(mau_found)
+        num_transfers_after_update = 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) > 2 and 'PROTOCOL' in log_components[3]:

Review comment:
       ditto len(log_components) here as well.

##########
File path: tests/system_tests_log_level_update.py
##########
@@ -256,56 +256,72 @@ def router(name, connection):
 
     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
         for result in results:
             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)
 
-        # Create a receiver and make sure the MAU update is seen on the inter-router connection log
+        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) > 2 and 'PROTOCOL' in log_components[3]:

Review comment:
       I think you meant to check len(log_components) > 8, so indexing log_components[8] won't barf?  or at minimum > 3 if you're willing to trust the format of the PROTOCOL log statement.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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