From 8c174d9c46d58551c9817f6c6546207a875f351d Mon Sep 17 00:00:00 2001 From: Siegfried Neumann Date: Tue, 12 Jul 2022 06:52:51 -0700 Subject: [PATCH 1/5] do logging on test level --- nose_reportportal/plugin.py | 8 ++++---- nose_reportportal/service.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/nose_reportportal/plugin.py b/nose_reportportal/plugin.py index dd41db7..d60c3e5 100644 --- a/nose_reportportal/plugin.py +++ b/nose_reportportal/plugin.py @@ -404,21 +404,21 @@ def stopTest(self, test): if test.capturedOutput: try: - self.service.post_log(safe_str(test.capturedOutput)) + self.service.post_log(safe_str(test.capturedOutput),test_item=test.test_item) except Exception: log.exception('Unexpected error during sending capturedOutput.') if test.capturedLogging: for x in test.capturedLogging: try: - self.service.post_log(safe_str(x)) + self.service.post_log(safe_str(x), test_item=test.test_item) except Exception: log.exception('Unexpected error during sending capturedLogging.') if test.errors: try: - self.service.post_log(safe_str(test.errors[0])) - self.service.post_log(safe_str(test.errors[1]), loglevel="ERROR") + self.service.post_log(safe_str(test.errors[0]),test_item=test.test_item) + self.service.post_log(safe_str(test.errors[1]), loglevel="ERROR", test_item=test.test_item) except Exception: log.exception('Unexpected error during sending errors.') diff --git a/nose_reportportal/service.py b/nose_reportportal/service.py index a131af7..e5c2855 100644 --- a/nose_reportportal/service.py +++ b/nose_reportportal/service.py @@ -122,7 +122,7 @@ def finish_nose_item(self, test_item, status, issue=None): if self.rp is None: return - self.post_log(status) + self.post_log(status, test_item=test_item) fta_rq = { 'item_id': test_item, 'end_time': timestamp(), @@ -148,7 +148,7 @@ def terminate_service(self, nowait=False): self.rp.terminate(nowait) self.rp = None - def post_log(self, message, loglevel='INFO', attachment=None): + def post_log(self, message, loglevel='INFO', attachment=None, test_item=None): if self.rp is None: return @@ -162,6 +162,7 @@ def post_log(self, message, loglevel='INFO', attachment=None): 'message': message, 'level': loglevel, 'attachment': attachment, + 'item_id': test_item } self.rp.log(**sl_rq) From c375cab50f9cd62758ff37927a2f80e3601186a7 Mon Sep 17 00:00:00 2001 From: Siegfried Neumann Date: Thu, 14 Jul 2022 02:39:47 -0700 Subject: [PATCH 2/5] add option --- nose_reportportal/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nose_reportportal/plugin.py b/nose_reportportal/plugin.py index d60c3e5..886b3a7 100644 --- a/nose_reportportal/plugin.py +++ b/nose_reportportal/plugin.py @@ -95,6 +95,12 @@ def options(self, parser, env): dest='rp_launch_description', help='description of a launch') + parser.add_option('--rp-launch-tags', + action='store', + default="", + dest='rp_launch_tags', + help='description of a launch') + parser.add_option('--ignore-loggers', action='store', default=[], From 35c7bb4b852016989de6ccab534a075d39798ebd Mon Sep 17 00:00:00 2001 From: Siegfried Neumann Date: Thu, 14 Jul 2022 04:58:52 -0700 Subject: [PATCH 3/5] correct mistake --- nose_reportportal/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nose_reportportal/plugin.py b/nose_reportportal/plugin.py index 886b3a7..c9d2a34 100644 --- a/nose_reportportal/plugin.py +++ b/nose_reportportal/plugin.py @@ -155,8 +155,8 @@ def configure(self, options, conf): self.rp_endpoint = config.get("base", "rp_endpoint") os.environ["RP_ENDPOINT"] = self.rp_endpoint self.rp_project = config.get("base", "rp_project") - self.rp_launch = config.get("base", "rp_launch").format(slaunch) - self.rp_launch_tags = config.get("base", "rp_launch_tags") + self.rp_launch = options.rp_launch or config.get("base", "rp_launch").format(slaunch) + self.rp_launch_tags = options.rp_launch_tags or config.get("base", "rp_launch_tags") self.rp_launch_description = options.rp_launch_description or config.get("base", "rp_launch_description") def setupLoghandler(self): From 92c54aa9d4cbcc95e33d5ce3f128774c7da43f0c Mon Sep 17 00:00:00 2001 From: Sigi Neumann Date: Mon, 5 Sep 2022 15:46:12 +0200 Subject: [PATCH 4/5] Enable Logcapture --- nose_reportportal/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nose_reportportal/plugin.py b/nose_reportportal/plugin.py index c9d2a34..5af92e4 100644 --- a/nose_reportportal/plugin.py +++ b/nose_reportportal/plugin.py @@ -37,8 +37,8 @@ log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) -# Disabled because we've already had a overloaded capturing of the logs -LogCapture.enabled = False +# TODO maybe make this configurable +LogCapture.enabled = True class RPNoseLogHandler(MyMemoryHandler): From 5f3ddf5496d05041563e0e828a9a2361af35ba9f Mon Sep 17 00:00:00 2001 From: Sigi Neumann Date: Thu, 8 Sep 2022 14:09:45 +0200 Subject: [PATCH 5/5] don't clear loggers other people are using them... --- nose_reportportal/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nose_reportportal/plugin.py b/nose_reportportal/plugin.py index 5af92e4..9949d17 100644 --- a/nose_reportportal/plugin.py +++ b/nose_reportportal/plugin.py @@ -149,7 +149,7 @@ def configure(self, options, conf): if options.ignore_loggers and isinstance(options.ignore_loggers, basestring): self.filters = [x.strip() for x in options.ignore_loggers.split(",")] - self.clear = True + self.clear = False if "base" in config.sections(): self.rp_uuid = config.get("base", "rp_uuid") self.rp_endpoint = config.get("base", "rp_endpoint")