From: Lucas Meneghel Rodrigues <lmr@redhat.com>
To: autotest@test.kernel.org
Cc: kvm@vger.kernel.org
Subject: [PATCH 3/5] KVM test: Add migration server control file
Date: Mon, 20 Dec 2010 11:57:32 -0500 [thread overview]
Message-ID: <1292864254-6782-3-git-send-email-lmr@redhat.com> (raw)
In-Reply-To: <1292864254-6782-1-git-send-email-lmr@redhat.com>
Introduce the server migration control file, that makes
possible to run the multi host migration. 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 ('destination' or 'source').
Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---
client/tests/kvm/migration_control.srv | 122 ++++++++++++++++++++++++++++++++
1 files changed, 122 insertions(+), 0 deletions(-)
create mode 100644 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 0000000..16ada36
--- /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)
--
1.7.3.4
next prev parent reply other threads:[~2010-12-20 16:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-20 16:57 [PATCH 1/5] KVM test: Include the preprocessing param migration_mode Lucas Meneghel Rodrigues
2010-12-20 16:57 ` [PATCH 2/5] KVM test: Introduce migration_multi_host test Lucas Meneghel Rodrigues
2010-12-20 16:57 ` Lucas Meneghel Rodrigues [this message]
2010-12-20 16:57 ` [PATCH 4/5] KVM test: Modifications on the migrate utility function Lucas Meneghel Rodrigues
2010-12-20 16:57 ` [PATCH 5/5] KVM test: kvm_vm: Allow NIC MACs to be defined on config file Lucas Meneghel Rodrigues
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1292864254-6782-3-git-send-email-lmr@redhat.com \
--to=lmr@redhat.com \
--cc=autotest@test.kernel.org \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox