On Wed, 2010-08-18 at 14:40 +0200, Vojtěch Aschenbrenner wrote:
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 :-).
I was interested in testing out just the upgrade-path portion of the test (not the autotest/autoqa integration). How would you feel about moving the test to a stand-alone script, and then changing upgradepath.py to call the stand-alone script and process output?
I think this would make it a lot easier for folks without a full autoqa and autotest-server setup to run the test at home.
Thanks, James
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@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@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-serverself.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 msgmsg = "-> Package %s in %s doesn't exist" % (matching_build['name'], tag)self.log.append(msg)print msgelse:result = autoqa.koji_utils.compareEVR(matching_build, latest_build)if op(result, 0):msg = tag + '... OK'print msgself.log.append(msg)else:self.test_result = 'FAIL'msg = tag + '... FAIL'print msgself.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 msgself.log.append(msg)self.envr_list.add(matching_build['envr'])raise error.TestFailhi_tags = repotags[(current_tag + 1):] # tags higher than currentlow_eq_tags = repotags[:(current_tag + 1)] # tags lower or equalfor envr in envrs:msg = 40*'=' + '\n' + envr + '\n' + 40*'='self.log.append(msg)print 40*'='print envrprint 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 msgkoji = 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 equalself.compare(matching_build, low_eq_tags, operator.ge)# compare with higher tags, so version has to be lower or equalself.compare(matching_build, hi_tags, operator.le)# mailing stuffself.result = self.test_resultself.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_failif self.test_result == 'FAIL':raise error.TestFail
autoqa-devel mailing list autoqa-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/autoqa-devel