Index: client/tests/kvm/migration_control.srv |
diff --git a/client/tests/kvm/migration_control.srv b/client/tests/kvm/migration_control.srv |
new file mode 100644 |
index 0000000000000000000000000000000000000000..16ada361d07102b0afc3684d2e2423e4feca617a |
--- /dev/null |
+++ b/client/tests/kvm/migration_control.srv |
@@ -0,0 +1,122 @@ |
+AUTHOR = "Yolkfull Chow <yzhou@redhat.com>" |
+TIME = "SHORT" |
+NAME = "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 |
+ |
+# 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' |
+ |
+# Make possible to import the KVM test APIs |
+KVM_DIR = os.path.join(AUTOTEST_DIR, 'client/tests/kvm') |
+sys.path.append(KVM_DIR) |
+ |
+import common, kvm_config |
+ |
+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 |
+ cfg = kvm_config.config() |
+ 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.13.64 |
+only migrate_multi_host |
+nic_mode = tap |
+nic_mac_nic1 = %s |
+""" % (generate_mac_address()) |
+ cfg.fork_and_parse(cfg_file, test_variants) |
+ test_dicts = cfg.get_list() |
+ |
+ 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) |