This is an automated email from the ASF dual-hosted git repository.
gmurthy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/qpid-dispatch.git
The following commit(s) were added to refs/heads/master by this push:
new ae448db DISPATCH-1561: Added a test that makes sure that different
modules can write to different log files. This closes #691.
ae448db is described below
commit ae448db17367d21564aad0360cda5e9fb901c35d
Author: Ganesh Murthy <[email protected]>
AuthorDate: Wed Feb 19 13:08:54 2020 -0500
DISPATCH-1561: Added a test that makes sure that different modules can
write to different log files. This closes #691.
---
tests/system_tests_log_level_update.py | 98 +++++++++++++++++++++++++++++++++-
1 file changed, 97 insertions(+), 1 deletion(-)
diff --git a/tests/system_tests_log_level_update.py
b/tests/system_tests_log_level_update.py
index 17609ef..16136ed 100644
--- a/tests/system_tests_log_level_update.py
+++ b/tests/system_tests_log_level_update.py
@@ -29,6 +29,102 @@ import time
apply_options = AtMostOnce()
+class ManyLogFilesTest(TestCase):
+ @classmethod
+ def setUpClass(cls):
+ super(ManyLogFilesTest, cls).setUpClass()
+ name = "test-router"
+ LogLevelUpdateTest.listen_port = cls.tester.get_port()
+ config = Qdrouterd.Config([
+ ('router', {'mode': 'standalone', 'id': 'QDR'}),
+ ('listener', {'port': LogLevelUpdateTest.listen_port}),
+
+ ('address', {'prefix': 'closest', 'distribution': 'closest'}),
+ ('address', {'prefix': 'balanced', 'distribution': 'balanced'}),
+ ('address', {'prefix': 'multicast', 'distribution': 'multicast'}),
+
+ # We are sending three different module trace logs to three
different
+ # files and we will make sure that these files exist and these
+ # files contain only logs pertinent to the module in question
+ ('log', {'module': 'SERVER', 'enable': 'trace+',
+ 'includeSource': 'true', 'outputFile': name +
'-server.log'}),
+ ('log', {'module': 'ROUTER_CORE', 'enable': 'trace+',
+ 'includeSource': 'true',
+ 'outputFile': name + '-core.log'}),
+ ('log', {'module': 'PROTOCOL', 'enable': 'trace+',
+ 'includeSource': 'true',
+ 'outputFile': name + '-protocol.log'}),
+
+ # try two modules to the same file.
+ # Put the ROUTER_CORE and ROUTER module logs into the same log file
+ ('log', {'module': 'ROUTER', 'enable': 'trace+',
+ 'includeSource': 'true',
+ 'outputFile': name + '-core.log'}),
+
+ ])
+ cls.router = cls.tester.qdrouterd(name, config)
+ cls.router.wait_ready()
+ cls.address = cls.router.addresses[0]
+
+ def test_multiple_log_file(self):
+ blocking_connection = BlockingConnection(self.address)
+
+ TEST_ADDRESS = "test_multiple_log_file"
+
+ blocking_receiver =
blocking_connection.create_receiver(address=TEST_ADDRESS)
+ blocking_sender =
blocking_connection.create_sender(address=TEST_ADDRESS, options=apply_options)
+
+ TEST_MSG = "LOGTEST"
+ msg = Message(body=TEST_MSG)
+ blocking_sender.send(msg)
+ received_message = blocking_receiver.receive()
+ self.assertEqual(TEST_MSG, received_message.body)
+ server_log_found = True
+ all_server_logs = True
+ try:
+ with open(self.router.outdir + '/test-router-server.log', 'r') as
server_log:
+ for line in server_log:
+ parts = line.split(" ")
+ if (parts[3] != "SERVER"):
+ all_server_logs = False
+ break;
+ except:
+ server_log_found = False
+
+ self.assertTrue(all_server_logs)
+ self.assertTrue(server_log_found)
+
+ protocol_log_found = True
+ all_protocol_logs =True
+ try:
+ with open(self.router.outdir + '/test-router-protocol.log', 'r')
as protocol_log:
+ for line in protocol_log:
+ parts = line.split(" ")
+ if (parts[3] != "PROTOCOL"):
+ all_protocol_logs = False
+ break;
+ except:
+ protocol_log_found = False
+
+ self.assertTrue(protocol_log_found)
+ self.assertTrue(all_protocol_logs)
+
+ core_router_log_found = True
+ all_core_router_logs = True
+ try:
+ with open(self.router.outdir + '/test-router-core.log', 'r') as
core_log:
+ for line in core_log:
+ parts = line.split(" ")
+ if parts[3] != "ROUTER_CORE" and parts[3] != "ROUTER":
+ all_core_router_logs = False
+ break;
+
+ except:
+ core_router_log_found = False
+
+ self.assertTrue(core_router_log_found)
+ self.assertTrue(all_core_router_logs)
+
class LogModuleProtocolTest(TestCase):
@classmethod
@@ -535,7 +631,7 @@ class RouterCoreModuleLogTest(TestCase):
# Before the fix to DISPATCH-1575, this file will not be
# created because the router core module was logging to the ROUTER
# module instead of the ROUTER_CORE module.
- with open('../setUpClass/test-router-core.log', 'r') as core_log:
+ with open(self.router.outdir + '/test-router-core.log', 'r') as
core_log:
for line in core_log:
# Every line in the file must log to the router core
module.
if not "ROUTER_CORE" in line:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]