From patchwork Mon Dec 10 10:08:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiri Zupka X-Patchwork-Id: 1856751 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C2F883FCF2 for ; Mon, 10 Dec 2012 10:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753998Ab2LJKJP (ORCPT ); Mon, 10 Dec 2012 05:09:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63138 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753255Ab2LJKJN (ORCPT ); Mon, 10 Dec 2012 05:09:13 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBAA8quh023468 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 10 Dec 2012 05:08:52 -0500 Received: from jzupka-pc.local.com (vpn1-6-90.ams2.redhat.com [10.36.6.90]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBAA8nNp010443; Mon, 10 Dec 2012 05:08:50 -0500 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=BDupka?= To: autotest@test.kernel.org, kvm@vger.kernel.org, kvm-autotest@redhat.com, lmr@redhat.com, ldoktor@redhat.com, jzupka@redhat.com Subject: [Autotest][PATCH] Server test: Adds support for multi-host migration in afe tool. Date: Mon, 10 Dec 2012 11:08:47 +0100 Message-Id: <1355134127-15234-1-git-send-email-jzupka@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Test name Multi_host migration. Signed-off-by: Ji?í Župka --- multihost_migration/control.srv | 55 +++++++++++ multihost_migration/multihost_migration.py | 136 ++++++++++++++++++++++++++++ 2 files changed, 191 insertions(+), 0 deletions(-) create mode 100644 multihost_migration/control.srv create mode 100644 multihost_migration/multihost_migration.py diff --git a/multihost_migration/control.srv b/multihost_migration/control.srv new file mode 100644 index 0000000..db6c08a --- /dev/null +++ b/multihost_migration/control.srv @@ -0,0 +1,55 @@ +AUTHOR = "jzupka@redhat.com (J. Zupka)" +TIME = "MEDIUM" +NAME = "Multi_host migration" +TEST_CATEGORY = "Virtualization" +TEST_CLASS = 'Multihost Migration' +TEST_TYPE = "Server" +SYNC_COUNT = 2 +DOC = """ +Multihost_migration tests multihost migration with different configuration. + +List of test are described in /client/tests/virt/cfg/subtest.cfg.sample. + +Environment for test: +Storage: + Both quest have to have acces to same shared diskplace vhere are images of + migrated guests placed. (NFS, ...) +Network client hosts: + Both machine on which are migration tests started have to be in same network. +Netowrk client guests: + For some test are necessary join guest to same network. (bridge connected + directly to network). + +EXTRA_PARAMS: + adds extra params to client part of autotest. It is possible use this Extra + params for closer specific of running test. + example: + EXTRA_PARAMS = ""\" + only pc.migrate_multi_host..ping-pong-stress.cpu_memory..tcp + ""\" + start migrate_multi_host only ping-pong-stress test wirh + cpu and memory load. +""" + +from autotest.server import utils + +EXTRA_PARAMS = """ +""" + +def run(machines): + job.run_test('multihost_migration', machines=machines, + extra_params=EXTRA_PARAMS, cycles=1) + +if 'all' in args: + # Run test with all machines at once. + run(machines) +else: + # 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/multihost_migration/multihost_migration.py b/multihost_migration/multihost_migration.py new file mode 100644 index 0000000..8103fb6 --- /dev/null +++ b/multihost_migration/multihost_migration.py @@ -0,0 +1,136 @@ +import sys, os, commands, logging, random +from autotest.server import autotest_remote, hosts, subcommand, test +from autotest.client.shared import error +from autotest.client.tests.virt.virttest import utils_misc, cartesian_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 + + +class Machines(object): + def __init__(self, host): + self.host = host + self.at = None + self.params = None + self.control = None + + +class multihost_migration(test.test): + version = 2 + + def run_once(self, machines, extra_params, cycles): + AUTOTEST_DIR = self.job.clientdir + + KVM_DIR = os.path.join(AUTOTEST_DIR, 'tests', 'virt') + + sys.path.insert(0, KVM_DIR) + + + CONTROL_MAIN_PART = """ +testname = "virt" +bindir = os.path.join(job.testdir, testname) +job.install_pkg(testname, 'test', bindir) + +kvm_test_dir = os.path.join(os.environ['AUTODIR'],'tests', 'virt') +sys.path.append(kvm_test_dir) +""" + logging.info("KVM test running on hosts %s\n", machines) + + _hosts = {} + for machine in machines: + _hosts[machine] = Machines(hosts.create_host(machine)) + + for host in _hosts.itervalues(): + host.at = autotest_remote.Autotest(host.host) + + cfg_file = os.path.join(KVM_DIR, "kvm", "cfg", "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) + parser.parse_string(extra_params) + test_dicts = parser.get_dicts() + + ips = [] + for machine in machines: + host = _hosts[machine] + ips.append(host.host.ip) + + logging.info("") + for i, params in enumerate(test_dicts): + logging.info("Test %d: %s" % (i, params.get("shortname"))) + logging.info("") + + test_dicts = parser.get_dicts() + + test_dicts_ar = [x for x in test_dicts] + + if not test_dicts_ar: + error.TestNAError("Impossible start any test with" + "this configuration.") + + for params in test_dicts_ar: + + params['hosts'] = ips + + params['not_preprocess'] = "yes" + for vm in params.get("vms").split(): + for nic in params.get('nics', "").split(): + params['mac_%s_%s' % (nic, vm)] = generate_mac_address() + + params['master_images_clone'] = "image1" + params['kill_vm'] = "yes" + + s_host = _hosts[machines[0]] + s_host.params = params.copy() + s_host.params['clone_master'] = "yes" + s_host.params['hostid'] = machines[0] + + for machine in machines[1:]: + host = _hosts[machine] + host.params = params.copy() + host.params['clone_master'] = "no" + host.params['hostid'] = machine + + # Report the parameters we've received + logging.debug("Test parameters:") + keys = params.keys() + keys.sort() + for key in keys: + logging.debug(" %s = %s", key, params[key]) + + for machine in machines: + host = _hosts[machine] + host.control = CONTROL_MAIN_PART + + for machine in machines: + host = _hosts[machine] + host.control += ("job.run_test('virt', tag='%s', params=%s)" % + (host.params['shortname'], host.params)) + + logging.debug('Master control file:\n%s', _hosts[machines[0]].control) + for machine in machines[1:]: + host = _hosts[machine] + logging.debug('Slave control file:\n%s', host.control) + + commands = [] + + for machine in machines: + host = _hosts[machine] + commands.append(subcommand.subcommand(host.at.run, + [host.control, host.host.hostname])) + + try: + subcommand.parallel(commands) + except error.AutoservError, e: + logging.error(e)