We had migration_control.srv which worked with old version of kvm config files (tests.cfg, subtest.cfg, etc..). Because config files were changed this control code stopped working. This patch repairs this problem and renames the file to the more correct and generic name multi-host.srv. Also, added new configuration file tests-shared.cfg which contains shared data among single host and multi host tests. The changes are useful for multihost tests, since we can use a lot of configuration from regular single host tests. Signed-off-by: Jiří Župka <jzupka@xxxxxxxxxx> --- client/tests/kvm/migration_control.srv | 123 -------------------------- client/tests/kvm/multi-host-tests.cfg.sample | 43 +++++++++ client/tests/kvm/multi_host.srv | 106 ++++++++++++++++++++++ client/tests/kvm/tests-shared.cfg.sample | 48 ++++++++++ client/tests/kvm/tests.cfg.sample | 43 +--------- 5 files changed, 198 insertions(+), 165 deletions(-) delete mode 100644 client/tests/kvm/migration_control.srv create mode 100644 client/tests/kvm/multi-host-tests.cfg.sample create mode 100644 client/tests/kvm/multi_host.srv create mode 100644 client/tests/kvm/tests-shared.cfg.sample diff --git a/client/tests/kvm/migration_control.srv b/client/tests/kvm/migration_control.srv deleted file mode 100644 index c669ccd..0000000 --- a/client/tests/kvm/migration_control.srv +++ /dev/null @@ -1,123 +0,0 @@ -AUTHOR = "Yolkfull Chow <yzhou@xxxxxxxxxx>" -TIME = "SHORT" -NAME = "KVM Test (migration across multiple hosts)" -TEST_CATEGORY = "Functional" -TEST_CLASS = "Virtualization" -TEST_TYPE = "Server" -DOC = """ -Migrate KVM guest between two hosts. It parses the base config file, restricts -it with appropriate parameters, generates the test dicts, modify the test_dicts -so there's a distinction between the migration roles ('dest' or 'source'). -""" - -import sys, os, commands, glob, shutil, logging, random -from autotest_lib.server import utils -from autotest_lib.client.common_lib import cartesian_config - -# Specify the directory of autotest before you start this test -AUTOTEST_DIR = '/usr/local/autotest' - -# Specify the root directory that on client machines -rootdir = '/tmp/kvm_autotest_root' - -KVM_DIR = os.path.join(AUTOTEST_DIR, 'client/tests/kvm') - - -def generate_mac_address(): - r = random.SystemRandom() - mac = "9a:%02x:%02x:%02x:%02x:%02x" % (r.randint(0x00, 0xff), - r.randint(0x00, 0xff), - r.randint(0x00, 0xff), - r.randint(0x00, 0xff), - r.randint(0x00, 0xff)) - return mac - - -def run(pair): - logging.info("KVM migration running on source host [%s] and destination " - "host [%s]\n", pair[0], pair[1]) - - source = hosts.create_host(pair[0]) - dest = hosts.create_host(pair[1]) - source_at = autotest.Autotest(source) - dest_at = autotest.Autotest(dest) - - cfg_file = os.path.join(KVM_DIR, "tests_base.cfg") - - if not os.path.exists(cfg_file): - raise error.JobError("Config file %s was not found", cfg_file) - - # Get test set (dictionary list) from the configuration file - parser = cartesian_config.Parser() - test_variants = """ -image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/ -cdrom(_.*)? ?<= /tmp/kvm_autotest_root/ -floppy ?<= /tmp/kvm_autotest_root/ -Linux: - unattended_install: - kernel ?<= /tmp/kvm_autotest_root/ - initrd ?<= /tmp/kvm_autotest_root/ -qemu_binary = /usr/libexec/qemu-kvm -qemu_img_binary = /usr/bin/qemu-img -only qcow2 -only virtio_net -only virtio_blk -only smp2 -only no_pci_assignable -only smallpages -only Fedora.14.64 -only migrate_multi_host -nic_mode = tap -nic_mac_nic1 = %s -""" % (generate_mac_address()) - parser.parse_file(cfg_file) - parser.parse_string(test_variants) - test_dicts = parser.get_dicts() - - source_control_file = dest_control_file = """ -kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests/kvm') -sys.path.append(kvm_test_dir)\n -""" - for params in test_dicts: - params['srchost'] = source.ip - params['dsthost'] = dest.ip - params['rootdir'] = rootdir - - source_params = params.copy() - source_params['role'] = "source" - - dest_params = params.copy() - dest_params['role'] = "destination" - dest_params['migration_mode'] = "tcp" - - # Report the parameters we've received - print "Test parameters:" - keys = params.keys() - keys.sort() - for key in keys: - logging.debug(" %s = %s", key, params[key]) - - source_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % - (source_params['shortname'], source_params)) - dest_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % - (dest_params['shortname'], dest_params)) - - logging.info('Source control file:\n%s', source_control_file) - logging.info('Destination control file:\n%s', dest_control_file) - dest_command = subcommand(dest_at.run, - [dest_control_file, dest.hostname]) - - source_command = subcommand(source_at.run, - [source_control_file, source.hostname]) - - parallel([dest_command, source_command]) - -# Grab the pairs (and failures) -(pairs, failures) = utils.form_ntuples_from_machines(machines, 2) - -# Log the failures -for failure in failures: - job.record("FAIL", failure[0], "kvm", failure[1]) - -# Now run through each pair and run -job.parallel_simple(run, pairs, log=False) diff --git a/client/tests/kvm/multi-host-tests.cfg.sample b/client/tests/kvm/multi-host-tests.cfg.sample new file mode 100644 index 0000000..17a41e3 --- /dev/null +++ b/client/tests/kvm/multi-host-tests.cfg.sample @@ -0,0 +1,43 @@ +# Copy this file to multi-host-tests.cfg and edit it. +# +# This file contains the test set definitions for multi host tests. + +# Include the shared test files. +include tests-shared.cfg + +# Here are the test sets variants. The variant 'qemu_kvm_windows_quick' is +# fully commented, the following ones have comments only on noteworthy points +variants: + # Runs qemu-kvm, Windows Vista 64 bit guest OS, install, boot, shutdown + - @qemu_migrate_multi_host: + qemu_binary = /usr/bin/qemu-kvm + qemu_img_binary = /usr/bin/qemu-img + qemu_io_binary = /usr/bin/qemu-io + nic_mode = tap + only qcow2 + only virtio_net + only virtio_blk + only smp2 + only no_pci_assignable + only no_9p_export + only smallpages + only Fedora.15.64 + only migrate_multi_host + + # Runs qemu, f16 64 bit guest OS, install, boot, shutdown + - @qemu_cpuflags_multi_host: + qemu_binary = /usr/bin/qemu-kvm + qemu_img_binary = /usr/bin/qemu-img + qemu_io_binary = /usr/bin/qemu-io + nic_mode = tap + only qcow2 + only virtio_net + only virtio_blk + only smp2 + only no_pci_assignable + only no_9p_export + only smallpages + only Fedora.15.64 + only cpuflags_multi_host + +only qemu_cpuflags_multi_host diff --git a/client/tests/kvm/multi_host.srv b/client/tests/kvm/multi_host.srv new file mode 100644 index 0000000..15acbb3 --- /dev/null +++ b/client/tests/kvm/multi_host.srv @@ -0,0 +1,106 @@ +AUTHOR = "Jiri Zupka <jzupka@xxxxxxxxxx>" +TIME = "SHORT" +NAME = "" +TEST_CATEGORY = "Functional" +TEST_CLASS = "Virtualization" +TEST_TYPE = "Server" +DOC = "KVM tests (multi-host) server control" +Runs tests across multiple hosts. It uses the config file +'multi-host-tests.cfg' in order to yield the appropriate +dicts for the multi host test. +""" + +import sys, os, commands, glob, shutil, logging, random +from autotest_lib.server import utils +from autotest_lib.client.common_lib import cartesian_config, error + +# Specify the directory of autotest before you start this test +AUTOTEST_DIR = job.clientdir + +KVM_DIR = os.path.join(AUTOTEST_DIR, 'tests', 'kvm') + + +def generate_mac_address(): + r = random.SystemRandom() + mac = "9a:%02x:%02x:%02x:%02x:%02x" % (r.randint(0x00, 0xff), + r.randint(0x00, 0xff), + r.randint(0x00, 0xff), + r.randint(0x00, 0xff), + r.randint(0x00, 0xff)) + return mac + + +def run(pair): + logging.info("KVM test running on source host [%s] and destination " + "host [%s]\n", pair[0], pair[1]) + + source = hosts.create_host(pair[0]) + dest = hosts.create_host(pair[1]) + source_at = autotest.Autotest(source) + dest_at = autotest.Autotest(dest) + + cfg_file = os.path.join(KVM_DIR, "multi-host-tests.cfg") + + if not os.path.exists(cfg_file): + raise error.JobError("Config file %s was not found", cfg_file) + + # Get test set (dictionary list) from the configuration file + parser = cartesian_config.Parser() + parser.parse_file(cfg_file) + test_dicts = parser.get_dicts() + + source_control_file = dest_control_file = """ +testname = "kvm" +bindir = os.path.join(job.testdir, testname) +job.install_pkg(testname, 'test', bindir) + +kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests', 'kvm') +sys.path.append(kvm_test_dir) +""" + import sys + + for params in test_dicts: + params['srchost'] = source.ip + params['dsthost'] = dest.ip + + for nic in params.get('nics',"").split(): + params['nic_mac_%s' % nic] = generate_mac_address() + + source_params = params.copy() + source_params['role'] = "source" + + dest_params = params.copy() + dest_params['role'] = "destination" + dest_params['migration_mode'] = "tcp" + + # Report the parameters we've received + print "Test parameters:" + keys = params.keys() + keys.sort() + for key in keys: + logging.debug(" %s = %s", key, params[key]) + + source_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % + (source_params['shortname'], source_params)) + dest_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % + (dest_params['shortname'], dest_params)) + + logging.info('Source control file:\n%s', source_control_file) + logging.info('Destination control file:\n%s', dest_control_file) + dest_command = subcommand(dest_at.run, + [dest_control_file, dest.hostname]) + + source_command = subcommand(source_at.run, + [source_control_file, source.hostname]) + + parallel([dest_command, source_command]) + +# Grab the pairs (and failures) +(pairs, failures) = utils.form_ntuples_from_machines(machines, 2) + +# Log the failures +for failure in failures: + job.record("FAIL", failure[0], "kvm", failure[1]) + +# Now run through each pair and run +job.parallel_simple(run, pairs, log=False) diff --git a/client/tests/kvm/tests-shared.cfg.sample b/client/tests/kvm/tests-shared.cfg.sample new file mode 100644 index 0000000..9de3b93 --- /dev/null +++ b/client/tests/kvm/tests-shared.cfg.sample @@ -0,0 +1,48 @@ +# Copy this file to tests-shared.cfg and edit it. +# +# This file contains the base test set definitions, shared among single host +# and multi host jobs. + +# Include the base config files. +include base.cfg +include subtests.cfg +include guest-os.cfg +include guest-hw.cfg +include cdkeys.cfg +include virtio-win.cfg + +# Virtualization type (kvm or libvirt) +# TODO: Update code to use vm_library + vm_type + vm_subtype +# i.e. (libvirt/none) + (qemu/kvm/xen) + (hvm/paravirt) +vm_type = kvm + +# Modify/comment the following lines if you wish to modify the paths of the +# image files, ISO files or qemu binaries. +# +# As for the defaults: +# * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm and +# /usr/bin/qemu-img respectively. +# * All image files are expected under /tmp/kvm_autotest_root/images/ +# * All install iso files are expected under /tmp/kvm_autotest_root/isos/ +# * The parameters cdrom_unattended, floppy, kernel and initrd are generated +# by KVM autotest, so remember to put them under a writable location +# (for example, the cdrom share can be read only) +image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/ +cdrom(_.*)? ?<= /tmp/kvm_autotest_root/ +floppy ?<= /tmp/kvm_autotest_root/ +Linux..unattended_install: + kernel ?<= /tmp/kvm_autotest_root/ + initrd ?<= /tmp/kvm_autotest_root/ + +# You may provide information about the DTM server for WHQL tests here: +#whql: +# server_address = 10.20.30.40 +# server_shell_port = 10022 +# server_file_transfer_port = 10023 +# Note that the DTM server must run rss.exe (available under deps/), +# preferably with administrator privileges. + +# Uncomment the following lines to enable abort-on-error mode: +#abort_on_error = yes +#kill_vm.* ?= no +#kill_unresponsive_vms.* ?= no diff --git a/client/tests/kvm/tests.cfg.sample b/client/tests/kvm/tests.cfg.sample index e03e007..c91a58b 100644 --- a/client/tests/kvm/tests.cfg.sample +++ b/client/tests/kvm/tests.cfg.sample @@ -3,17 +3,7 @@ # This file contains the test set definitions. Define your test sets here. # Include the base config files. -include base.cfg -include subtests.cfg -include guest-os.cfg -include guest-hw.cfg -include cdkeys.cfg -include virtio-win.cfg - -# Virtualization type (kvm or libvirt) -# TODO: Update code to use vm_library + vm_type + vm_subtype -# i.e. (libvirt/none) + (qemu/kvm/xen) + (hvm/paravirt) -vm_type = kvm +include tests-shared.cfg # Here you can override the image name for our custom linux and windows guests # @@ -36,24 +26,6 @@ CustomGuestWindows: #image_name = /dev/mapper/vg_windows_guest #image_raw_device = yes -# Modify/comment the following lines if you wish to modify the paths of the -# image files, ISO files or qemu binaries. -# -# As for the defaults: -# * qemu and qemu-img are expected to be found under /usr/bin/qemu-kvm and -# /usr/bin/qemu-img respectively. -# * All image files are expected under /tmp/kvm_autotest_root/images/ -# * All install iso files are expected under /tmp/kvm_autotest_root/isos/ -# * The parameters cdrom_unattended, floppy, kernel and initrd are generated -# by KVM autotest, so remember to put them under a writable location -# (for example, the cdrom share can be read only) -image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/ -cdrom(_.*)? ?<= /tmp/kvm_autotest_root/ -floppy ?<= /tmp/kvm_autotest_root/ -Linux..unattended_install: - kernel ?<= /tmp/kvm_autotest_root/ - initrd ?<= /tmp/kvm_autotest_root/ - # Here are the test sets variants. The variant 'qemu_kvm_windows_quick' is # fully commented, the following ones have comments only on noteworthy points variants: @@ -156,18 +128,5 @@ variants: only CustomGuestLinux only migrate -# You may provide information about the DTM server for WHQL tests here: -#whql: -# server_address = 10.20.30.40 -# server_shell_port = 10022 -# server_file_transfer_port = 10023 -# Note that the DTM server must run rss.exe (available under deps/), -# preferably with administrator privileges. - -# Uncomment the following lines to enable abort-on-error mode: -#abort_on_error = yes -#kill_vm.* ?= no -#kill_unresponsive_vms.* ?= no - # Choose your test list from the testsets defined only qemu_kvm_f16_quick -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html