Bug 694392

Summary: printing failed cleanup phase ends with traceback
Product: [Fedora] Fedora Reporter: Jan Hutař <jhutar>
Component: beakerlibAssignee: Petr Muller <pmuller>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: unspecified    
Version: 14CC: jpazdziora, ohudlick, pmuller, psplicha
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: Patch
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-04-07 10:38:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 545868    

Description Jan Hutař 2011-04-07 08:11:10 UTC
Description of problem:
Recently, we have started to get tracebacks when reporting failed cleanup phase. It is caused by an attempt to report result 'WARN' instead of 'WARNING'.

It is not clear which one is the correct one (see docs for rlReport, but see what code in Python functions printLog and getAllowedSeverities expects).


Version-Release number of selected component (if applicable):
beakerlib-1.3-4.el5


How reproducible:
always


Steps to Reproduce:
1. report failed cleanup phase


Actual results:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Cleanup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   FAIL   ] :: Running 'blablabla' (Expected 0, got 1)
:: [   LOG    ] :: Duration: 0s
:: [   LOG    ] :: Assertions: 0 good, 1 bad
Traceback (most recent call last):
  File "/usr/bin/beakerlib-journalling", line 468, in ?
    createLog(options.testid, options.severity)
  File "/usr/bin/beakerlib-journalling", line 181, in createLog
    printPhaseLog(nod,severity)
  File "/usr/bin/beakerlib-journalling", line 123, in printPhaseLog
    printLog("RESULT: %s" % phaseName, phaseResult)
  File "/usr/bin/beakerlib-journalling", line 70, in printLog
    color = termColors[prefix]
KeyError: u'WARN'


Expected results:
Should work


Additional info:
Relevant piece of journal.xml have:

<phase endtime="2011-04-07 03:38:46 EDT" name="Cleanup" result="WARN" score="1" starttime="2011-04-07 03:38:46 EDT" type="WARN"><test message="Running 'blablabla' (Expected 0, got 1)">FAIL</test></phase>


To fix traceback and avoid future similar occurrences, this might be a patch:

--- /usr/bin/beakerlib-journalling.ORIG	2011-04-07 03:37:44.000000000 -0400
+++ /usr/bin/beakerlib-journalling	2011-04-07 03:38:19.000000000 -0400
@@ -66,7 +66,7 @@
 
 def printLog(message, prefix="LOG"):
   color = uncolor = ""
-  if sys.stdout.isatty() and prefix in "PASS FAIL INFO WARNING":
+  if sys.stdout.isatty() and prefix in ("PASS", "FAIL", "INFO", "WARNING"):
     color = termColors[prefix]
     uncolor = "\033[0m"
   for line in message.split("\n"):

Comment 1 Jan Pazdziora 2011-04-07 08:32:41 UTC
Wouldn't it be better to just add the 'WARN' color to that 

termColors = {
  "PASS": "\033[0;32m",
  "FAIL": "\033[0;31m",
  "INFO": "\033[0;34m",
  "WARNING": "\033[0;33m" }

hash?

Comment 2 Petr Muller 2011-04-07 10:38:54 UTC

*** This bug has been marked as a duplicate of bug 692819 ***