From 7dbd00fd7de9eeec34be4f3ebe4c107774566de1 Mon Sep 17 00:00:00 2001 From: Yanan Fu Date: Fri, 14 Apr 2017 15:14:38 +0800 Subject: [PATCH] qemu.tests.win_heavyload: Improve stop heavyload strategy 1. Correct the test_timeout value 2. Old design don't check running status when execute stop_cmd in the loop, it will cause stop_cmd failed as "no process is running" sometimes, improve to do stop_cmd only once as it is only a cleanup. Signed-off-by: Yanan Fu --- qemu/tests/win_heavyload.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/qemu/tests/win_heavyload.py b/qemu/tests/win_heavyload.py index e8b1b010..1bebc577 100644 --- a/qemu/tests/win_heavyload.py +++ b/qemu/tests/win_heavyload.py @@ -7,14 +7,14 @@ try: except ImportError: from virttest import aexpect -from autotest.client.shared import error from autotest.client import utils +from virttest import error_context from virttest import utils_misc from virttest import data_dir -@error.context_aware +@error_context.context_aware def run(test, params, env): """ KVM guest stop test: @@ -81,14 +81,14 @@ def run(test, params, env): if download_url: dst = r"c:\\" pkg_md5sum = params["pkg_md5sum"] - error.context("Download HeavyLoadSetup.exe", logging.info) + error_context.context("Download HeavyLoadSetup.exe", logging.info) pkg = utils.unmap_url_cache(tmp_dir, download_url, pkg_md5sum) vm.copy_files_to(pkg, dst) else: dst = r"%s:\\" % utils_misc.get_winutils_vol(session) - error.context("Install HeavyLoad in guest", logging.info) + error_context.context("Install HeavyLoad in guest", logging.info) install_cmd = params["install_cmd"] install_cmd = re.sub(r"DRIVE:\\+", dst, install_cmd) session.cmd(install_cmd) @@ -96,7 +96,7 @@ def run(test, params, env): if config_cmd: session.cmd(config_cmd) - error.context("Start heavyload in guest", logging.info) + error_context.context("Start heavyload in guest", logging.info) # genery heavyload command automaticly if params.get("autostress") == "yes": free_mem = utils_misc.get_free_mem(session, "windows") @@ -111,37 +111,37 @@ def run(test, params, env): test_timeout = int(params.get("timeout", "60")) steping = 60 if test_timeout < 60: - logging.warn("Heavyload use minis as unit of timeout," - "values is too small, use default: 60s") + logging.warn("Heavyload use mins as unit of timeout, given timeout " + "is too small (%ss), force set to 60s", test_timeout) test_timeout = 60 steping = 30 - test_timeout = test_timeout / 60 - start_cmd = add_option(start_cmd, 'DURATION', test_timeout) + start_cmd = add_option(start_cmd, 'DURATION', test_timeout / 60) start_cmd = add_option(start_cmd, 'START', '') start_cmd = add_option(start_cmd, 'AUTOEXIT', '') logging.info("heavyload cmd: %s" % start_cmd) session.sendline(start_cmd) if not loop_session_cmd(session, check_running_cmd): - raise error.TestError("heavyload process is not started") + test.error("heavyload process is not started") sleep_before_migration = int(params.get("sleep_before_migration", "0")) time.sleep(sleep_before_migration) - error.context("Verify vm is alive", logging.info) + error_context.context("Verify vm is alive", logging.info) utils_misc.wait_for(vm.verify_alive, timeout=test_timeout, step=steping) finally: # in migration test, no need to stop heavyload on src host cleanup_in_the_end = params.get("unload_stress_in_the_end", "yes") if cleanup_in_the_end == "yes": - error.context("Stop load and clean tmp files", logging.info) + error_context.context("Stop load and clean tmp files", logging.info) if not installed and download_url: utils.system("rm -f %s/HeavyLoad*.exe" % tmp_dir) session.cmd("del /f /s %sHeavyLoad*.exe" % dst) - if loop_session_cmd(session, check_running_cmd): - if not loop_session_cmd(session, stop_cmd): - raise error.TestFail("Unable to terminate heavyload " - "process") + if not session.cmd_status(check_running_cmd): + try: + session.cmd(stop_cmd, timeout=120) + except: + logging.warn("Unable to terminate heavyload process") if session: session.close() -- GitLab