提交 fe8e620e 编写于 作者: Y Yiqiao Pu 提交者: Lucas Meneghel Rodrigues

qemu.tests: Measure RHEL guest boot up time

Measure the boot up time of RHEL guest when it run level is 1.
Signed-off-by: NYiqiao Pu <ypu@redhat.com>
Acked-by: Golita Yue<gyue@redhat.com>

get_image_filename have been moved to virt_storage.
And we have moved image related script to virt_storage.

Changes from v2:
Delete duplicated module
Changes from v1:
Import missing kvm_storage in live_snapshot_chain.py
Signed-off-by: NFeng Yang <fyang@redhat.com>

All image related functions is moved to storage class. Update it
in boot_time.
Signed-off-by: NYiqiao Pu <ypu@redhat.com>

backup image before boot_time test and restore image after it.

Delete image snapshot part code and simplify the code.
Signed-off-by: NFeng Yang <fyang@redhat.com>

Update method for set and resotre run level. Also drop cache before
test the boot time.
Signed-off-by: NYiqiao Pu <ypu@redhat.com>
上级 9a8774cf
import logging, time, re, os
from autotest.client.shared import error
from autotest.client import utils
from virttest import utils_misc, utils_test, env_process, storage, data_dir
@error.context_aware
def run_boot_time(test, params, env):
"""
KVM boot time test:
1) Set init run level to 1
2) Send a shutdown command to the guest, or issue a system_powerdown
monitor command (depending on the value of shutdown_method)
3) Boot up the guest and measure the boot time
4) set init run level back to the old one
@param test: QEMU test object
@param params: Dictionary with the test parameters
@param env: Dictionary with test environment
"""
vm = env.get_vm(params["main_vm"])
vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
session = vm.wait_for_login(timeout=timeout)
error.context("Set guest run level to 1", logging.info)
single_user_cmd = params['single_user_cmd']
session.cmd(single_user_cmd)
try:
error.context("Shut down guest", logging.info)
session.cmd('sync')
vm.destroy()
error.context("Boot up guest and measure the boot time", logging.info)
utils.drop_caches()
vm.create()
vm.verify_alive()
session = vm.wait_for_serial_login(timeout=timeout)
boot_time = time.time() - vm.start_time
expect_time = int(params.get("expect_bootup_time", "17"))
logging.info("Boot up time: %ss" % boot_time)
finally:
try:
error.context("Restore guest run level", logging.info)
restore_level_cmd = params['restore_level_cmd']
session.cmd(restore_level_cmd)
session.cmd('sync')
vm.destroy()
vm.create()
vm.verify_alive()
vm.wait_for_login(timeout=timeout)
except Exception:
logging.Warn("Can not restore guest run level, "
"need restore the image")
params["restore_image_after_testing"] = "yes"
if boot_time > expect_time:
raise error.TestFail("Guest boot up is taking too long: %ss" % boot_time)
session.close()
- boot_time:
virt_test_type = qemu
only Linux
type = boot_time
shutdown_method = system_powerdown
kill_vm = yes
kill_vm_gracefully = no
check_img = yes
backup_image_before_testing = yes
restore_level_cmd = grubby --update-kernel=ALL --remove-args="S"
single_user_cmd = grubby --update-kernel=ALL --args="S"
# This value may change from host to host
# Please confirm your host status and update it
# expect_bootup_time = 17
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册