diff --git a/libvirt_tck/Sys-Virt-TCK-v0.1.0.tar.gz b/libvirt_tck/Sys-Virt-TCK-v0.1.0.tar.gz new file mode 100644 index 000000000..df23ff68c Binary files /dev/null and b/libvirt_tck/Sys-Virt-TCK-v0.1.0.tar.gz differ diff --git a/libvirt_tck/control b/libvirt_tck/control new file mode 100644 index 000000000..6d3aac61b --- /dev/null +++ b/libvirt_tck/control @@ -0,0 +1,47 @@ +AUTHOR = "Daniel Berrange " +DOC = """ +The libvirt TCK provides a framework for performing testing +of the integration between libvirt drivers, the underlying virt +hypervisor technology, related operating system services and system +configuration. + +Thus the libvirt TCK will allow developers, administrators and users +to determine the level of compatability of their platform, and +evaluate whether it will meet their needs, and get awareness of any +regressions that may have occurred since a previous test run +""" + +TIME="MEDIUM" +NAME = 'libvirt_tck' +TEST_CLASS = 'Virtualization' +TEST_TYPE= 'client' +TEST_CATEGORY = 'Regresstion' + +import os + +os.environ['LANG'] = 'en_US.UTF-8' + +libvirt_tck_dir = os.path.join(os.environ['AUTODIR'],'tests/libvirt_tck') + +def get_case_item(casefile): + if not os.path.exists(casefile): + return + + case_items = [] + fh = open(casefile, "r") + for eachLine in fh: + line = eachLine.strip() + if not line or line[0].isdigit() or line.startswith('#'): + continue + + item = line[:-1] + case_items.append(item) + + fh.close() + return case_items + +testcase_conf = os.path.join(libvirt_tck_dir, 'testcase.cfg') +item_list = get_case_item(testcase_conf) + +for item in item_list: + job.run_test('libvirt_tck', item=item, tag=item) diff --git a/libvirt_tck/default.cfg b/libvirt_tck/default.cfg new file mode 100644 index 000000000..345fa3e0d --- /dev/null +++ b/libvirt_tck/default.cfg @@ -0,0 +1,162 @@ +# +# Which driver to test. If not set, then driver is +# auto probed +uri = "qemu:///system" +#uri = "xen:///" +#uri = "qemu:///session" + +# +# To enable migration tests, set 'otheruri' to a URI +# that the local libvirtd can use to connect to a +# remote libvirtd. +# +# NB: You must *ALSO* ensure that 'scratch_dir' is +# pointing to an NFS filesystem shared between the +# local host and the remote libvirtd. +#otheruri = "qemu+ssh://otherhostname/system" + +# Override directory used for downloading/creating temporary files +# +# A minimum of 1 GB of free space is required on this +# directory. +# +# Defaults to /var/cache/libvirt-tck for root, or `pwd`/libvirt-tck for non-root +#scratch_dir = /var/cache/libvirt-tck + +# To avoid filling the filesystem, the test suite will +# automatically set a usage limit of +# +# freespace(scratch_dir) - 500 MB +# +# The test suite will abort if it thinks it will exceed +# the limit. +# +# If you want to set a artificially lower usage limit... +#scratch_usage_limit = 10G + +# Kickstart file used for installing a temp guest for +# the nwfilter tests. Tweak this if you have a local +# Fedora mirror you wish to use instead of downloading +# over the interwebs +ks = /etc/libvirt-tck/ks.cfg + +# +# Where the kernel/initrd files needed by tests are to be +# found. These can be URLS or local file paths. +# +# The test suite auto-downloads any URLs, but some of the files +# can be rather large so you may wish to download them ahead of +# time and change this config to point to local files +# +# The particular OS doesn't really matter - all the test +# suite currently needs is a kernel that doesn't crash +# upon boot. It doesn't actually need todo anything useful +# +# ...yet... +# +# So even if running on a Debian host, you'll not see any +# problem letting it grab the Fedora kernels +# +# If the kernel requires a special root filesystem then +# that can be listed instead of the initrd. Otherwise a +# empty sparse root FS will be created +# +kernels = ( + # Fedora 15 i686 PAE has pv_ops, so one kernel can do both Xen and KVM guests here + { + arch = i686 + ostype = ( + hvm + xen + ) + kernel = http://dl.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/i386/os/images/pxeboot/vmlinuz-PAE + initrd = http://dl.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/i386/os/images/pxeboot/initrd-PAE.img + } + # Fedora 15 x86_64 has pv_ops, so one kernel can do both Xen and KVM guests here + { + arch = x86_64 + ostype = ( + hvm + xen + ) + kernel = http://dl.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/x86_64/os/images/pxeboot/vmlinuz + initrd = http://dl.fedoraproject.org/pub/fedora/linux/releases/15/Fedora/x86_64/os/images/pxeboot/initrd.img + } + # User mode linux i686 needs custom kernel + root filesystem + { + arch = i686 + ostype = uml + kernel = { + source = http://user-mode-linux.sourceforge.net/linux-2.6.24-rc7.bz2 + uncompress = bzip2 + } + disk = { + source = http://fs.devloop.org.uk/filesystems/Fedora13/Fedora13-x86-root_fs.bz2 + uncompress = bzip2 + } + } + # User mode linux x86_64 needs custom kernel + root filesystem + { + arch = x86_64 + ostype = uml + kernel = { + source = http://user-mode-linux.sourceforge.net/linux-2.6.24-x86_64.bz2 + uncompress = bzip2 + } + disk = { + source = http://fs.devloop.org.uk/filesystems/Fedora13/Fedora13-AMD64-root_fs.bz2 + uncompress = bzip2 + } + } + # LXC containers need a virtual container filesystem somewhere +# { +# arch = x86_64 +# ostype = exe +# } +) + +# Host USB devices that the test suite can safely mess around with +# without risk of breaking the host OS +host_usb_devices = ( +# Must list either vendor+product, or bus+dev, or both +# { +# vendor = 0x0627 +# product = 0x0001 +# bus = 001 +# device = 002 +# } +# Can list more than one USB device if many are available +) + + +# Host PCI devices that the test suite can safely mess around with +# without risk of breaking the host OS. Using a NIC device is the +# most reliable option. Definitely don't try listing a VGA device. +host_pci_devices = ( +# Slot is only required entry, all others default to 0 +# { +# domain = 0000 +# bus = 00 +# slot = 07 +# function = 0 +# } +# Can list more than one PCI device if many are available +) + +# List of host block devices that the test suite can trash all +# data on, for purposes of testing. You have been warned ! +# Only full block devices allowed, no single partitions, since +# the test suite itself needs to create partitions. +# The disks should be at *least* 512 MB in size +host_block_devices = ( +# Each block device is either a raw path +# /dev/vdb +# or a path plus size in 1k blocks, as in /proc/partitions, to avoid +# trashing the wrong device +# { +# path = /dev/disk/by-id/usb-Generic_Flash_Disk_9B46E3C5-0:0 +# size = 989184 +# } +# Can list more than on block device if many are available +) + diff --git a/libvirt_tck/ks.cfg b/libvirt_tck/ks.cfg new file mode 100644 index 000000000..b40e10329 --- /dev/null +++ b/libvirt_tck/ks.cfg @@ -0,0 +1,29 @@ +install +text +url --url=http://ftp-stud.hs-esslingen.de/Mirrors/fedora.redhat.com/linux/releases/16/Fedora/x86_64/os/ +lang en_US.UTF-8 +keyboard de-latin1-nodeadkeys +network --device eth0 --bootproto dhcp +rootpw --iscrypted $6$AHEMvpa2rx3n/DON$toWNA/ainpreIRC1g2L9yuil7bS.2hIf8DomTluFGulQtN3KstPeVrmwFMhkwhsW7ud7DANsWycGEL5ZOU50e. +firewall --service=ssh +authconfig --enableshadow --passalgo=sha512 --enablefingerprint +selinux --enforcing +timezone --utc Europe/Berlin +bootloader --location=mbr --driveorder=vda --append=" LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rhgb quiet" +# The following is the partition information you requested +# Note that any partitions you deleted are not expressed +# here so unless you clear all partitions first, this is +# not guaranteed to work +clearpart --all --drives=vda --initlabel + +part /boot --fstype=ext4 --size=200 +part swap --grow --maxsize=256 --asprimary --size=1 +part / --fstype=ext3 --grow --size=200 + +poweroff + +%packages +@admin-tools +@base +@core +@hardware-support diff --git a/libvirt_tck/libvirt_tck.py b/libvirt_tck/libvirt_tck.py new file mode 100644 index 000000000..452ae92dc --- /dev/null +++ b/libvirt_tck/libvirt_tck.py @@ -0,0 +1,114 @@ +import os, re, shutil, logging + +from autotest_lib.client.common_lib import error +from autotest_lib.client.bin import utils, test + + +class libvirt_tck(test.test): + """ + Autotest wrapper for the libvirt Technology Compatibility toolkit. + + The libvirt TCK provides a framework for performing testing + of the integration between libvirt drivers, the underlying virt + hypervisor technology, related operating system services and system + configuration. The idea (and name) is motivated by the Java TCK. + + @see: git clone git://libvirt.org/libvirt-tck.git + @author: Daniel Berrange + """ + version = 1 + TESTDIR = '/usr/share/libvirt-tck/tests' + + def setup(self, tarball='Sys-Virt-TCK-v0.1.0.tar.gz'): + # The absence of Module::Build will hange up the testing + try: + utils.system('perl -MModule::Build -e 1') + except error.CmdError, e: + raise error.TestError("Module::Build is required") + + # Install cpanminus script + try: + utils.system('(curl -L http://cpanmin.us | perl - App::cpanminus)2>&1') + except error.CmdError, e: + raise error.TestError("Failed to install cpanminus script.") + + tarpath = utils.unmap_url(self.bindir, tarball) + utils.extract_tarball_to_dir(tarpath, self.srcdir) + os.chdir(self.srcdir) + + output = utils.system_output('perl Makefile.PL 2>&1', retain_output=True) + + required_mods = list(set(re.findall("[^ ']*::[^ ']*", output))) + + # Resolve perl modules dependencies + if required_mods: + for mod in required_mods: + ret = utils.system('cpanm %s 2>&1' % mod) + if ret != 0: + raise error.TestError("Failed to install module %s" % mod) + + utils.system('make') + utils.system('make test') + utils.system('make install') + + def get_testcases(self, testcasecfg, item): + flag = 0 + testcases = [] + fh = open(testcasecfg, "r") + for eachLine in fh: + line = eachLine.strip() + + if line.startswith('#'): + continue + + if flag == 0 and not line: + continue + + if item == line[:-1]: + flag = 1 + continue + + if flag == 1 and not line: + flag = 0 + break + + if flag == 1 and line[0].isdigit(): + testcases.append(line) + continue + + fh.close() + return testcases + + def run_once(self, item=None): + failed_tests = [] + if item is None: + raise error.TestError("No item provided") + + default_cfg = os.path.join(self.bindir, 'default.cfg') + ks_cfg = os.path.join(self.bindir, 'ks.cfg') + + testcase_cfg = os.path.join(self.bindir, 'testcase.cfg') + item_path = os.path.join(self.TESTDIR, item) + testcases = self.get_testcases(testcase_cfg, item) + + shutil.copyfile(ks_cfg, '/etc/libvirt-tck/ks.cfg') + + logging.debug("Available testcases for item %s: %s", item, testcases) + + output = os.path.join(self.resultsdir, 'libvirt_tck_%s.tap' % item) + for testcase in testcases: + testcase_path = os.path.join(item_path, testcase) + os.environ['LIBVIRT_TCK_CONFIG'] = default_cfg + t_cmd = ('perl %s' % testcase_path) + try: + try: + t_output = open(output, 'a+') + cmd_result = utils.run(t_cmd, stdout_tee=t_output, + stderr_tee=t_output) + finally: + t_output.close() + except error.CmdError: + failed_tests.append(testcase) + + if failed_tests: + raise error.TestFail('FAIL: %s' % failed_tests) diff --git a/libvirt_tck/testcase.cfg b/libvirt_tck/testcase.cfg new file mode 100644 index 000000000..bf4913781 --- /dev/null +++ b/libvirt_tck/testcase.cfg @@ -0,0 +1,90 @@ +# This is the testcase config file. +# Commenting out the testcase item name will ignore the whole testcases under it. +# For example "#domain:" will skip all testcases from "050-transient-lifecycle.t" to "300-migration.t" +# Commenting out specific testcase is done by putting "#" at the beginning of the line. +# The order of testcases listed below represents the executed order of these testcases, +# Please ensure at least one blank line between two blocks of testcase items. + +domain: +050-transient-lifecycle.t +051-transient-autostart.t +060-persistent-lifecycle.t +061-persistent-autostart.t +065-persistent-redefine.t +070-transient-to-persistent.t +080-unique-id-define.t +081-unique-id-create.t +082-unique-id-caching.t +090-invalid-ops-when-inactive.t +100-transient-save-restore.t +101-persistent-save-restore.t +102-broken-save-restore.t +103-blockdev-save-restore.t +120-disks-stats.t +130-cpu-hotplug.t +200-disk-hotplug.t +#205-disk-hotplug-ordering.t +207-disk-media-change.t +210-nic-hotplug.t +215-nic-hotplug-many.t +240-usb-host-hotplug.t +250-pci-host-hotplug.t +300-migration.t + +#hooks: +051-daemon-hook.t +052-domain-hook.t + +networks: +050-transient-lifecycle.t +051-transient-autostart.t +060-persistent-lifecycle.t +061-persistent-autostart.t +065-persistent-redefine.t +070-transient-to-persistent.t +080-unique-id-define.t +081-unique-id-create.t +082-unique-id-caching.t +090-invalid-ops-when-inactive.t +100-apply-verify-host.t + +#nwfilter: +050-apply-verify-host.t +060-concurrency.t +090-install-image.t +100-ping-still-working.t +210-no-mac-spoofing.t +220-no-ip-spoofing.t +230-no-mac-broadcast.t +240-no-arp-spoofing.t +300-vsitype.t + +qemu: +100-disk-encryption.t +200-qcow2-single-backing-file.t +#205-qcow2-double-backing-file.t +210-qcow2-auto-probing.t + +#selinux: +050-dynamic-relabel-yes.t +055-dynamic-base-label.t +100-static-relabel-no.t +105-static-relabel-fail.t +110-static-relabel-yes.t + +storage: +050-transient-lifecycle.t +051-transient-autostart.t +060-persistent-lifecycle.t +061-persistent-autostart.t +065-persistent-redefine.t +070-transient-to-persistent.t +080-unique-id-define.t +081-unique-id-create.t +082-unique-id-caching.t +090-invalid-ops-when-inactive.t +100-create-vol-dir.t +110-disk-pool.t +200-clone-vol-dir.t +250-vol-qcow2-backing-store.t +255-vol-qcow2-backing-store-auto.t