[PATCH 4/3] upgradepath: improve output text and set summary correctly

Kamil Páral kparal at redhat.com
Tue Sep 14 12:31:20 UTC 2010


This patch improves text output - it now mentions to which repository we
want to push our package, and also mentions which condition failed after
a FAIL status line. It also improves self.summary. And uses tabs instead
of space, ahem.
---
 tests/upgradepath/upgradepath.py |   39 ++++++++++++++++++-------------------
 1 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/tests/upgradepath/upgradepath.py b/tests/upgradepath/upgradepath.py
index dfbbb81..1811aba 100755
--- a/tests/upgradepath/upgradepath.py
+++ b/tests/upgradepath/upgradepath.py
@@ -47,7 +47,7 @@ class upgradepath(AutoQATest):
     def setup(self):
         pass
 
-    def compare(self, matching_build, tags, op):
+    def compare(self, matching_build, tags, op, opstr):
         koji = autoqa.koji_utils.SimpleKojiClientSession()
         for tag in tags:
             latest_build = koji.latest_by_tag(tag, matching_build['name'])
@@ -56,28 +56,36 @@ class upgradepath(AutoQATest):
                 self.log.append(msg)
                 print msg
 
-                msg = "           Package %s in %s doesn't exist" % (matching_build['name'], tag)
+                msg = "\tNo such package: %s" % matching_build['name']
                 self.log.append(msg)
                 print msg
             else:
                 result = autoqa.koji_utils.compareEVR(matching_build, latest_build)
 
                 if op(result, 0):
+                    ok = True
                     msg ='{0:<7}{1}'.format('[ OK ]', tag)
                     print msg
                     self.log.append(msg)
                 else:
+                    ok = False
                     self.test_result = 'FAIL'
                     msg ='{0:<7}{1}'.format('[FAIL]', tag)
                     print msg
                     self.log.append(msg)
                     self.envr_list.add(matching_build['envr'])
-                msg = "           Pushing package: %s\n           Latest package:  %s" % (matching_build['envr'], latest_build['nvr'])
+                msg = "\tLatest package: %s" % latest_build['nvr']
                 self.log.append(msg)
                 print msg
+                if not ok:
+                    msg = '\tFailed condition: Requested package %s Latest package' % opstr
+                    self.log.append(msg)
+                    print msg
 
     @ExceptionCatcher("self.run_once_failed")
-    def run_once(self, envrs, name, kojitag, **kwargs):
+    def run_once(self, envrs, kojitag, **kwargs):
+        update_id = kwargs['name'] or kwargs['id']
+
         reponames = [reponame for reponame in autoqa.koji_utils.repoinfo.repos() if not reponame.endswith('-testing')]
         repotags = [autoqa.koji_utils.repoinfo.getrepo(reponame)['tag'] for reponame in reponames]
         repotags.sort()
@@ -88,11 +96,9 @@ class upgradepath(AutoQATest):
         low_eq_tags = repotags[:(current_tag + 1)] # tags lower or equal
 
         for envr in envrs:
-            msg = 40*'=' + '\n' + envr + '\n' + 40*'='
+            msg = '%s\n%s into %s\n%s' % (40*'=', envr, kojitag, 40*'=')
+            print msg
             self.log.append(msg)
-            print 40*'='
-            print envr
-            print 40*'='
 
             # our testing package
             (name, version, release, epoch, arch) = rpmUtils.miscutils.splitFilename(envr)
@@ -113,15 +119,15 @@ class upgradepath(AutoQATest):
             latest_build = koji.latest_by_tag(kojitag, matching_build['name'])
             if latest_build is not None:
                 result = autoqa.koji_utils.compareEVR(matching_build, latest_build)
-                if result != 1:
-                    msg = "Warning: Pushing older or current version of package"
+                if result <= 0:
+                    msg = "Warning: Same or newer build already exists: %s" % latest_build['nvr']
                     self.log.append(msg)
                     print msg
 
             # compare with lower or equal tags, so version has to be greater or equal
-            self.compare(matching_build, low_eq_tags, operator.ge)
+            self.compare(matching_build, low_eq_tags, operator.ge, '>=')
             # compare with higher tags, so version has to be lower or equal
-            self.compare(matching_build, hi_tags, operator.le)
+            self.compare(matching_build, hi_tags, operator.le, '<=')
 
         summary = str(len(envrs) - len(self.envr_list)) + ' OK, ' + str(len(self.envr_list)) + ' FAILED'
         msg = 'SUMMARY: ' + summary
@@ -132,13 +138,6 @@ class upgradepath(AutoQATest):
         self.outputs = ""
         for i in self.log:
             self.outputs += i + '\n'
-
         self.outputs += '\n \n'
-
-        packages_fail = ""
-        for i in self.envr_list:
-            packages_fail += i + ', '
-        packages_fail = packages_fail[:-2]
-
-        self.summary = packages_fail
+        self.summary = '%s for %s' % (summary, update_id)
 
-- 
1.7.2.2



More information about the autoqa-devel mailing list