From patchwork Wed Oct 7 17:54:18 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 52323 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 n97I5tBG015201 for ; Wed, 7 Oct 2009 18:05:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759797AbZJGR63 (ORCPT ); Wed, 7 Oct 2009 13:58:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758637AbZJGR6R (ORCPT ); Wed, 7 Oct 2009 13:58:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59387 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757801AbZJGR6N (ORCPT ); Wed, 7 Oct 2009 13:58:13 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n97Hvkk0010568; Wed, 7 Oct 2009 13:57:46 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n97HvjST028906; Wed, 7 Oct 2009 13:57:46 -0400 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 n97Hve86014834; Wed, 7 Oct 2009 13:57:44 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 3/7] KVM test: new test timedrift_with_migration Date: Wed, 7 Oct 2009 19:54:18 +0200 Message-Id: <1254938062-15286-3-git-send-email-mgoldish@redhat.com> In-Reply-To: <1254938062-15286-2-git-send-email-mgoldish@redhat.com> References: <1254938062-15286-1-git-send-email-mgoldish@redhat.com> <1254938062-15286-2-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 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 540d0a2..618c21e 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -100,19 +100,26 @@ variants: type = linux_s3 - timedrift: install setup - type = timedrift extra_params += " -rtc-td-hack" - # Pin the VM and host load to CPU #0 - cpu_mask = 0x1 - # Set the load and rest durations - load_duration = 20 - rest_duration = 20 - # Fail if the drift after load is higher than 50% - drift_threshold = 50 - # Fail if the drift after the rest period is higher than 10% - drift_threshold_after_rest = 10 - # For now, make sure this test is executed alone - used_cpus = 100 + variants: + - with_load: + type = timedrift + # Pin the VM and host load to CPU #0 + cpu_mask = 0x1 + # Set the load and rest durations + load_duration = 20 + rest_duration = 20 + # Fail if the drift after load is higher than 50% + drift_threshold = 50 + # Fail if the drift after the rest period is higher than 10% + drift_threshold_after_rest = 10 + # For now, make sure this test is executed alone + used_cpus = 100 + - with_migration: + type = timedrift_with_migration + migration_iterations = 3 + drift_threshold = 10 + drift_threshold_single = 3 - stress_boot: install setup type = stress_boot @@ -581,7 +588,7 @@ variants: extra_params += " -smp 2" used_cpus = 2 stress_boot: used_cpus = 10 - timedrift: used_cpus = 100 + timedrift.with_load: used_cpus = 100 variants: diff --git a/client/tests/kvm/tests/timedrift_with_migration.py b/client/tests/kvm/tests/timedrift_with_migration.py new file mode 100644 index 0000000..139b663 --- /dev/null +++ b/client/tests/kvm/tests/timedrift_with_migration.py @@ -0,0 +1,95 @@ +import logging, time, commands, re +from autotest_lib.client.common_lib import error +import kvm_subprocess, kvm_test_utils, kvm_utils + + +def run_timedrift_with_migration(test, params, env): + """ + Time drift test with migration: + + 1) Log into a guest. + 2) Take a time reading from the guest and host. + 3) Migrate the guest. + 4) Take a second time reading. + 5) If the drift (in seconds) is higher than a user specified value, fail. + + @param test: KVM test object. + @param params: Dictionary with test parameters. + @param env: Dictionary with the test environment. + """ + vm = kvm_test_utils.get_living_vm(env, params.get("main_vm")) + session = kvm_test_utils.wait_for_login(vm) + + # Collect test parameters: + # Command to run to get the current time + time_command = params.get("time_command") + # Filter which should match a string to be passed to time.strptime() + time_filter_re = params.get("time_filter_re") + # Time format for time.strptime() + time_format = params.get("time_format") + drift_threshold = float(params.get("drift_threshold", "10")) + drift_threshold_single = float(params.get("drift_threshold_single", "3")) + migration_iterations = int(params.get("migration_iterations", 1)) + + try: + # Get initial time + # (ht stands for host time, gt stands for guest time) + (ht0, gt0) = kvm_test_utils.get_time(session, time_command, + time_filter_re, time_format) + + # Migrate + for i in range(migration_iterations): + # Get time before current iteration + (ht0_, gt0_) = kvm_test_utils.get_time(session, time_command, + time_filter_re, time_format) + session.close() + # Run current iteration + logging.info("Migrating: iteration %d of %d..." % + (i + 1, migration_iterations)) + vm = kvm_test_utils.migrate(vm, env) + # Log in + logging.info("Logging in after migration...") + session = vm.remote_login() + if not session: + raise error.TestFail("Could not log in after migration") + logging.info("Logged in after migration") + # Get time after current iteration + (ht1_, gt1_) = kvm_test_utils.get_time(session, time_command, + time_filter_re, time_format) + # Report iteration results + host_delta = ht1_ - ht0_ + guest_delta = gt1_ - gt0_ + drift = abs(host_delta - guest_delta) + logging.info("Host duration (iteration %d): %.2f" % + (i + 1, host_delta)) + logging.info("Guest duration (iteration %d): %.2f" % + (i + 1, guest_delta)) + logging.info("Drift at iteration %d: %.2f seconds" % + (i + 1, drift)) + # Fail if necessary + if drift > drift_threshold_single: + raise error.TestFail("Time drift too large at iteration %d: " + "%.2f seconds" % (i + 1, drift)) + + # Get final time + (ht1, gt1) = kvm_test_utils.get_time(session, time_command, + time_filter_re, time_format) + + finally: + session.close() + + # Report results + host_delta = ht1 - ht0 + guest_delta = gt1 - gt0 + drift = abs(host_delta - guest_delta) + logging.info("Host duration (%d migrations): %.2f" % + (migration_iterations, host_delta)) + logging.info("Guest duration (%d migrations): %.2f" % + (migration_iterations, guest_delta)) + logging.info("Drift after %d migrations: %.2f seconds" % + (migration_iterations, drift)) + + # Fail if necessary + if drift > drift_threshold: + raise error.TestFail("Time drift too large after %d migrations: " + "%.2f seconds" % (migration_iterations, drift))