---
lib/python/rats.py | 66 +++++++++++++++-------------------------
tests/rats_install/install.py | 61 ++++++++++++++++++++++++++++++++-----
tests/rats_sanity/sanity.py | 35 +++++++++++++++++-----
3 files changed, 104 insertions(+), 58 deletions(-)
diff --git a/lib/python/rats.py b/lib/python/rats.py
index 3adda31..03b2148 100644
--- a/lib/python/rats.py
+++ b/lib/python/rats.py
@@ -61,48 +61,32 @@ def report_results(testlist, keyvals, url=None, username='',
password=''):
# TODO: handle other statuses (e.g. WARN)
irb.send_request('/add_result', auth=True, req_params=params)
-def parse_args():
- archlist = ['i386', 'x86_64', 'ppc']
- parser = optparse.OptionParser(usage="%prog [options] TREEURL")
- parser.add_option("-a", "--arch", action="store",
type="choice",
- choices=archlist, default=util.get_basearch(),
- help="target architecture (%default)")
- parser.add_option("-s", "--scratchdir",
action="store",
- default=config.scratchdir,
- help="scratch dir for downloaded/generated files (%default)")
- parser.add_option("-l", "--logdir", action="store",
- default=config.logdir,
- help="write logs to this dir (%default)")
- parser.add_option("-b", "--bindir", action="store",
- default=config.bindir,
- help="binary dir - contains minimon, ks.cfg, etc. (%default)")
- parser.add_option("-i", "--image-url", action="store",
- default="",
- help="Specify alternative URL for boot and install images")
- parser.add_option("-x", "--extra-args",
action="store",
- default="",
- help="Additional arguments to pass to the kernel booted from the specified
TREEURL")
- parser.add_option("-r", "--ram", action="store",
type="int", dest="memory",
- default=768,
- help="Memory to allocate for guest instance in megabytes (default:
%default)")
- (opt, args) = parser.parse_args()
+class RatsOptionParser(optparse.OptionParser):
- # Validate arguments
- if len(args) != 1:
- parser.error("incorrect number of arguments")
+ def __init__(self, *args, **kwargs):
+ optparse.OptionParser.__init__(self, *args, **kwargs)
- # Set the default URL prefix for all urlgrabber operations
- url_prefix = opt.image_url or args[0]
- if not url_prefix.endswith('/'):
- url_prefix = url_prefix + '/'
- util.grabber.opts.prefix = url_prefix
+ # RATS-specific options
+ self.set_usage("%prog [options] TREEURL")
- # Process TREEURL
- baseurl = args[0]
- if not baseurl.endswith('/'):
- baseurl = baseurl + '/'
+ archlist = ['i386', 'x86_64', 'ppc']
+ self.add_option("-a", "--arch", action="store",
type="choice",
+ choices=archlist, default=util.get_basearch(),
+ help="target architecture (%default)")
+ self.add_option("-s", "--scratchdir",
action="store",
+ default=config.scratchdir,
+ help="scratch dir for downloaded/generated files (%default)")
+ self.add_option("-l", "--logdir", action="store",
+ default=config.logdir,
+ help="write logs to this dir (%default)")
+ self.add_option("-b", "--bindir", action="store",
+ default=config.bindir,
+ help="binary dir - contains minimon, ks.cfg, etc. (%default)")
- config.set_scratchdir(opt.scratchdir)
- config.logdir = opt.logdir
- config.bindir = opt.bindir
- return (opt, baseurl)
+ def check_values(self, values, args):
+
+ # Was a TREEURL supplied?
+ if len(args) != 1:
+ parser.error("incorrect number of arguments")
+
+ return optparse.OptionParser.check_values(self, values, args)
diff --git a/tests/rats_install/install.py b/tests/rats_install/install.py
index c596239..ff6a692 100755
--- a/tests/rats_install/install.py
+++ b/tests/rats_install/install.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# Rawhide Acceptance Test Suite - install testing
-#
+#
# basic usage: ./install.py treeurl
#
# Copyright 2009, Red Hat, Inc.
@@ -27,6 +27,7 @@ import gzip
import time
import ConfigParser
import re
+import optparse
from subprocess import *
from minimon import MinimonServer
from autoqa import rats, util, config
@@ -44,14 +45,14 @@ def installer_image_test(arch):
print "Failed to download .treeinfo: %s" % str(e)
return False
c.read(treeinfo)
-
- # 2. confirm that the arch listed in the [general] section is correct
+
+ # 2. confirm that the arch listed in the [general] section is correct
util.check("[general] section in .treeinfo",
c.has_section('general'))
util.check("arch = %s in [general]" % arch,
c.get('general','arch') == arch)
timestamp = float(c.get('general','timestamp'))
-
+
# 3. confirm that the files listed in the [images-$ARCH] section are present
- # and non-empty
+ # and non-empty
img_s = 'images-%s' % arch
util.check("[%s] section" % img_s, c.has_section(img_s))
util.check("kernel", c.has_option(img_s,'kernel'))
@@ -65,13 +66,13 @@ def installer_image_test(arch):
relpath = c.get('stage2','mainimage')
print "stage2 mainimage: %s" % os.path.basename(relpath)
fetchlist.append(relpath)
-
- # 5. confirm that the listed images are present and non-empty
+
+ # 5. confirm that the listed images are present and non-empty
for relpath in fetchlist:
loc = util.simplegrab(relpath)
util.check("%s non-empty" % os.path.basename(relpath),
util.nonempty(loc))
localfile[relpath] = loc
-
+
# 6. check that each of the listed files matches the checksum specified in
# the [checksum] section
util.check("[checksum] section", c.has_section('checksums'))
@@ -324,15 +325,57 @@ def system_sanity():
print msg
return False
+def parse_args():
+ # establish install-specific command-line options
+ parser = rats.RatsOptionParser()
+
+ optgroup = optparse.OptionGroup(parser, "Installation Options")
+ optgroup.add_option("-i", "--image-url",
action="store",
+ default="",
+ help="Specify alternative URL for boot and install images")
+ optgroup.add_option("-x", "--extra-args",
action="store",
+ default="",
+ help="Additional arguments to pass to the kernel booted from the specified
TREEURL")
+ optgroup.add_option("-r", "--ram", action="store",
type="int", dest="memory",
+ default=768,
+ help="Memory to allocate for guest instance in megabytes (default:
%default)")
+ parser.add_option_group(optgroup)
+
+ # Process command-line arguments
+ (opt, args) = parser.parse_args()
+
+ # Process TREEURL
+ baseuri = args[0]
+ if not baseuri.endswith('/'):
+ baseuri = baseuri + '/'
+
+ # Process IMAGEURL
+ url_prefix = opt.image_url or baseuri
+ if not url_prefix.endswith('/'):
+ url_prefix = url_prefix + '/'
+
+ # Set the default URL prefix for future urlgrabber operations
+ util.grabber.opts.prefix = url_prefix
+
+ config.set_scratchdir(opt.scratchdir)
+ config.logdir = opt.logdir
+ config.bindir = opt.bindir
+ return (opt, baseuri)
+
#http://fedoraproject.org/wiki/QA:Rawhide_Acceptance_Test_Plan#Installability_2
if __name__ == '__main__':
- (opt, baseuri) = rats.parse_args()
+
+ # Process command-line arguments
+ (opt, baseuri) = parse_args()
+
+ # Environment sanity checks
if not os.getuid() == 0:
print "ERROR: this can't be run as a normal user (yet)"
sys.exit(1)
if not system_sanity():
sys.exit(1)
+ # Start testing
print "== installer image sanity test =="
timestamp = util.test("images", installer_image_test(opt.arch))
util.write_keyval("treeinfo_timestamp", timestamp)
diff --git a/tests/rats_sanity/sanity.py b/tests/rats_sanity/sanity.py
index 40d226e..82bc21a 100755
--- a/tests/rats_sanity/sanity.py
+++ b/tests/rats_sanity/sanity.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
# Rawhide Acceptance Test Suite - repo sanity testing
-#
+#
# basic usage: ./sanity.py treeurl
#
# Copyright 2009, Red Hat, Inc.
@@ -131,9 +131,9 @@ def critpath_closure_test(start_list):
name_list.remove(name)
# TODO this isn't coming out right for i386
- print "%u packages in critical path (+%u multiarch)" % (len(name_list),
+ print "%u packages in critical path (+%u multiarch)" % (len(name_list),
len(pkg_list)-len(name_list))
- print "%u rejected package names: %s" % (len(skipped_list),
+ print "%u rejected package names: %s" % (len(skipped_list),
" ".join(skipped_list))
return pkg_list
@@ -153,8 +153,27 @@ def critpath_integrity_test(critpath_pkgs):
all_ok = False
return all_ok
+def parse_args():
+
+ # Process command-line arguments
+ parser = rats.RatsOptionParser()
+ (opt, args) = parser.parse_args()
+
+ # Process TREEURL
+ baseuri = args[0]
+ if not baseuri.endswith('/'):
+ baseuri = baseuri + '/'
+
+ # Set the default URL prefix for future urlgrabber operations
+ util.grabber.opts.prefix = baseuri
+
+ config.set_scratchdir(opt.scratchdir)
+ config.logdir = opt.logdir
+ config.bindir = opt.bindir
+ return (opt, baseuri)
+
if __name__ == '__main__':
- (opt, baseuri) = rats.parse_args()
+ (opt, baseuri) = parse_args()
my = yum.YumBase()
if opt.arch != util.get_basearch():
@@ -166,13 +185,13 @@ if __name__ == '__main__':
my.add_enable_repo('rats-repo-%s' % opt.arch, baseurls=[baseuri])
#
https://fedoraproject.org/wiki/QA:Rawhide_Acceptance_Test_Plan#Repo_Sanity_2
-
+
print "== repodata validity test =="
util.test("repodata", repodata_validity_test())
print "\n== comps validity test =="
util.test("comps", comps_validity_test())
-
+
(maj, min, sub) = yum.__version_info__
if (maj < 3 or min < 2 or sub < 24) and opt.arch != util.get_basearch():
print "\nWARNING: yum < 3.2.24 may be unable to depsolve other
arches."
@@ -185,8 +204,8 @@ if __name__ == '__main__':
namelist = set([p.name.encode('utf8') for p in critpath_pkgs])
util.write_keyval("critpath_count", len(namelist))
util.writelog("critpath.log", "\n".join(sorted(namelist)))
-
+
print "\n== critical path integrity test =="
util.test("critpath_integrity", critpath_integrity_test(critpath_pkgs))
-
+
print "\n== testing complete =="
--
1.6.6.1