Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions nose_reportportal/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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=[],
Expand Down Expand Up @@ -143,14 +149,14 @@ 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")
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):
Expand Down Expand Up @@ -404,21 +410,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.')

Expand Down
5 changes: 3 additions & 2 deletions nose_reportportal/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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

Expand All @@ -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)

Expand Down