Hello,
I created new test for AutoQA named 'upgradepath'.
It will check if package which you want to push into repository has
correct version. Also there will be warning if you're pushing into
stable repo or pushing older or the same version of package. Requests
for comments :-).
---
diff --git a/tests/upgradepath/control b/tests/upgradepath/control
new file mode 100644
index 0000000..997c81e
--- /dev/null
+++ b/tests/upgradepath/control
@@ -0,0 +1,14 @@
+# vim: set syntax=python
+# Notice: Most recent documentation is available at doc/control.template.
+TIME="SHORT"
+AUTHOR = "Vojtech Aschenbrenner <vaschenb(a)redhat.com>"
+DOC = """
+This test runs upgradepath to catch problems with package versions
+in repositories.
+"""
+NAME = 'upgradepath'
+TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need multiple machines
+TEST_CLASS = 'General'
+TEST_CATEGORY = 'Functional'
+
+job.run_test('upgradepath', config=autoqa_conf, **autoqa_args)
diff --git a/tests/upgradepath/control.autoqa b/tests/upgradepath/control.autoqa
new file mode 100644
index 0000000..6b2ea92
--- /dev/null
+++ b/tests/upgradepath/control.autoqa
@@ -0,0 +1,9 @@
+# vim: set syntax=python
+# Notice: Most recent documentation is available at doc/control.autoqa.template.
+
+# upgradepath can be run just once and on any architecture
+archs = ['noarch']
+
+# do not run automaticaly
+execute = False
+
diff --git a/tests/upgradepath/upgradepath.py b/tests/upgradepath/upgradepath.py
new file mode 100755
index 0000000..8c4547e
--- /dev/null
+++ b/tests/upgradepath/upgradepath.py
@@ -0,0 +1,147 @@
+#!/usr/bin/python
+#
+# Copyright 2010, Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Author: Vojtech Aschenbrenner <vaschenb(a)redhat.com>
+
+import os
+import sys
+import operator
+import autoqa.koji_utils
+import autoqa.util
+import rpmUtils.miscutils
+
+from autoqa.test import AutoQATest
+from autoqa.decorators import ExceptionCatcher
+from autotest_lib.client.bin.test_config import config_loader
+from autotest_lib.client.common_lib import error
+
+
+class upgradepath(AutoQATest):
+ version = 1 # increment if setup() changes
+ test_result = 'PASS'
+ log = []
+ envr_list = set()
+
+ def initialize(self, config):
+ self.config = config_loader(config, self.tmpdir)
+ #URL of logs/results stored on autotest-server
+ self.autotest_url = autoqa.util.make_autotest_url(self.config)
+
+ def setup(self):
+ pass
+
+ def compare(self, matching_build, tags, op):
+ koji = autoqa.koji_utils.SimpleKojiClientSession()
+ for tag in tags:
+ latest_build = koji.latest_by_tag(tag, matching_build['name'])
+ if latest_build is None:
+ msg = tag + '... OK'
+ self.log.append(msg)
+ print msg
+
+ msg = "-> Package %s in %s doesn't exist" %
(matching_build['name'], tag)
+ self.log.append(msg)
+ print msg
+ else:
+ result = autoqa.koji_utils.compareEVR(matching_build, latest_build)
+
+ if op(result, 0):
+ msg = tag + '... OK'
+ print msg
+ self.log.append(msg)
+ else:
+ self.test_result = 'FAIL'
+ msg = tag + '... FAIL'
+ 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'])
+ self.log.append(msg)
+ print msg
+
+ @ExceptionCatcher("self.run_once_failed")
+ def run_once(self, envrs, name, kojitag, **kwargs):
+ 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()
+ try:
+ current_tag = repotags.index(kojitag)
+ except ValueError:
+ self.test_result = 'FAIL'
+ msg = "ERROR: Entered bad kojitag"
+ print msg
+ self.log.append(msg)
+ self.envr_list.add(matching_build['envr'])
+ raise error.TestFail
+
+ hi_tags = repotags[(current_tag + 1):] # tags higher than current
+ low_eq_tags = repotags[:(current_tag + 1)] # tags lower or equal
+
+ for envr in envrs:
+ msg = 40*'=' + '\n' + envr + '\n' + 40*'='
+ self.log.append(msg)
+ print 40*'='
+ print envr
+ print 40*'='
+
+ # our testing package
+ (name, version, release, epoch, arch) =
rpmUtils.miscutils.splitFilename(envr)
+ matching_build = {
+ 'name': name,
+ 'version' : version,
+ 'release' : release + '.' + arch,
+ 'epoch' : epoch,
+ 'envr' : envr,
+ }
+
+ if kojitag.find('updates') == -1 and repotags[current_tag] !=
repotags[-1]:
+ msg = "Warning: Pushing into stable repository"
+ self.log.append(msg)
+ print msg
+
+ koji = autoqa.koji_utils.SimpleKojiClientSession()
+ 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"
+ 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)
+ # compare with higher tags, so version has to be lower or equal
+ self.compare(matching_build, hi_tags, operator.le)
+
+ # mailing stuff
+ self.result = self.test_result
+
+ 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
+
+ if self.test_result == 'FAIL':
+ raise error.TestFail
+