From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C5=BDupka?= 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE To: autotest@test.kernel.org, kvm@vger.kernel.org, kvm-autotest@redhat.com, lmr@redhat.com, ldoktor@redhat.com, jzupka@redhat.com Return-path: 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 Sender: kvm-owner@vger.kernel.org List-ID: Test name Multi_host migration. Signed-off-by: Ji=C5=99=C3=AD =C5=BDupka --- 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/cont= rol.srv new file mode 100644 index 0000000..db6c08a --- /dev/null +++ b/multihost_migration/control.srv @@ -0,0 +1,55 @@ +AUTHOR =3D "jzupka@redhat.com (J. Zupka)" +TIME =3D "MEDIUM" +NAME =3D "Multi_host migration" +TEST_CATEGORY =3D "Virtualization" +TEST_CLASS =3D 'Multihost Migration' +TEST_TYPE =3D "Server" +SYNC_COUNT =3D 2 +DOC =3D """ +Multihost_migration tests multihost migration with different configura= tion. + +List of test are described in /client/tests/virt/cfg/subtest.cfg.sampl= e. + +Environment for test: +Storage: + Both quest have to have acces to same shared diskplace vhere are ima= ges 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 conn= ected + directly to network). + +EXTRA_PARAMS: + adds extra params to client part of autotest. It is possible use thi= s Extra + params for closer specific of running test. + example: + EXTRA_PARAMS =3D ""\" + 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 =3D """ +""" + +def run(machines): + job.run_test('multihost_migration', machines=3Dmachines, + extra_params=3DEXTRA_PARAMS, cycles=3D1) + +if 'all' in args: + # Run test with all machines at once. + run(machines) +else: + # Grab the pairs (and failures) + (pairs, failures) =3D 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=3DFalse) diff --git a/multihost_migration/multihost_migration.py b/multihost_mig= ration/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 =3D random.SystemRandom() + mac =3D "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 =3D host + self.at =3D None + self.params =3D None + self.control =3D None + + +class multihost_migration(test.test): + version =3D 2 + + def run_once(self, machines, extra_params, cycles): + AUTOTEST_DIR =3D self.job.clientdir + + KVM_DIR =3D os.path.join(AUTOTEST_DIR, 'tests', 'virt') + + sys.path.insert(0, KVM_DIR) + + + CONTROL_MAIN_PART =3D """ +testname =3D "virt" +bindir =3D os.path.join(job.testdir, testname) +job.install_pkg(testname, 'test', bindir) + +kvm_test_dir =3D 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 =3D {} + for machine in machines: + _hosts[machine] =3D Machines(hosts.create_host(machine)) + + for host in _hosts.itervalues(): + host.at =3D autotest_remote.Autotest(host.host) + + cfg_file =3D os.path.join(KVM_DIR, "kvm", "cfg", "multi-host-t= ests.cfg") + + if not os.path.exists(cfg_file): + raise error.JobError("Config file %s was not found", cfg_f= ile) + + # Get test set (dictionary list) from the configuration file + parser =3D cartesian_config.Parser() + parser.parse_file(cfg_file) + parser.parse_string(extra_params) + test_dicts =3D parser.get_dicts() + + ips =3D [] + for machine in machines: + host =3D _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 =3D parser.get_dicts() + + test_dicts_ar =3D [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'] =3D ips + + params['not_preprocess'] =3D "yes" + for vm in params.get("vms").split(): + for nic in params.get('nics', "").split(): + params['mac_%s_%s' % (nic, vm)] =3D generate_mac_a= ddress() + + params['master_images_clone'] =3D "image1" + params['kill_vm'] =3D "yes" + + s_host =3D _hosts[machines[0]] + s_host.params =3D params.copy() + s_host.params['clone_master'] =3D "yes" + s_host.params['hostid'] =3D machines[0] + + for machine in machines[1:]: + host =3D _hosts[machine] + host.params =3D params.copy() + host.params['clone_master'] =3D "no" + host.params['hostid'] =3D machine + + # Report the parameters we've received + logging.debug("Test parameters:") + keys =3D params.keys() + keys.sort() + for key in keys: + logging.debug(" %s =3D %s", key, params[key]) + + for machine in machines: + host =3D _hosts[machine] + host.control =3D CONTROL_MAIN_PART + + for machine in machines: + host =3D _hosts[machine] + host.control +=3D ("job.run_test('virt', tag=3D'%s', p= arams=3D%s)" % + (host.params['shortname'], host.param= s)) + + logging.debug('Master control file:\n%s', _hosts[machines[= 0]].control) + for machine in machines[1:]: + host =3D _hosts[machine] + logging.debug('Slave control file:\n%s', host.control) + + commands =3D [] + + for machine in machines: + host =3D _hosts[machine] + commands.append(subcommand.subcommand(host.at.run, + [host.control, host.host.ho= stname])) + + try: + subcommand.parallel(commands) + except error.AutoservError, e: + logging.error(e) --=20 1.7.7.6