Why the hell wasn't my patch attached? :)
By the way, it's also available in the origin/labels branch.
diff --git a/autoqa b/autoqa
index b4b9097..9e50c53 100755
--- a/autoqa
+++ b/autoqa
@@ -28,6 +28,7 @@ import tempfile
import StringIO
import urlgrabber
import socket
+import fnmatch
from ConfigParser import *
from subprocess import call
@@ -90,6 +91,30 @@ def prep_controlfile(controlfile, extradata):
os.close(fd)
return name
+def get_aq_vars(controlfile, extradata):
+ '''Extract AutoQA specific test variables from control file and
+ return them in a dictionary. All these variables start with prefix 'aq_'.
+ Arguments:
+ * controlfile - control file
+ * extradata - dictionary with extra variables received from hook options
+ Returns: dictionary with AutoQA specific test variables
+ '''
+ lines = [line for line in open(controlfile).readlines() if
line.startswith('aq_')]
+ vars = extradata.copy()
+ for line in lines:
+ try:
+ exec line in vars
+ except:
+ print "Evaluating of AutoQA variables from control file failed:"
+ print " Line: %s" % line.strip()
+ print " Control file: %s" % controlfile
+ return {}
+ # let's leave only aq_* keys present
+ for key in vars.copy():
+ if not key.startswith('aq_'):
+ del vars[key]
+ return vars
+
def maybe_call(cmdlist, dryrun=False, verbose=False):
if dryrun or verbose:
print ' '.join(cmdlist)
@@ -102,21 +127,28 @@ def maybe_call(cmdlist, dryrun=False, verbose=False):
return None
# TODO add info about required distro
-def schedule_job(controlfile, required_arch=None, email=None, name=None, dryrun=False):
+def schedule_job(controlfile, required_arch=None, email=None, name=None, dryrun=False,
labels=[]):
cmd = ['/usr/bin/atest', 'job', 'create']
if email:
cmd += ['-e', email]
# some hooks/tests may require special machines
if required_arch:
+ # for 'i[3-6]86' arch we have 'i386' autotest label, let's
convert it
+ if fnmatch.fnmatch(required_arch, 'i?86'):
+ required_arch = 'i386'
cmd += ['-m', '*%s' % required_arch]
# NOTE this doesn't work without -m, so we need to pick something..
# currently we require an --arch flag though, so this will never happen
else:
- # FIXME schedule against distro label with e.g. '-b fc11'
cmd += ['-m', '*x86_64']
+ # schedule against additional labels, like distro label ('fc13')
+ if labels:
+ cmd += ['-d', ','.join(labels)]
+ cmd += ['-f', controlfile]
+ # do not restart machines
+ cmd += ['-B', 'never', '-a', 'never']
cmd.append(name) # job name
- thiscmd = cmd + ['-f', controlfile]
- return maybe_call(thiscmd, dryrun)
+ return maybe_call(cmd, dryrun)
def run_test_locally(controlfile, name=None, dryrun=False):
cmd = ['/usr/share/autotest/client/bin/autotest', '--verbose']
@@ -234,14 +266,18 @@ for arch in opts.arch:
testname='%s:%s.%s' % (hookname, test, arch)
email = conf['notification_email']
+ # get AutoQA specific test variables and use it modify scheduling call
+ aq_vars = get_aq_vars(control, testdata)
+ aq_labels = aq_vars.get('aq_labels',[])
+
if run_local:
retval = run_test_locally(control, name=testname,
dryrun=opts.dryrun)
else:
# XXX FIXME add required_distro, set arch=None for noarch tests
retval = schedule_job(control, email=email, name=testname,
- required_arch=arch,
- dryrun=opts.dryrun)
+ required_arch=arch, dryrun=opts.dryrun,
+ labels=aq_labels)
if retval != 0:
print "ERROR: failed to schedule job %s" % testname
diff --git a/hooks/post-bodhi-update/control.template
b/hooks/post-bodhi-update/control.template
index 34878e0..7d49d1e 100644
--- a/hooks/post-bodhi-update/control.template
+++ b/hooks/post-bodhi-update/control.template
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "YOUR NAME <you(a)youremail.biz>"
DOC = """
@@ -9,6 +11,15 @@ TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need
multiple machines
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
# post-bodhi-update tests can expect the following variables from autoqa:
# title: title of the update request
# updateid: Unique ID of the update request (may be empty)
diff --git a/hooks/post-koji-build/control.template
b/hooks/post-koji-build/control.template
index b90260f..eba3353 100644
--- a/hooks/post-koji-build/control.template
+++ b/hooks/post-koji-build/control.template
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "YOUR NAME <you(a)youremail.biz>"
DOC = """
@@ -9,6 +11,15 @@ TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need
multiple machines
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
# post-koji-build tests can expect the following variables from autoqa:
# envr: package ENVR (required, epoch can be skipped)
# name: package name
diff --git a/hooks/post-repo-update/control.template
b/hooks/post-repo-update/control.template
index 50ba58d..39a4456 100644
--- a/hooks/post-repo-update/control.template
+++ b/hooks/post-repo-update/control.template
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "YOUR NAME <you(a)youremail.biz>"
DOC = """
@@ -9,12 +11,20 @@ TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need
multiple machines
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
-# post-repo-update tests can expect the following variables from autoqa:
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
#
-#url - url of repo that changed
-#parents - space-separated list of urls for 'parent' repos of the given repo
-#reponame - name for repo that changed
-#autoqa_conf - contents of /etc/autoqa/autoqa.conf on the server
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
+# post-repo-update tests can expect the following variables from autoqa:
+# url: url of repo that changed
+# parents: space-separated list of urls for 'parent' repos of the given repo
+# reponame: name for repo that changed
+# autoqa_conf: contents of /etc/autoqa/autoqa.conf on the server
job.run_test('testclassname', baseurl=url,
parents=parents,
diff --git a/hooks/post-tree-compose/control.template
b/hooks/post-tree-compose/control.template
index e327799..77c5f31 100644
--- a/hooks/post-tree-compose/control.template
+++ b/hooks/post-tree-compose/control.template
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "YOUR NAME <you(a)youremail.biz>"
DOC = """
@@ -9,11 +11,19 @@ TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need
multiple machines
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
-# post-tree-compose tests can expect the following variables from autoqa:
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
#
-#url - url of the new tree
-#treename - name for the new tree
-#autoqa_conf - contents of /etc/autoqa/autoqa.conf on the server
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
+# post-tree-compose tests can expect the following variables from autoqa:
+# url: url of the new tree
+# treename: name for the new tree
+# autoqa_conf: contents of /etc/autoqa/autoqa.conf on the server
job.run_test('testclassname', baseurl=url,
treename=treename,
diff --git a/tests/conflicts/control b/tests/conflicts/control
index 7c9b780..1c3d92c 100644
--- a/tests/conflicts/control
+++ b/tests/conflicts/control
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "Will Woods <wwoods(a)redhat.com>"
DOC = """
@@ -10,6 +12,21 @@ TEST_TYPE = 'CLIENT'
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
+# post-repo-update tests can expect the following variables from autoqa:
+# url: url of repo that changed
+# parents: space-separated list of urls for 'parent' repos of the given repo
+# reponame: name for repo that changed
+# autoqa_conf: contents of /etc/autoqa/autoqa.conf on the server
+
job.run_test('conflicts', baseurl=url,
parents=parents,
reponame=reponame,
diff --git a/tests/initscripts/control b/tests/initscripts/control
index fec4fc0..e5910b2 100644
--- a/tests/initscripts/control
+++ b/tests/initscripts/control
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "Josef Skladanka <jskladan(a)redhat.com>"
DOC = """
@@ -9,6 +11,21 @@ TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need
multiple machines
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+
+# initscripts may leave services in inconsistent states, let's test it in
+# virtual machines as a precaution
+aq_labels = ['virt']
+# because we install the package, the distribution label must match the package's
+# Fedora release (like 'fc13')
+aq_labels.append(envr.split('.')[-1])
+
+### Job execution ###
# post-koji-build tests can expect the following variables from autoqa:
# envr: package ENVR (required, epoch can be skipped)
# name: package name
diff --git a/tests/rats_install/control b/tests/rats_install/control
index f3fd56e..62249e2 100644
--- a/tests/rats_install/control
+++ b/tests/rats_install/control
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "Will Woods <wwoods(a)redhat.com>"
DOC = """
@@ -12,8 +14,22 @@ The test cases covered by this test are:
- Anaconda stage2 disk probe
"""
NAME = 'rats_install'
+TEST_TYPE = 'CLIENT'
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
-TEST_TYPE = 'CLIENT'
+
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = ['virt_capable'] # it must support KVM, we use it
+
+### Job execution ###
+# post-tree-compose tests can expect the following variables from autoqa:
+# url: url of the new tree
+# treename: name for the new tree
+# autoqa_conf: contents of /etc/autoqa/autoqa.conf on the server
job.run_test('rats_install', baseurl=url, treename=treename, config=autoqa_conf)
diff --git a/tests/rats_sanity/control b/tests/rats_sanity/control
index 299d423..fd8894b 100644
--- a/tests/rats_sanity/control
+++ b/tests/rats_sanity/control
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "Will Woods <wwoods(a)redhat.com>"
DOC = """
@@ -17,6 +19,21 @@ TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional' # Acceptance, really, but whatevs
TEST_TYPE = 'CLIENT'
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
+# post-repo-update tests can expect the following variables from autoqa:
+# url: url of repo that changed
+# parents: space-separated list of urls for 'parent' repos of the given repo
+# reponame: name for repo that changed
+# autoqa_conf: contents of /etc/autoqa/autoqa.conf on the server
+
job.run_test('rats_sanity', baseurl=url,
parents=parents,
reponame=reponame,
diff --git a/tests/repoclosure/control b/tests/repoclosure/control
index 8467545..69bc0b2 100644
--- a/tests/repoclosure/control
+++ b/tests/repoclosure/control
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "Will Woods <wwoods(a)redhat.com>"
DOC = """
@@ -10,6 +12,20 @@ TEST_TYPE = 'CLIENT'
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
+# post-repo-update tests can expect the following variables from autoqa:
+# url: url of repo that changed
+# parents: space-separated list of urls for 'parent' repos of the given repo
+# reponame: name for repo that changed
+# autoqa_conf: contents of /etc/autoqa/autoqa.conf on the server
job.run_test('repoclosure', baseurl=url, parents=parents, reponame=reponame,
config=autoqa_conf)
diff --git a/tests/rpmguard/control b/tests/rpmguard/control
index 8c6bd12..512e82e 100644
--- a/tests/rpmguard/control
+++ b/tests/rpmguard/control
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "Kamil Paral <kparal(a)redhat.com>"
DOC = """
@@ -12,6 +14,15 @@ TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need
multiple machines
TEST_CLASS = 'General'
TEST_CATEGORY = 'Regression'
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+
+### Job execution ###
# post-koji-build tests can expect the following variables from autoqa:
# envr: package NVR (required, epoch can be skipped)
# name: package name
diff --git a/tests/rpmlint/control b/tests/rpmlint/control
index a03be4e..756d252 100644
--- a/tests/rpmlint/control
+++ b/tests/rpmlint/control
@@ -1,4 +1,6 @@
# vim: set syntax=python
+
+### Variables describing test ###
TIME="SHORT"
AUTHOR = "Will Woods <wwoods(a)redhat.com>"
DOC = """
@@ -9,7 +11,16 @@ NAME = 'rpmlint'
TEST_TYPE = 'CLIENT' # SERVER can be used for tests that need multiple machines
TEST_CLASS = 'General'
TEST_CATEGORY = 'Functional'
+
+### AutoQA specific variables used for scheduling ###
+# You can use contents of variables that are passed in here and used for job
+# execution (see below) if you need it.
+#
+# aq_labels - list of autotest labels that must be present on target test client
+# example: aq_labels = ['fc13', 'virt']
+aq_labels = []
+### Job execution ###
# post-koji-build tests can expect the following variables from autoqa:
# envr: package NVR (required, epoch can be skipped)
# name: package name