Skip to content

Commit

Permalink
client tests: Introduce libvirt_tck wrapper
Browse files Browse the repository at this point in the history
    This is an autotest wrapper based on the released
    TCK version 0.1.0.

     *Sys-Virt-TCK-v0.1.0.tar.gz  libvirt-tck tarball
     *control
     *default.cfg
     *ks.cfg
     *libvirt_tck.py
     *testcase.cfg

Signed-off-by: Guannan Ren <[email protected]>
  • Loading branch information
Guannan Ren committed Mar 8, 2012
1 parent becac34 commit 2b5c441
Show file tree
Hide file tree
Showing 6 changed files with 442 additions and 0 deletions.
Binary file added libvirt_tck/Sys-Virt-TCK-v0.1.0.tar.gz
Binary file not shown.
47 changes: 47 additions & 0 deletions libvirt_tck/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
AUTHOR = "Daniel Berrange <[email protected]>"
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)
162 changes: 162 additions & 0 deletions libvirt_tck/default.cfg
Original file line number Diff line number Diff line change
@@ -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
)

29 changes: 29 additions & 0 deletions libvirt_tck/ks.cfg
Original file line number Diff line number Diff line change
@@ -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
114 changes: 114 additions & 0 deletions libvirt_tck/libvirt_tck.py
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
"""
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)
Loading

0 comments on commit 2b5c441

Please sign in to comment.