From: Satheesh Rajendran <sathn...@linux.vnet.ibm.com> This test implements the following github issue https://github.com/autotest/autotest/issues/404
Signed-off-by: Satheesh Rajendran <sathn...@linux.vnet.ibm.com> --- client/tests/kvm/tests/time_manage.py | 127 +++++++++++++++++++++++++++++++++ client/virt/guest-os.cfg.sample | 9 +++ client/virt/subtests.cfg.sample | 12 +++ 3 files changed, 148 insertions(+), 0 deletions(-) create mode 100644 client/tests/kvm/tests/time_manage.py diff --git a/client/tests/kvm/tests/time_manage.py b/client/tests/kvm/tests/time_manage.py new file mode 100644 index 0000000..578bf89 --- /dev/null +++ b/client/tests/kvm/tests/time_manage.py @@ -0,0 +1,127 @@ +import logging, time, commands +from autotest.client.shared import error +from autotest.client.virt import virt_test_utils, aexpect +from autotest.client.virt import virt_env_process + +@error.context_aware +def run_time_manage(test, params, env): + """ + Time manage test: + + 1) Generate stress in host. + 2) Run atleast 15 vms with "driftfix=slew" option + 3) Reboot the guest. + 4) Repeat the step 3 for all guests and check whether the guest + responds properly(not any watchdog reported). + 5) TODO: Improve the way of checking the response and + run some stress inside guest too. + 6) Continue the step 4 for 10 iterations and + record the guest/host realtime, calculate drift in time for + each iterations. + 7) Print the drift values for all sessions + 8) TODO: Validate if the drift value has to be within defined value + + @param test: KVM test object. + @param params: Dictionary with test parameters. + @param env: Dictionary with the test environment. + """ + # Checking the main vm is alive + vm = env.get_vm(params["main_vm"]) + vm.verify_alive() + timeout = int(params.get("login_timeout", 360)) + session = vm.wait_for_login(timeout=timeout) + + # Collect test parameters + login_timeout = float(params.get("login_timeout", 240)) + host_load_command = params.get("host_load_command") + host_load_kill_command = params.get("host_load_kill_command") + time_command = params.get("time_command") + time_filter_re = params.get("time_filter_re") + time_format = params.get("time_format") + + # Intialize the variables + itr = 0 + num = 2 + host_load_sessions = [] + sessions = [session] + prev_time = [] + curr_time = [] + timedrift = [] + totaldrift = [] + vmnames =["vm1"] + + # Run some load on the host + logging.info("Starting load on host.") + host_load_sessions.append(aexpect.run_bg(host_load_command, + output_func=logging.debug, + output_prefix="host load ", + timeout=0.5)) + # Boot the VMs + try: + while num <= int(params.get("max_vms")): + # Clone vm according to the first one + vm_name = "vm%d" % num + vmnames.append(vm_name) + vm_params = vm.params.copy() + curr_vm = vm.clone(vm_name, vm_params) + env.register_vm(vm_name, curr_vm) + virt_env_process.preprocess_vm(test, vm_params, env, vm_name) + params["vms"] += " " + vm_name + + sessions.append(curr_vm.wait_for_login(timeout=login_timeout)) + logging.info("Guest #%d booted up successfully", num) + + # Check whether all previous shell sessions are responsive + error.context("checking responsiveness of the booted guest") + for se in sessions: + se.cmd(params.get("alive_test_cmd")) + num += 1 + + while itr <= int(params.get("max_itrs")): + for vmid,se in enumerate(sessions): + # Get the respective vm object + vmname = "vm%d" % (vmid +1) + vm = env.get_vm(vmname) + # Run current iteration + logging.info("Rebooting:vm%d iteration %d " % ((vmid + 1), itr)) + se = vm.reboot(se ,timeout=timeout) + # Remember the current changed session + sessions[vmid] = se + error.context("checking responsiveness of guest") + se.cmd(params.get("alive_test_cmd")) + if itr == 0: + (ht0, gt0) = virt_test_utils.get_time(se, time_command, + time_filter_re, time_format) + prev_time.append((ht0, gt0)) + else: + (ht1, gt1) = virt_test_utils.get_time(se, time_command, + time_filter_re, time_format) + curr_time.append((ht1, gt1)) + if itr != 0: + for i in range(int(params.get("max_vms"))): + hdelta = curr_time[i][0] - prev_time[i][0] + gdelta = curr_time[i][1] - prev_time[i][1] + drift = format( 100.0 * (hdelta - gdelta) / hdelta, ".2f" ) + timedrift.append(drift) + totaldrift.append(timedrift) + prev_time = curr_time + timedrift = [] + curr_time = [] + # Wait for some time before next iteration + time.sleep(30) + itr += 1 + + logging.info("The time drift values for all VM sessions/iterations") + logging.info("VM-Name:%s" % vmnames) + for idx,value in enumerate(totaldrift): + logging.info("itr-%2d:%s" % (idx+1,value)) + + finally: + for se in sessions: + # Closing all the sessions. + se.close() + logging.info("killing load on host.") + host_load_sessions.append(aexpect.run_bg(host_load_kill_command, + output_func=logging.debug, + output_prefix="host load kill", + timeout=0.5)) diff --git a/client/virt/guest-os.cfg.sample b/client/virt/guest-os.cfg.sample index 5c1eb2b..4e19c42 100644 --- a/client/virt/guest-os.cfg.sample +++ b/client/virt/guest-os.cfg.sample @@ -34,6 +34,10 @@ variants: time_command = date +'TIME: %a %m/%d/%Y %H:%M:%S.%N' time_filter_re = "(?:TIME: \w\w\w )(.{19})(?:\.\d\d)" time_format = "%m/%d/%Y %H:%M:%S" + time_manage: + time_command = date +'TIME: %a %m/%d/%Y %H:%M:%S.%N' + time_filter_re = "(?:TIME: \w\w\w )(.{19})(?:\.\d\d)" + time_format = "%m/%d/%Y %H:%M:%S" file_transfer: tmp_dir = /tmp/ clean_cmd = rm -f @@ -1415,6 +1419,11 @@ variants: time_command = "echo TIME: %date% %time%" time_filter_re = "(?<=TIME: \w\w\w ).{19}(?=\.\d\d)" time_format = "%m/%d/%Y %H:%M:%S" + time_manage: + alive_test_cmd = systeminfo + time_command = "echo TIME: %date% %time%" + time_filter_re = "(?<=TIME: \w\w\w ).{19}(?=\.\d\d)" + time_format = "%m/%d/%Y %H:%M:%S" guest_s4: check_s4_support_cmd = powercfg /hibernate on test_s4_cmd = start ping -t localhost diff --git a/client/virt/subtests.cfg.sample b/client/virt/subtests.cfg.sample index 099f28e..875e464 100644 --- a/client/virt/subtests.cfg.sample +++ b/client/virt/subtests.cfg.sample @@ -1026,6 +1026,18 @@ variants: drift_threshold = 10 drift_threshold_single = 3 + - time_manage: + type = time_manage + kill_vm = yes + extra_params +=" -rtc base=utc,driftfix=slew -snapshot" + host_load_command = stress --vm 1 --vm-bytes 4G --vm-keep + host_load_kill_command = killall stress + reboot_method = shell + alive_test_cmd = uname -a + # Set the max_itrs(iterations) and max_vms + max_itrs = 15 + max_vms = 4 + - balloon_check: install setup image_copy unattended_install.cdrom no Win2000, Fedora.8, Fedora.9, Fedora.10, RHEL.3, RHEL.4, Unix, livecd type = balloon_check -- 1.7.5.4 _______________________________________________ Autotest mailing list Autotest@test.kernel.org http://test.kernel.org/cgi-bin/mailman/listinfo/autotest