From patchwork Wed Nov 4 14:05:39 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 57583 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA4E8OqE020583 for ; Wed, 4 Nov 2009 14:08:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756218AbZKDOIR (ORCPT ); Wed, 4 Nov 2009 09:08:17 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756213AbZKDOIQ (ORCPT ); Wed, 4 Nov 2009 09:08:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40301 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756201AbZKDOIQ (ORCPT ); Wed, 4 Nov 2009 09:08:16 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nA4E8Kw4017989; Wed, 4 Nov 2009 09:08:20 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nA4E8KMp019488; Wed, 4 Nov 2009 09:08:20 -0500 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id nA4E897B029198; Wed, 4 Nov 2009 09:08:17 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 3/6] KVM test: migration: rely on background process instead of timing Date: Wed, 4 Nov 2009 16:05:39 +0200 Message-Id: <1257343542-27902-3-git-send-email-mgoldish@redhat.com> In-Reply-To: <1257343542-27902-2-git-send-email-mgoldish@redhat.com> References: <1257343542-27902-1-git-send-email-mgoldish@redhat.com> <1257343542-27902-2-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 573206c..bcc31bb 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -77,6 +77,9 @@ variants: - migrate: install setup type = migration 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 @@ -499,6 +502,9 @@ variants: migrate: migration_test_command = ver && vol + migration_bg_command = start ping -t localhost + migration_bg_check_command = tasklist | find /I "ping.exe" + migration_bg_kill_command = taskkill /IM ping.exe /F stress_boot: alive_test_cmd = systeminfo timedrift: diff --git a/client/tests/kvm/tests/migration.py b/client/tests/kvm/tests/migration.py index 4b13b5d..7b80e51 100644 --- a/client/tests/kvm/tests/migration.py +++ b/client/tests/kvm/tests/migration.py @@ -1,4 +1,4 @@ -import logging +import logging, time from autotest_lib.client.common_lib import error import kvm_subprocess, kvm_test_utils, kvm_utils @@ -20,33 +20,63 @@ def run_migration(test, params, env): @param env: Dictionary with the test environment. """ vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) - - # Log into guest and get the output of migration_test_command session = kvm_test_utils.wait_for_login(vm) - migration_test_command = params.get("migration_test_command") - reference_output = session.get_command_output(migration_test_command) - session.close() - # Migrate the VM - dest_vm = kvm_test_utils.migrate(vm, env) + # Get the output of migration_test_command + test_command = params.get("migration_test_command") + reference_output = session.get_command_output(test_command) - # Log into guest and get the output of migration_test_command - logging.info("Logging into guest after migration...") - session = dest_vm.remote_login() - if not session: - raise error.TestFail("Could not log into guest after migration") - logging.info("Logged in after migration") - output = session.get_command_output(migration_test_command) - session.close() + # Start some process in the background (and leave the session open) + background_command = params.get("migration_bg_command", "") + session.sendline(background_command) + time.sleep(5) + + # Start another session with the guest and make sure the background + # process is running + session2 = kvm_test_utils.wait_for_login(vm) + + try: + check_command = params.get("migration_bg_check_command", "") + if session2.get_command_status(check_command, timeout=30) != 0: + raise error.TestError("Could not start background process '%s'" % + background_command) + session2.close() + + # Migrate the VM + dest_vm = kvm_test_utils.migrate(vm, env) - # Compare output to reference output - if output != reference_output: - logging.info("Command output before migration differs from command " - "output after migration") - logging.info("Command: %s" % params.get("migration_test_command")) - logging.info("Output before:" + - kvm_utils.format_str_for_message(reference_output)) - logging.info("Output after:" + - kvm_utils.format_str_for_message(output)) - raise error.TestFail("Command produced different output before and " - "after migration") + # Log into the guest again + logging.info("Logging into guest after migration...") + session2 = kvm_utils.wait_for(dest_vm.remote_login, 30, 0, 2) + if not session2: + raise error.TestFail("Could not log into guest after migration") + logging.info("Logged in after migration") + + # Make sure the background process is still running + if session2.get_command_status(check_command, timeout=30) != 0: + raise error.TestFail("Could not find running background process " + "after migration: '%s'" % background_command) + + # Get the output of migration_test_command + output = session2.get_command_output(test_command) + + # Compare output to reference output + if output != reference_output: + logging.info("Command output before migration differs from " + "command output after migration") + logging.info("Command: %s" % test_command) + logging.info("Output before:" + + kvm_utils.format_str_for_message(reference_output)) + logging.info("Output after:" + + kvm_utils.format_str_for_message(output)) + raise error.TestFail("Command '%s' produced different output " + "before and after migration" % test_command) + + finally: + # Kill the background process + if session2.is_alive(): + session2.get_command_output(params.get("migration_bg_kill_command", + "")) + + session2.close() + session.close() diff --git a/client/tests/kvm/tests/timedrift_with_migration.py b/client/tests/kvm/tests/timedrift_with_migration.py index af02f97..99d645a 100644 --- a/client/tests/kvm/tests/timedrift_with_migration.py +++ b/client/tests/kvm/tests/timedrift_with_migration.py @@ -49,7 +49,7 @@ def run_timedrift_with_migration(test, params, env): vm = kvm_test_utils.migrate(vm, env) # Log in logging.info("Logging in after migration...") - session = vm.remote_login() + session = kvm_utils.wait_for(vm.remote_login, 30, 0, 2) if not session: raise error.TestFail("Could not log in after migration") logging.info("Logged in after migration")