From patchwork Wed Dec 1 02:52:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 369511 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oB12rBum019031 for ; Wed, 1 Dec 2010 02:53:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754093Ab0LACxE (ORCPT ); Tue, 30 Nov 2010 21:53:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20015 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753968Ab0LACxD (ORCPT ); Tue, 30 Nov 2010 21:53:03 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oB12r21l006581 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 30 Nov 2010 21:53:03 -0500 Received: from freedom.redhat.com (vpn-11-100.rdu.redhat.com [10.11.11.100]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id oB12qw1K010709; Tue, 30 Nov 2010 21:53:01 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH 2/4] KVM test: Introduce migration_multi_host test Date: Wed, 1 Dec 2010 00:52:55 -0200 Message-Id: <1291171977-14327-2-git-send-email-lmr@redhat.com> In-Reply-To: <1291171977-14327-1-git-send-email-lmr@redhat.com> References: <1291171977-14327-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 01 Dec 2010 02:53:11 +0000 (UTC) diff --git a/client/tests/kvm/tests/migration_multi_host.py b/client/tests/kvm/tests/migration_multi_host.py new file mode 100644 index 0000000..4126789 --- /dev/null +++ b/client/tests/kvm/tests/migration_multi_host.py @@ -0,0 +1,96 @@ +import logging, time, socket +from autotest_lib.client.common_lib import error +import kvm_subprocess, kvm_test_utils, kvm_utils + + +def run_migration_multi_host(test, params, env): + """ + KVM multi-host migration test: + + Migration execution progress: + + source host dest host + ---------------------------------------------------------------------------- + log into guest + ---------------------------------------------------------------------------- + start socket server + + wait 30 secs -------------------- wait login_timeout+30 secs --------------- + + accept connection connect to socket server,send mig_port + ---------------------------------------------------------------------------- + start migration + + wait 30 secs -------------------- wait mig_timeout+30 secs ----------------- + + try to log into migrated guest check VM's status via monitor cmd + ---------------------------------------------------------------------------- + + @param test: kvm test object. + @param params: Dictionary with test parameters. + @param env: Dictionary with the test environment. + """ + def guest_active(vm): + o = vm.monitor.info("status") + if isinstance(o, str): + return "status: active" in o + else: + return o.get("status") == "active" + + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + login_timeout = int(params.get("login_timeout", 360)) + role = params.get("role") + if role == 'source': + session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout) + + # Listen on a port to get the migration port received from + # dest machine + s = socket.socket() + s.bind(source_addr) + s.listen(1) + + # Wait 30 seconds for source and dest to reach this point + self.job.barrier(srchost,'socket_started', 30).rendezvous(*all) + + conn, addr = s.accept() + mig_port = int(conn.recv(6)) + logging.info("Received from destination the migration port %s", + mig_port) + s.close() + + logging.info("Start migrating now...") + kvm_test_utils.migrate(vm=vm, dest_host=dsthost, mig_port=mig_port, + env=env) + + # Wait up to 30 seconds for dest to reach this point + self.job.barrier(srchost,'mig_finished',30).rendezvous(*all) + + elif role == 'destination': + # Wait up to login_timeout + 30 seconds for the source to + # reach this point + self.job.barrier(dsthost, 'socket_started', + login_timeout + 30).rendezvous(*all) + + s = socket.socket() + s.connect(source_addr) + logging.info("Communicating to source migration port %s", + vm.migration_port) + s.send("%d" % vm.migration_port) + s.close() + + # Wait up to mig_timeout + 30 seconds for the source to + # reach this point: migration finished + self.job.barrier(dsthost, 'mig_finished', + mig_timeout + 30).rendezvous(*all) + + if not guest_active(vm): + raise error.TestFail("Guest not active after migration") + + logging.info("Migrated guest appears to be running") + + # Log into the guest again + logging.info("Logging into migrated guest after migration...") + session = kvm_test_utils.wait_for_login(vm, timeout=login_timeout) + + else: + raise error.TestError('Invalid role specified') diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample index 2e06c3b..87cd28e 100644 --- a/client/tests/kvm/tests_base.cfg.sample +++ b/client/tests/kvm/tests_base.cfg.sample @@ -156,6 +156,17 @@ variants: iterations = 1 type = migration_with_file_transfer + - migrate_multi_host: install setup unattended_install.cdrom + type = migration_multi_host + migration_test_command = help + migration_bg_command = "cd /tmp; nohup tcpdump -q -t ip host localhost" + migration_bg_check_command = pgrep tcpdump + migration_bg_kill_command = pkill tcpdump + kill_vm_on_error = yes + iterations = 2 + used_mem = 1024 + mig_timeout = 3600 + - boot_savevm: install setup unattended_install.cdrom type = boot_savevm savevm_delay = 0.3