1import logging, time, random 2 3 4def run_ioquit(test, params, env): 5 """ 6 Emulate the poweroff under IO workload(dd so far) using kill -9. 7 8 @param test: Kvm test object 9 @param params: Dictionary with the test parameters. 10 @param env: Dictionary with test environment. 11 """ 12 vm = env.get_vm(params["main_vm"]) 13 vm.verify_alive() 14 login_timeout = int(params.get("login_timeout", 360)) 15 session = vm.wait_for_login(timeout=login_timeout) 16 session2 = vm.wait_for_login(timeout=login_timeout) 17 try: 18 bg_cmd = params.get("background_cmd") 19 logging.info("Add IO workload for guest OS.") 20 session.cmd_output(bg_cmd, timeout=60) 21 check_cmd = params.get("check_cmd") 22 session2.cmd(check_cmd, timeout=60) 23 24 logging.info("Sleep for a while") 25 time.sleep(random.randrange(30, 100)) 26 session2.cmd(check_cmd, timeout=60) 27 logging.info("Kill the virtual machine") 28 vm.process.close() 29 finally: 30 session.close() 31 session2.close() 32