boot.py 1.2 KB
Newer Older
1
import time
2
from autotest.client.shared import error
3
from virttest import utils_test
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32


@error.context_aware
def run_boot(test, params, env):
    """
    KVM reboot test:
    1) Log into a guest
    3) Send a reboot command or a system_reset monitor command (optional)
    4) Wait until the guest is up again
    5) Log into the guest to verify it's up again

    @param test: kvm test object
    @param params: Dictionary with the test parameters
    @param env: Dictionary with test environment.
    """

    error.context("Try to log into guest.")
    vm = env.get_vm(params["main_vm"])
    vm.verify_alive()
    timeout = float(params.get("login_timeout", 240))
    session = vm.wait_for_login(timeout=timeout)

    if params.get("rh_perf_envsetup_script"):
        utils_test.service_setup(vm, session, test.virtdir)

    if params.get("reboot_method"):
        error.context("Reboot guest.")
        if params["reboot_method"] == "system_reset":
            time.sleep(int(params.get("sleep_before_reset", 10)))
33 34 35
            # Reboot the VM
        for i in range(int(params.get("reboot_count", 1))):
            session = vm.reboot(session, params["reboot_method"], 0, timeout)
36 37

    session.close()