KVM test: client parallel test execution
PATCH v4 1/1 KVM test: client parallel test execution
From: Michael Goldish <[email protected]>
This patch adds a control.parallel file that runs several test execution pipelines in parallel.
The number of pipelines is set to the number of CPUs reported by /proc/cpuinfo. It can be changed by modifying the control file.
The total amount of RAM defaults to 3/4 times what 'free -m' reports.
The scheduler's job is to make sure tests run in parallel only when there are sufficient resources to allow it. For example, a test that requires 2 CPUs will not run together with a test that requires 3 CPUs on a 4 CPU machine. The same logic applies to RAM.
Note that tests that require more CPUs and/or more RAM than the machine has are allowed to run alone, e.g. a test that requires 3GB of RAM is allowed to run on a machine with only 2GB of RAM, but no tests will run in parallel to it.
Currently TAP networking isn't supported by this scheduler because the main MAC address pool must be divided between the pipelines ("workers"). This should be straightforward to do but I haven't had the time to do it yet.
scan_results.py can be used to list the test results during and after execution.
v4:
* Updated the install part to be in sync with the current control file
* Blended this patch with the one that add scheduler parameters
* Instead of custom code to figure number of cpus, used an autotest utils function
--- client/tests/kvm/control.parallel | 204 +++++++++++++++++++++++++++++ client/tests/kvm/kvm_scheduler.py | 229 +++++++++++++++++++++++++++++++++ client/tests/kvm/kvm_tests.cfg.sample | 18 +++- 3 files changed, 449 insertions(+), 2 deletions(-) create mode 100644 client/tests/kvm/control.parallel create mode 100644 client/tests/kvm/kvm_scheduler.py
client/tests/kvm/control.parallel new file +204 -0
@@ -0,0 +1,204 @@ +AUTHOR = """ [email protected] (Uri Lublin) [email protected] (Dror Russo) [email protected] (Michael Goldish) [email protected] (David Huff) [email protected] (Alexey Eromenko) [email protected] (Mike Burns) +""" +TIME = 'SHORT' +NAME = 'KVM test' +TEST_TYPE = 'client' +TEST_CLASS = 'Virtualization' +TEST_CATEGORY = 'Functional' + +DOC = """ +Executes the KVM test framework on a given host. This module is separated in +minor functions, that execute different tests for doing Quality Assurance on +KVM (both kernelspace and userspace) code. +""" + + +import sys, os, commands, re + +#----------------------------------------------------------------------------- +# 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. +r = True +r = job.run_test("kvm", params=params, tag=params.get("shortname")) +if not r: + 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("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") + +tests = cfg.get_list() + + +# ------------- +# Run the tests +# ------------- +import kvm_scheduler +from autotest_lib.client.bin import utils + +# total_cpus defaults to the number of CPUs reported by /proc/cpuinfo +total_cpus = utils.count_cpus() +# total_mem defaults to 3/4 of the total memory reported by 'free' +total_mem = int(commands.getoutput("free -m").splitlines()[1].split()[1]) * 3/4 +# We probably won't need more workers than CPUs +num_workers = total_cpus + +# Start the scheduler and workers +s = kvm_scheduler.scheduler(tests, num_workers, total_cpus, total_mem, pwd) +job.parallel([s.scheduler], + *[(s.worker, i, job.run_test) for i in range(num_workers)]) + + +# 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_scheduler.py new file +229 -0
229 lines not on this page · raw message
client/tests/kvm/kvm_tests.cfg.sample +16 -2
@@ -22,6 +22,10 @@ image_size = 10G shell_port = 22 display = vnc +# Default scheduler params +used_cpus = 1 +used_mem = 512 + # Port redirections redirs = remote_shell guest_port_remote_shell = 22
@@ -66,6 +70,7 @@ variants: migration_test_command = help kill_vm_on_error = yes iterations = 2 + used_mem = 1024 - autotest: install setup type = autotest
@@ -112,6 +117,9 @@ variants: drift_threshold = 50 # Fail if the drift after the rest period is higher than 10% drift_threshold_after_rest = 10 + # For now, make sure this test is executed alone + used_cpus = 100 + - stress_boot: install setup type = stress_boot
@@ -122,6 +130,9 @@ variants: kill_vm_vm1 = no kill_vm_gracefully = no extra_params += " -snapshot" + used_cpus = 5 + used_mem = 2560 + - autoit: install setup type = autoit
@@ -132,7 +143,7 @@ variants: - notepad: autoit_script = autoit/notepad1.au3 - - nic_hotplug: + - nic_hotplug: install setup type = pci_hotplug pci_type = nic modprobe_acpiphp = no
@@ -151,7 +162,7 @@ variants: pci_model = e1000 match_string = "Gigabit Ethernet Controller" - - block_hotplug: + - block_hotplug: install setup type = pci_hotplug pci_type = block reference_cmd = lspci
@@ -641,6 +652,9 @@ variants: - @up: - smp2: extra_params += " -smp 2" + used_cpus = 2 + stress_boot: used_cpus = 10 + timedrift: used_cpus = 100 variants:
Signature · 1 line
1.6.2.5