-
Notifications
You must be signed in to change notification settings - Fork 0
KVM & Libvirt Autotest Introduction and Quickstart
KVM-autotest is a suite of tests for the autotest client, which directly exercise the lower-level qemu binaries. Libvirt-autotest, while very similar in many respects, relies on the higher-level virsh, and virt-install utilities. The majority of KVM-autotest documentation also applies to libvirt-autotest, though there are some differences.
Within a full-blown production testing grid, an autotest-server takes care of provisioning client systems and establishing operating environments. Many GNU/Linux distributions can be used as a server or client, however this guide and the default test-set assumes the autotest client is running on a Fedora system. It's highly recommended to begin with a fresh, defaults-based, install.
-
The following commands will ensure needed software is available:
[root@localhost ~]# yum groupinstall -y "Development Libraries" "Development Tools" "Virtualization" "Virtualization Client" "Virtualization Tool ...
[root@localhost ~]# yum install -y dnsmasq genisoimage python-imaging gdb boost-devel glibc-devel libvirt python-devel ntpdate gstreamer-plugins-good gstreamer-python ...
-
If you don't have grubby 8.11, you will need additional -devel packages:
[root@localhost ~]# yum install -y libblkid-devel popt-devel boost-devel
-
Next, download and install autotest. For example, use git to clone the latest version under
/usr/local
:[root@localhost ~]# git clone git://github.com/autotest/autotest.git /usr/local/autotest Initialized empty Git repository in /usr/local/autotest/.git/ ...
-
The top-level directory contains all the server components, and a
client
subdirectory. -
Within the
client
subdirectory, there are two helper scripts to assist with setting up and verifying your environment:-
- kvm autotest:
-
client/tests/kvm/get_started.py
-
- libvirt autotest:
-
client/tests/libvirt/get_started.py
-
-
You may run them as many times as necessary to setup or verify the client environment. For example::
[root@localhost client]# tests/libvirt/get_started.py 16:16:49 INFO | libvirt test config helper 16:16:49 INFO | 16:16:49 INFO | 1 - Verifying directories (check if the directory structure expected by the default test config is there) 16:16:49 DEBUG| Creating /tmp/libvirt_autotest_root/images 16:16:49 DEBUG| Creating /tmp/libvirt_autotest_root/isos 16:16:49 DEBUG| Creating /tmp/libvirt_autotest_root/steps_data 16:16:49 INFO | 16:16:49 INFO | 2 - Creating config files from samples (copy the default config samples to actual config files) 16:16:49 DEBUG| Config file /usr/local/autotest/client/tests/libvirt/tests.cfg exists, not touching 16:16:49 DEBUG| Config file /usr/local/autotest/client/tests/libvirt/build.cfg exists, not touching 16:16:49 DEBUG| Config file /usr/local/autotest/client/tests/libvirt/cdkeys.cfg exists, not touching 16:16:49 DEBUG| Config file /usr/local/autotest/client/tests/libvirt/base.cfg exists, not touching 16:16:49 DEBUG| Config file /usr/local/autotest/client/tests/libvirt/guest-hw.cfg exists, not touching 16:16:49 DEBUG| Creating config file /usr/local/autotest/client/tests/libvirt/subtests.cfg from sample 16:16:49 DEBUG| Config file /usr/local/autotest/client/tests/libvirt/virtio-win.cfg exists, not touching 16:16:49 DEBUG| Creating config file /usr/local/autotest/client/tests/libvirt/guest-os.cfg from sample 16:16:49 INFO | 16:16:49 INFO | 3 - Verifying iso (make sure we have the OS ISO needed for the default test set) 16:16:49 WARNI| File /tmp/libvirt_autotest_root/isos/linux/Fedora-16-x86_64-DVD.iso not found 16:16:49 WARNI| Expected SHA1 sum: 76dd59c37e9a0ec2af56263fa892ff571c92c89a 16:16:49 INFO | Would you like to download it from http://download.fedoraproject.org/pub/fedora/linux/releases/16/Fedora/x86_64/iso/Fedora-16-x86_64-DVD.iso? (y/n) n 16:16:53 WARNI| Missing file /tmp/libvirt_autotest_root/isos/linux/Fedora-16-x86_64-DVD.iso 16:16:53 WARNI| Please download it or put an exsiting copy on the appropriate location 16:16:53 INFO | 16:16:53 INFO | 4 - Verifying winutils.iso (make sure we have the utility ISO needed for Windows testing) 16:16:53 INFO | In order to run the KVM autotests in Windows guests, we provide you an ISO that this script can download 16:16:53 WARNI| File /tmp/libvirt_autotest_root/isos/windows/winutils.iso not found 16:16:53 WARNI| Expected SHA1 sum: 02930224756510e383c44c49bffb760e35d6f892 16:16:53 INFO | Would you like to download it from http://people.redhat.com/mrodrigu/kvm/winutils.iso? (y/n) n 16:16:55 WARNI| Missing file /tmp/libvirt_autotest_root/isos/windows/winutils.iso 16:16:55 WARNI| Please download it or put an exsiting copy on the appropriate location 16:16:55 INFO | 16:16:55 INFO | 5 - Checking if the appropriate userspace programs are installed 16:16:55 DEBUG| /usr/bin/virt-install present 16:16:55 INFO | If you wish to change any userspace program path, you will have to modify tests.cfg 16:16:55 INFO | 16:16:55 INFO | When you are done fixing eventual warnings found, you can run the test using this command line AS ROOT: 16:16:55 INFO | /usr/local/autotest/client/bin/autotest /usr/local/autotest/client/tests/libvirt/control 16:16:55 INFO | Autotest prints the results dir, so you can look at DEBUG logs if something went wrong 16:16:55 INFO | You can also edit the test config files
- Note:
- For KVM autotest, the base root directory would be
/tmp/kvm_autotest_root/
- Only non-existent configuration files were copied over from their
.sample.cfg
source. i.e. none of my customizations were overwritten. - I answered "no" to the image downloads
- I already have my images on an NFS export, I'll symlink them into
/tmp/libvirt_autotest_root/isos/linux/
afterward. - I'm not going to do any windows testing, so I did not download
winutils.iso
- I already have my images on an NFS export, I'll symlink them into
- For KVM autotest, the base root directory would be
- Note:
-
Once the
get_started.py
script(s) run without any warnings or errors, the default test may be executed.- kvm autotest:
-
[root@localhost ~]# cd /usr/local/autotest/client [root@localhost client]# bin/autotest run kvm ...
- libvirt autotest:
-
[root@localhost ~]# cd /usr/local/autotest/client [root@localhost client]# bin/autotest run libvirt ...
-
Both KVM and libvirt default test includes a guest installation test, a reboot test, and a shutdown test.
-
Test status is written into the file `` client/results/default/status``.
-
A debug log is written to the file
client/results/default/debug/client.DEBUG
-
There are configuration files, but for simple testing it's often easier to adjust the environment.
- If you bungle one up, just remove it and re-run the corresponding
get_started.py
- The most valuable configuration files are:
-
client/tests/{libvirt,kvm}/base.cfg
defines many default parameters -
client/tests/{libvirt,kvm}/tests.cfg
specifies tests to execute and defaults to override.
-
- If you bungle one up, just remove it and re-run the corresponding
-
Testing and/or cleanup will continue even after failures occur.
-
If something goes wrong, it's good to find and fix the earliest problem identified in the logs first.
-
Ran both kvm and libvirt get_started.py, but forgot to symlink my guest OS iso image to
/tmp/kvm_autotest_root/isos/linux/Fedora-16-x86_64-DVD.iso
[root@localhost ~]# cd /usr/local/autotest/client [root@localhost client]# bin/autotest run kvm 18:23:27 INFO | Writing results to /usr/local/autotest/client/results/default 18:23:27 INFO | START ---- ---- timestamp=1327533807 localtime=Jan 25 18:23:27 18:23:27 INFO | Test 1: smp2.Fedora.16.64.unattended_install.cdrom 18:23:27 INFO | Test 2: smp2.Fedora.16.64.boot 18:23:27 INFO | Test 3: smp2.Fedora.16.64.shutdown 18:23:27 ERROR| Command kvm_stat not present 18:23:27 INFO | START kvm.smp2.Fedora.16.64.unattended_install.cdrom kvm.smp2.Fedora.16.64.unattended_install.cdrom timestamp=1327533807 localtime=Jan 25 18:23:27 18:23:27 WARNI| Could not import json module. QMP monitor functionality disabled. 18:23:28 ERROR| Asked for kvm_stat profiler, but kvm_stat not present 18:23:28 INFO | Starting unattended install setup 18:23:28 ERROR| Test failed: CmdError: Command <mount -t iso9660 -v -o loop,ro /tmp/kvm_autotest_root/isos/linux/Fedora-16-x86_64-DVD.iso /usr/local/autotest/client/tmp/tmpAQtlG0_kvm.smp2.Fedora.16.64.unattended_install.cdrom/cdrom_cd1_BqYlqr> failed, rc=32, Command returned non-zero exit status [context: (run_unattended_install) --> Copying vmlinuz and initrd.img from install cdrom /tmp/kvm_autotest_root/isos/linux/Fedora-16-x86_64-DVD.iso] * Command: mount -t iso9660 -v -o loop,ro /tmp/kvm_autotest_root/isos/linux/Fedora-16-x86_64-DVD.iso /usr/local/auto test/client/tmp/tmpAQtlG0_kvm.smp2.Fedora.16.64.unattended_install.cdrom/c drom_cd1_BqYlqr Exit status: 32 Duration: 0.0095329284668
-
Ran out of disk space on /tmp where default guest image is sparse allocated at
10GB
[root@localhost ~]# cd /usr/local/autotest/client [root@localhost client]# bin/autotest run kvm 18:39:30 INFO | Writing results to /usr/local/autotest/client/results/default 18:39:30 INFO | START ---- ---- timestamp=1327534770 localtime=Jan 25 18:39:30 18:39:30 INFO | Test 1: smp2.Fedora.16.64.unattended_install.cdrom 18:39:30 INFO | Test 2: smp2.Fedora.16.64.boot 18:39:30 INFO | Test 3: smp2.Fedora.16.64.shutdown 18:39:30 ERROR| Command kvm_stat not present 18:39:30 INFO | START kvm.smp2.Fedora.16.64.unattended_install.cdrom kvm.smp2.Fedora.16.64.unattended_install.cdrom timestamp=1327534770 localtime=Jan 25 18:39:30 18:39:30 ERROR| ** Message: pygobject_register_sinkfunc is deprecated (GstObject) 18:39:30 ERROR| Asked for kvm_stat profiler, but kvm_stat not present 18:39:31 INFO | Starting unattended install setup 18:39:33 INFO | Running qemu command: /usr/bin/qemu-kvm -name 'vm1' -nodefaults -vga std -monitor unix:'/tmp/monitor-humanmonitor1-20120125-183931-Cmpn',server,nowait -serial unix:'/tmp/serial-20120125-183931-Cmpn',server,nowait -device ich9-usb-uhci1,id=usb1 -drive file='/tmp/kvm_autotest_root/images/f16-64.qcow2',index=0,if=ide,cache=none -device rtl8139,netdev=id2nkzGl,mac='9a:b5:bb:48:79:88',id='idchBTQ8' -netdev tap,id=id2nkzGl,fd=21 -m 1024 -smp 2 -drive file='/tmp/kvm_autotest_root/isos/linux/Fedora-16-x86_64-DVD.iso',media=cdrom,index=2 -drive file='/tmp/kvm_autotest_root/images/f16-64/ks.iso',media=cdrom,index=1 -device usb-tablet,id=usb-tablet1,bus=usb1.0 -kernel '/tmp/kvm_autotest_root/images/f16-64/vmlinuz' -initrd '/tmp/kvm_autotest_root/images/f16-64/initrd.img' -vnc :0 --append 'ks=cdrom nicdelay=60 console=ttyS0,115200 console=tty0' -boot d 18:39:34 INFO | Waiting for installation to finish. Timeout set to 3000 s (50 min) 19:29:37 ERROR| Test failed: TestFail: Timeout elapsed while waiting for install to finish [context: waiting for installation to finish]
-
Problems during an unattended install can be observed in the movie generated for you. For example:
client/results/default/kvm.smp2.Fedora.16.64.unattended_install.cdrom/debug/vm1-1.ogg
-
-
If a python traceback appears, it can be an indication that a needed package isn't installed.
-
When that's not the traceback cause, most likely something in the environment doesn't match the configuration.