| OLD | NEW |
| 1 AUTHOR = "Yolkfull Chow <yzhou@redhat.com>" | 1 AUTHOR = "Yolkfull Chow <yzhou@redhat.com>" |
| 2 TIME = "SHORT" | 2 TIME = "SHORT" |
| 3 NAME = "Migration across multiple hosts" | 3 NAME = "Migration across multiple hosts" |
| 4 TEST_CATEGORY = "Functional" | 4 TEST_CATEGORY = "Functional" |
| 5 TEST_CLASS = "Virtualization" | 5 TEST_CLASS = "Virtualization" |
| 6 TEST_TYPE = "Server" | 6 TEST_TYPE = "Server" |
| 7 DOC = """ | 7 DOC = """ |
| 8 Migrate KVM guest between two hosts. It parses the base config file, restricts | 8 Migrate KVM guest between two hosts. It parses the base config file, restricts |
| 9 it with appropriate parameters, generates the test dicts, modify the test_dicts | 9 it with appropriate parameters, generates the test dicts, modify the test_dicts |
| 10 so there's a distinction between the migration roles ('dest' or 'source'). | 10 so there's a distinction between the migration roles ('dest' or 'source'). |
| 11 """ | 11 """ |
| 12 | 12 |
| 13 import sys, os, commands, glob, shutil, logging, random | 13 import sys, os, commands, glob, shutil, logging, random |
| 14 from autotest_lib.server import utils | 14 from autotest_lib.server import utils |
| 15 from autotest_lib.client.common_lib import cartesian_config |
| 15 | 16 |
| 16 # Specify the directory of autotest before you start this test | 17 # Specify the directory of autotest before you start this test |
| 17 AUTOTEST_DIR = '/usr/local/autotest' | 18 AUTOTEST_DIR = '/usr/local/autotest' |
| 18 | 19 |
| 19 # Specify the root directory that on client machines | 20 # Specify the root directory that on client machines |
| 20 rootdir = '/tmp/kvm_autotest_root' | 21 rootdir = '/tmp/kvm_autotest_root' |
| 21 | 22 |
| 22 # Make possible to import the KVM test APIs | |
| 23 KVM_DIR = os.path.join(AUTOTEST_DIR, 'client/tests/kvm') | 23 KVM_DIR = os.path.join(AUTOTEST_DIR, 'client/tests/kvm') |
| 24 sys.path.append(KVM_DIR) | |
| 25 | 24 |
| 26 import common, kvm_config | |
| 27 | 25 |
| 28 def generate_mac_address(): | 26 def generate_mac_address(): |
| 29 r = random.SystemRandom() | 27 r = random.SystemRandom() |
| 30 mac = "9a:%02x:%02x:%02x:%02x:%02x" % (r.randint(0x00, 0xff), | 28 mac = "9a:%02x:%02x:%02x:%02x:%02x" % (r.randint(0x00, 0xff), |
| 31 r.randint(0x00, 0xff), | 29 r.randint(0x00, 0xff), |
| 32 r.randint(0x00, 0xff), | 30 r.randint(0x00, 0xff), |
| 33 r.randint(0x00, 0xff), | 31 r.randint(0x00, 0xff), |
| 34 r.randint(0x00, 0xff)) | 32 r.randint(0x00, 0xff)) |
| 35 return mac | 33 return mac |
| 36 | 34 |
| 37 | 35 |
| 38 def run(pair): | 36 def run(pair): |
| 39 logging.info("KVM migration running on source host [%s] and destination " | 37 logging.info("KVM migration running on source host [%s] and destination " |
| 40 "host [%s]\n", pair[0], pair[1]) | 38 "host [%s]\n", pair[0], pair[1]) |
| 41 | 39 |
| 42 source = hosts.create_host(pair[0]) | 40 source = hosts.create_host(pair[0]) |
| 43 dest = hosts.create_host(pair[1]) | 41 dest = hosts.create_host(pair[1]) |
| 44 source_at = autotest.Autotest(source) | 42 source_at = autotest.Autotest(source) |
| 45 dest_at = autotest.Autotest(dest) | 43 dest_at = autotest.Autotest(dest) |
| 46 | 44 |
| 47 cfg_file = os.path.join(KVM_DIR, "tests_base.cfg") | 45 cfg_file = os.path.join(KVM_DIR, "tests_base.cfg") |
| 48 | 46 |
| 49 if not os.path.exists(cfg_file): | 47 if not os.path.exists(cfg_file): |
| 50 raise error.JobError("Config file %s was not found", cfg_file) | 48 raise error.JobError("Config file %s was not found", cfg_file) |
| 51 | 49 |
| 52 # Get test set (dictionary list) from the configuration file | 50 # Get test set (dictionary list) from the configuration file |
| 53 parser = kvm_config.Parser() | 51 parser = cartesian_config.Parser() |
| 54 test_variants = """ | 52 test_variants = """ |
| 55 image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/ | 53 image_name(_.*)? ?<= /tmp/kvm_autotest_root/images/ |
| 56 cdrom(_.*)? ?<= /tmp/kvm_autotest_root/ | 54 cdrom(_.*)? ?<= /tmp/kvm_autotest_root/ |
| 57 floppy ?<= /tmp/kvm_autotest_root/ | 55 floppy ?<= /tmp/kvm_autotest_root/ |
| 58 Linux: | 56 Linux: |
| 59 unattended_install: | 57 unattended_install: |
| 60 kernel ?<= /tmp/kvm_autotest_root/ | 58 kernel ?<= /tmp/kvm_autotest_root/ |
| 61 initrd ?<= /tmp/kvm_autotest_root/ | 59 initrd ?<= /tmp/kvm_autotest_root/ |
| 62 qemu_binary = /usr/libexec/qemu-kvm | 60 qemu_binary = /usr/libexec/qemu-kvm |
| 63 qemu_img_binary = /usr/bin/qemu-img | 61 qemu_img_binary = /usr/bin/qemu-img |
| (...skipping 28 matching lines...) Expand all Loading... |
| 92 dest_params['role'] = "destination" | 90 dest_params['role'] = "destination" |
| 93 dest_params['migration_mode'] = "tcp" | 91 dest_params['migration_mode'] = "tcp" |
| 94 | 92 |
| 95 # Report the parameters we've received | 93 # Report the parameters we've received |
| 96 print "Test parameters:" | 94 print "Test parameters:" |
| 97 keys = params.keys() | 95 keys = params.keys() |
| 98 keys.sort() | 96 keys.sort() |
| 99 for key in keys: | 97 for key in keys: |
| 100 logging.debug(" %s = %s", key, params[key]) | 98 logging.debug(" %s = %s", key, params[key]) |
| 101 | 99 |
| 102 source_control_file += "job.run_test('kvm', tag='%s', params=%s)" % (sou
rce_params['shortname'], source_params) | 100 source_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % |
| 103 dest_control_file += "job.run_test('kvm', tag='%s', params=%s)" % (dest_
params['shortname'], dest_params) | 101 (source_params['shortname'], source_params)) |
| 102 dest_control_file += ("job.run_test('kvm', tag='%s', params=%s)" % |
| 103 (dest_params['shortname'], dest_params)) |
| 104 | 104 |
| 105 logging.info('Source control file:\n%s', source_control_file) | 105 logging.info('Source control file:\n%s', source_control_file) |
| 106 logging.info('Destination control file:\n%s', dest_control_file) | 106 logging.info('Destination control file:\n%s', dest_control_file) |
| 107 dest_command = subcommand(dest_at.run, | 107 dest_command = subcommand(dest_at.run, |
| 108 [dest_control_file, dest.hostname]) | 108 [dest_control_file, dest.hostname]) |
| 109 | 109 |
| 110 source_command = subcommand(source_at.run, | 110 source_command = subcommand(source_at.run, |
| 111 [source_control_file, source.hostname]) | 111 [source_control_file, source.hostname]) |
| 112 | 112 |
| 113 parallel([dest_command, source_command]) | 113 parallel([dest_command, source_command]) |
| 114 | 114 |
| 115 # Grab the pairs (and failures) | 115 # Grab the pairs (and failures) |
| 116 (pairs, failures) = utils.form_ntuples_from_machines(machines, 2) | 116 (pairs, failures) = utils.form_ntuples_from_machines(machines, 2) |
| 117 | 117 |
| 118 # Log the failures | 118 # Log the failures |
| 119 for failure in failures: | 119 for failure in failures: |
| 120 job.record("FAIL", failure[0], "kvm", failure[1]) | 120 job.record("FAIL", failure[0], "kvm", failure[1]) |
| 121 | 121 |
| 122 # Now run through each pair and run | 122 # Now run through each pair and run |
| 123 job.parallel_simple(run, pairs, log=False) | 123 job.parallel_simple(run, pairs, log=False) |
| OLD | NEW |