KVM test: Unattended script: Make qemu_img_bin come from test params
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/5 KVM test: Unattended script: Make qemu_img_bin come from test params
Instead of hard coding the path to qemu-img on the unattended_install script, let's pick it up from the test parameters.
--- client/tests/kvm/scripts/unattended.py | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
client/tests/kvm/scripts/unattended.py +1 -1
@@ -53,7 +53,7 @@ class UnattendedInstall(object): cdrom_iso = os.environ['KVM_TEST_cdrom'] self.unattended_file = os.environ['KVM_TEST_unattended_file'] - self.qemu_img_bin = os.path.join(kvm_test_dir, 'qemu-img') + self.qemu_img_bin = os.environ['KVM_TEST_qemu_img_binary'] self.cdrom_iso = os.path.join(kvm_test_dir, cdrom_iso) self.floppy_mount = tempfile.mkdtemp(prefix='floppy_', dir='/tmp') self.cdrom_mount = tempfile.mkdtemp(prefix='cdrom_', dir='/tmp')
Signature · 1 line
1.6.5.2
PATCH 3/5 KVM test: Verify paths to cdrom and qemu on kvm_preprocessing
If paths to CD images and qemu binaries are not correctly configured, the tests will fail, sometimes giving to unexperienced users little clue about what is actually going on. So make sure we verify:
* ISO paths
* qemu binary paths
Inside kvm_preprocessing code, and give clear indications if something goes wrong, asking the user to fix the configuration problem.
--- client/tests/kvm/kvm_preprocessing.py | 48 +++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-)
client/tests/kvm/kvm_preprocessing.py +48 -0
@@ -187,6 +187,29 @@ def preprocess(test, params, env): @param params: A dict containing all VM and image parameters. @param env: The environment (a dict-like object). """ + # Verify if the: + # * CD locations + # * qemu and qemu-img binaries + # are valid paths + needed_paths = [[params.get("cdrom", ""), + os.path.join(test.bindir, 'isos')], + [params.get("qemu_binary", ""), test.bindir], + [params.get("qemu_img_binary", ""), test.bindir]] + + missing_paths = [] + for needed_path, root_dir in needed_paths: + # If the test doesn't set one of the parameters, + # just don't check for it. + if needed_path: + needed_path = kvm_utils.get_path(root_dir, needed_path) + if not _is_path_present(needed_path): + missing_paths.append(needed_path) + + if missing_paths: + raise error.TestError("The following needed paths are missing " + "or are broken symbolic links: %s" % + missing_paths) + # Start tcpdump if it isn't already running if not env.has_key("address_cache"): env["address_cache"] = {}
@@ -343,3 +366,28 @@ def _update_address_cache(address_cache, line): mac_address, address_cache.get("last_seen")) address_cache[mac_address] = address_cache.get("last_seen") del address_cache["last_seen"] + + +def _is_path_present(path): + """ + Verify whether a given path to a file is present (follows symlinks). + + @param path: Path to the file. + @return: True when the file is present, False when it's not. + """ + exists = True + + if os.path.islink(path): + source = os.path.abspath(os.readlink(path)) + if not os.path.isfile(source): + logging.warning("File %s, needed for this test, " + "is a broken symbolic link. Please fix your " + "test configuration." % path) + exists = False + elif not os.path.isfile(path): + logging.warning("File %s, needed for this test, does not exist. " + "Please fix your test configuration." % path) + exists = False + + return exists +
Signature · 1 line
1.6.5.2
PATCH 4/5 KVM test: Reorganizing configuration files
Dropped the kvm_ parameter from the names of
configuration files, added a new build.cfg.sample
file, and split the main tests file into:
* tests_base.cfg.sample - a test config 'library'
* tests.cfg.sample - test sets definition
--- client/tests/kvm/address_pools.cfg.sample | 65 ++ client/tests/kvm/build.cfg.sample | 85 +++ client/tests/kvm/cdkeys.cfg.sample | 17 + client/tests/kvm/kvm_address_pools.cfg.sample | 64 -- client/tests/kvm/kvm_cdkeys.cfg.sample | 16 - client/tests/kvm/kvm_tests.cfg.sample | 941 ------------------------- client/tests/kvm/tests.cfg.sample | 69 ++ client/tests/kvm/tests_base.cfg.sample | 886 +++++++++++++++++++++++ 8 files changed, 1122 insertions(+), 1021 deletions(-) create mode 100644 client/tests/kvm/address_pools.cfg.sample create mode 100644 client/tests/kvm/build.cfg.sample create mode 100644 client/tests/kvm/cdkeys.cfg.sample delete mode 100644 client/tests/kvm/kvm_address_pools.cfg.sample delete mode 100644 client/tests/kvm/kvm_cdkeys.cfg.sample delete mode 100644 client/tests/kvm/kvm_tests.cfg.sample create mode 100644 client/tests/kvm/tests.cfg.sample create mode 100644 client/tests/kvm/tests_base.cfg.sample
client/tests/kvm/address_pools.cfg.sample new file +65 -0
@@ -0,0 +1,65 @@ +# Copy this file to address_pools.cfg and edit it. +# +# This file specifies several MAC-IP ranges for each host in the network that +# may run KVM tests. A MAC address must not be used twice, so these ranges +# must not overlap. The VMs running on each host will only use MAC addresses +# from the pool of that host. +# If you wish to use a static MAC-IP mapping, where each MAC address range is +# mapped to a known corresponding IP address range, specify the bases of the IP +# address ranges in this file. +# If you specify a MAC address range without a corresponding IP address range, +# the IP addresses for that range will be determined at runtime by listening +# to DHCP traffic using tcpdump. +# If you wish to determine IP addresses using tcpdump in any case, regardless +# of any # IP addresses specified in this file, uncomment the following line: +#always_use_tcpdump = yes +# You may also specify this parameter for specific hosts by adding it in the +# appropriate sections below. + +variants: + # Rename host1 to an actual (short) hostname in the network that will be running the Autotest client + - @host1: + # Add/remove ranges here + address_ranges = r1 r2 + + # Modify the following parameters to reflect the DHCP server's configuration + address_range_base_mac_r1 = 52:54:00:12:35:56 + #address_range_base_ip_r1 = 10.0.2.20 + address_range_size_r1 = 16 + + # Modify the following parameters to reflect the DHCP server's configuration + address_range_base_mac_r2 = 52:54:00:12:35:80 + #address_range_base_ip_r2 = 10.0.2.40 + address_range_size_r2 = 16 + + # Rename host2 to an actual (short) hostname in the network that will be running the Autotest client + - @host2: + # Add/remove ranges here + address_ranges = r1 r2 + + # Modify the following parameters to reflect the DHCP server's configuration + address_range_base_mac_r1 = 52:54:00:12:36:56 + #address_range_base_ip_r1 = 10.0.3.20 + address_range_size_r1 = 16 + + # Modify the following parameters to reflect the DHCP server's configuration + address_range_base_mac_r2 = 52:54:00:12:36:80 + #address_range_base_ip_r2 = 10.0.3.40 + address_range_size_r2 = 16 + + # Add additional hosts here... + + # This will be used for hosts that do not appear on the list + - @default_host: + # Add/remove ranges here + address_ranges = r1 r2 + + # Modify the following parameters to reflect the DHCP server's configuration + address_range_base_mac_r1 = 52:54:00:12:34:56 + #address_range_base_ip_r1 = 10.0.1.20 + address_range_size_r1 = 16 + + # Modify the following parameters to reflect the DHCP server's configuration + address_range_base_mac_r2 = 52:54:00:12:34:80 + #address_range_base_ip_r2 = 10.0.1.40 + address_range_size_r2 = 16
client/tests/kvm/build.cfg.sample new file +85 -0
85 lines not on this page · raw message
client/tests/kvm/cdkeys.cfg.sample new file +17 -0
@@ -0,0 +1,17 @@ +# Copy this file to cdkeys.cfg and edit it. +# +# Replace the 'CDKEY' strings with real cdkeys where necessary. +# Guests that do not require cdkeys by default are commented out. +# You may uncomment them if necessary. + +RHEL.5.3.i386: cdkey = CDKEY +RHEL.5.3.x86_64: cdkey = CDKEY +Win2000: cdkey = CDKEY +WinXP.32: cdkey = CDKEY +WinXP.64: cdkey = CDKEY +Win2003.32: cdkey = CDKEY +Win2003.64: cdkey = CDKEY +#WinVista.32: cdkey = CDKEY +#WinVista.64: cdkey = CDKEY +#Win2008.32: cdkey = CDKEY +#Win2008.64: cdkey = CDKEY
client/tests/kvm/kvm_address_pools.cfg.sample deleted +0 -64
64 lines not on this page · raw message
client/tests/kvm/kvm_cdkeys.cfg.sample deleted +0 -16
@@ -1,16 +0,0 @@ -# Rename this file to kvm_cdkeys.cfg. -# Replace the 'CDKEY' strings with real cdkeys where necessary. -# Guests that do not require cdkeys by default are commented out. -# You may uncomment them if necessary. - -RHEL.5.3.i386: cdkey = CDKEY -RHEL.5.3.x86_64: cdkey = CDKEY -Win2000: cdkey = CDKEY -WinXP.32: cdkey = CDKEY -WinXP.64: cdkey = CDKEY -Win2003.32: cdkey = CDKEY -Win2003.64: cdkey = CDKEY -#WinVista.32: cdkey = CDKEY -#WinVista.64: cdkey = CDKEY -#Win2008.32: cdkey = CDKEY -#Win2008.64: cdkey = CDKEY
client/tests/kvm/kvm_tests.cfg.sample deleted +0 -941
941 lines not on this page · raw message
client/tests/kvm/tests.cfg.sample new file +69 -0
69 lines not on this page · raw message
client/tests/kvm/tests_base.cfg.sample new file +886 -0
886 lines not on this page · raw message
Signature · 1 line
1.6.5.2
PATCH 5/5 KVM test: Major control file cleanup
As pointed out before, the KVM reference control files could use a little clean up. This patch implements severe cleanup of the main control file by:
* Refactoring the code present there, moving it to the kvm_utils.py library
* Treat the build test exactly the same way as other tests, moving the config stuff that used to be in the control file realm out to its own configuration file, for the sake of consistency.
This way the control file becomes way shorter, fairly well organized, and we have a consistent configuration schema across the board, based on configuration files.
If people are OK with this change, final patch will change the control.parallel file as well.
2nd try: Implemented pretty much all Michael's suggestions for this patchset.
--- client/tests/kvm/control | 219 +++++++---------------------------------- client/tests/kvm/kvm_utils.py | 51 ++++++++++ 2 files changed, 86 insertions(+), 184 deletions(-)
client/tests/kvm/control +35 -184
@@ -6,7 +6,7 @@ [email protected] (David Huff) [email protected] (Alexey Eromenko) [email protected] (Mike Burns) """ -TIME = 'SHORT' +TIME = 'MEDIUM' NAME = 'KVM test' TEST_TYPE = 'client' TEST_CLASS = 'Virtualization'
@@ -20,194 +20,45 @@ KVM (both kernelspace and userspace) code. For online docs, please refer to http://www.linux-kvm.org/page/KVM-Autotest """ +import sys, os, logging +# Add the KVM tests dir to the python path +kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm') +sys.path.append(kvm_test_dir) +# Now we can import modules inside the KVM tests dir +import kvm_utils, kvm_config -import sys, os - -#----------------------------------------------------------------------------- # set English environment (command output might be localized, need to be safe) -#----------------------------------------------------------------------------- os.environ['LANG'] = 'en_US.UTF-8' -#--------------------------------------------------------- -# Enable modules import from current directory (tests/kvm) -#--------------------------------------------------------- -pwd = os.path.join(os.environ['AUTODIR'],'tests/kvm') -sys.path.append(pwd) - -# ------------------------ -# create required symlinks -# ------------------------ -# When dispatching tests from autotest-server the links we need do not exist on -# the host (the client). The following lines create those symlinks. Change -# 'rootdir' here and/or mount appropriate directories in it. -# -# When dispatching tests on local host (client mode) one can either setup kvm -# links, or same as server mode use rootdir and set all appropriate links and -# mount-points there. For example, guest installation tests need to know where -# to find the iso-files. -# -# We create the links only if not already exist, so if one already set up the -# links for client/local run we do not touch the links. -rootdir='/tmp/kvm_autotest_root' -iso=os.path.join(rootdir, 'iso') -images=os.path.join(rootdir, 'images') -qemu=os.path.join(rootdir, 'qemu') -qemu_img=os.path.join(rootdir, 'qemu-img') - - -def link_if_not_exist(ldir, target, link_name): - t = target - l = os.path.join(ldir, link_name) - if not os.path.exists(l): - os.system('ln -s %s %s' % (t, l)) - -# Create links only if not already exist -link_if_not_exist(pwd, '../../', 'autotest') -link_if_not_exist(pwd, iso, 'isos') -link_if_not_exist(pwd, images, 'images') -link_if_not_exist(pwd, qemu, 'qemu') -link_if_not_exist(pwd, qemu_img, 'qemu-img') - -# -------------------------------------------------------- -# Params that will be passed to the KVM install/build test -# -------------------------------------------------------- -params = { - "name": "build", - "shortname": "build", - "type": "build", - #"mode": "release", - #"mode": "snapshot", - #"mode": "localtar", - #"mode": "localsrc", - #"mode": "git", - "mode": "noinstall", - #"mode": "koji", - - ## Are we going to load modules built by this test? - ## Defaults to 'yes', so if you are going to provide only userspace code to - ## be built by this test, please set load_modules to 'no', and make sure - ## the kvm and kvm-[vendor] module is already loaded by the time you start - ## it. - #"load_modules": "no", - - ## Install from a kvm release ("mode": "release"). You can optionally - ## specify a release tag. If you omit it, the test will get the latest - ## release tag available. - #"release_tag": '84', - #"release_dir": 'http://downloads.sourceforge.net/project/kvm/', - # This is the place that contains the sourceforge project list of files - #"release_listing": 'http://sourceforge.net/projects/kvm/files/', - - ## Install from a kvm snapshot location ("mode": "snapshot"). You can - ## optionally specify a snapshot date. If you omit it, the test will get - ## yesterday's snapshot. - #"snapshot_date": '20090712' - #"snapshot_dir": 'http://foo.org/kvm-snapshots/', - - ## Install from a tarball ("mode": "localtar") - #"tarball": "/tmp/kvm-84.tar.gz", - - ## Install from a local source code dir ("mode": "localsrc") - #"srcdir": "/path/to/source-dir" - - ## Install from koji build server ("mode": "koji") - ## Koji is the Fedora Project buildserver. It is possible to install - ## packages right from Koji if you provide a release tag or a build. - ## Tag (if available) - #"koji_tag": 'dist-f11', - ## Build (if available, is going to override tag). - #"koji_build": 'qemu-0.10-16.fc11', - ## Command to interact with the build server - #"koji_cmd": '/usr/bin/koji', - ## The name of the source package that's being built - #"src_pkg": 'qemu', - ## Name of the rpms we need installed - #"pkg_list": ['qemu-kvm', 'qemu-kvm-tools', 'qemu-system-x86', 'qemu-common', 'qemu-img'], - ## Paths of the qemu relevant executables that should be checked - #"qemu_bin_paths": ['/usr/bin/qemu-kvm', '/usr/bin/qemu-img'], - - ## Install from git ("mode": "git") - ## If you provide only "git_repo" and "user_git_repo", the build test - ## will assume it will perform all build from the userspace dir, building - ## modules trough make -C kernel LINUX=%s sync. As of today (07-13-2009) - ## we need 3 git repos, "git_repo" (linux sources), "user_git_repo" and - ## "kmod_repo" to build KVM userspace + kernel modules. - #"git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git', - #"kernel_branch": 'kernel_branch_name', - #"kernel_lbranch": 'kernel_lbranch_name', - #"kernel_tag": 'kernel_tag_name', - #"user_git_repo": 'git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git', - #"user_branch": 'user_branch_name', - #"user_lbranch": 'user_lbranch_name', - #"user_tag": 'user_tag_name', - #"kmod_repo": 'git://git.kernel.org/pub/scm/virt/kvm/kvm-kmod.git', - #"kmod_branch": 'kmod_branch_name', - #"kmod_lbranch": 'kmod_lbranch_name', - #"kmod_tag": 'kmod_tag_name', -} - -# If you don't want to execute the build stage, just use 'noinstall' as the -# install type. If you run the tests from autotest-server, make sure that -# /tmp/kvm-autotest-root/qemu is a link to your existing executable. Note that -# if kvm_install is chose to run, it overwrites existing qemu and qemu-img -# links to point to the newly built executables. - -if not params.get("mode") == "noinstall": - if not job.run_test("kvm", params=params, tag=params.get("shortname")): - print 'kvm_installation failed ... exiting' - sys.exit(1) - -# ---------------------------------------------------------- -# Get test set (dictionary list) from the configuration file -# ---------------------------------------------------------- -import kvm_config - -filename = os.path.join(pwd, "kvm_tests.cfg") -cfg = kvm_config.config(filename) - -# If desirable, make changes to the test configuration here. For example: -# cfg.parse_string("install|setup: timeout_multiplier = 2") -# cfg.parse_string("only fc8_quick") -# cfg.parse_string("display = sdl") - -filename = os.path.join(pwd, "kvm_address_pools.cfg") -if os.path.exists(filename): - cfg.parse_file(filename) - hostname = os.uname()[1].split(".")[0] - if cfg.filter("^" + hostname): - cfg.parse_string("only ^%s" % hostname) - else: - cfg.parse_string("only ^default_host") - -list = cfg.get_list() - +build_cfg_path = os.path.join(kvm_test_dir, "build.cfg") +build_cfg = kvm_config.config(build_cfg_path) +# Make any desired changes to the build configuration here. For example: +#build_cfg.parse_string(""" +#release_tag = 84 +#""") +if not kvm_utils.run_tests(build_cfg.get_list(), job): + logging.error("KVM build step failed, exiting.") + sys.exit(1) + +tests_cfg_path = os.path.join(kvm_test_dir, "tests.cfg") +tests_cfg = kvm_config.config(tests_cfg_path) +# Make any desired changes to the test configuration here. For example: +#tests_cfg.parse_string(""" +#display = sdl +#install|setup: timeout_multiplier = 3 +#""") + +pools_cfg_path = os.path.join(kvm_test_dir, "address_pools.cfg") +tests_cfg.parse_file(pools_cfg_path) +hostname = os.uname()[1].split(".")[0] +if tests_cfg.filter("^" + hostname): + tests_cfg.parse_string("only ^%s" % hostname) +else: + tests_cfg.parse_string("only ^default_host") -# ------------- # Run the tests -# ------------- -status_dict = {} +kvm_utils.run_tests(tests_cfg.get_list(), job) -for dict in list: - if dict.get("skip") == "yes": - continue - dependencies_satisfied = True - for dep in dict.get("depend"): - for test_name in status_dict.keys(): - if not dep in test_name: - continue - if not status_dict[test_name]: - dependencies_satisfied = False - break - if dependencies_satisfied: - test_iterations = int(dict.get("iterations", 1)) - current_status = job.run_test("kvm", params=dict, - tag=dict.get("shortname"), - iterations=test_iterations) - else: - current_status = False - status_dict[dict.get("name")] = current_status +# Generate a nice HTML report inside the job's results dir +kvm_utils.create_report(kvm_test_dir, job.resultdir) -# create the html report in result dir -reporter = os.path.join(pwd, 'make_html_report.py') -html_file = os.path.join(job.resultdir,'results.html') -os.system('%s -r %s -f %s -R'%(reporter, job.resultdir, html_file))
client/tests/kvm/kvm_utils.py +51 -0
54 lines not on this page · raw message
Signature · 1 line
1.6.5.2