Index: client/virt/virt_test_utils.py |
diff --git a/client/tests/kvm/kvm_test_utils.py b/client/virt/virt_test_utils.py |
similarity index 96% |
rename from client/tests/kvm/kvm_test_utils.py |
rename to client/virt/virt_test_utils.py |
index b5c4a24e642e92a0b49396f25d22f2de6533edff..e3a18d2f7f5c77504e8a0d202d0394a8a12cc2b9 100644 |
--- a/client/tests/kvm/kvm_test_utils.py |
+++ b/client/virt/virt_test_utils.py |
@@ -24,7 +24,8 @@ More specifically: |
import time, os, logging, re, signal |
from autotest_lib.client.common_lib import error |
from autotest_lib.client.bin import utils |
-import kvm_utils, kvm_vm, kvm_subprocess, scan_results |
+from autotest_lib.client.tools import scan_results |
+import aexpect, virt_utils, virt_vm |
def get_living_vm(env, vm_name): |
@@ -66,7 +67,7 @@ def wait_for_login(vm, nic_index=0, timeout=240, start=0, step=2, serial=None): |
try: |
session = vm.serial_login() |
break |
- except kvm_utils.LoginError, e: |
+ except virt_utils.LoginError, e: |
logging.debug(e) |
time.sleep(step) |
else: |
@@ -78,7 +79,7 @@ def wait_for_login(vm, nic_index=0, timeout=240, start=0, step=2, serial=None): |
try: |
session = vm.login(nic_index=nic_index) |
break |
- except (kvm_utils.LoginError, kvm_vm.VMError), e: |
+ except (virt_utils.LoginError, virt_vm.VMError), e: |
logging.debug(e) |
time.sleep(step) |
if not session: |
@@ -130,7 +131,7 @@ def reboot(vm, session, method="shell", sleep_before_reset=10, nic_index=0, |
logging.error("Unknown reboot method: %s", method) |
# Wait for the session to become unresponsive and close it |
- if not kvm_utils.wait_for(lambda: not session.is_responsive(timeout=30), |
+ if not virt_utils.wait_for(lambda: not session.is_responsive(timeout=30), |
120, 0, 1): |
raise error.TestFail("Guest refuses to go down") |
session.close() |
@@ -191,7 +192,7 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", |
o.get("status") == "canceled") |
def wait_for_migration(): |
- if not kvm_utils.wait_for(mig_finished, mig_timeout, 2, 2, |
+ if not virt_utils.wait_for(mig_finished, mig_timeout, 2, 2, |
"Waiting for migration to finish..."): |
raise error.TestFail("Timeout expired while waiting for migration " |
"to finish") |
@@ -226,7 +227,7 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp", |
if mig_cancel: |
time.sleep(2) |
vm.monitor.cmd("migrate_cancel") |
- if not kvm_utils.wait_for(mig_cancelled, 60, 2, 2, |
+ if not virt_utils.wait_for(mig_cancelled, 60, 2, 2, |
"Waiting for migration " |
"cancellation"): |
raise error.TestFail("Failed to cancel migration") |
@@ -556,7 +557,7 @@ def run_autotest(vm, session, control_path, timeout, outputdir, params): |
try: |
session.cmd("rm -f control.state") |
session.cmd("rm -rf results/*") |
- except kvm_subprocess.ShellError: |
+ except aexpect.ShellError: |
pass |
try: |
bg = None |
@@ -566,7 +567,7 @@ def run_autotest(vm, session, control_path, timeout, outputdir, params): |
mig_timeout = float(params.get("mig_timeout", "3600")) |
mig_protocol = params.get("migration_protocol", "tcp") |
- bg = kvm_utils.Thread(session.cmd_output, |
+ bg = virt_utils.Thread(session.cmd_output, |
kwargs={'cmd': "bin/autotest control", |
'timeout': timeout, |
'print_func': logging.info}) |
@@ -584,7 +585,7 @@ def run_autotest(vm, session, control_path, timeout, outputdir, params): |
logging.info("------------- End of test output ------------") |
if migrate_background and bg: |
bg.join() |
- except kvm_subprocess.ShellTimeoutError: |
+ except aexpect.ShellTimeoutError: |
if vm.is_alive(): |
get_results() |
get_results_summary() |
@@ -593,7 +594,7 @@ def run_autotest(vm, session, control_path, timeout, outputdir, params): |
else: |
raise error.TestError("Autotest job on guest failed " |
"(VM terminated during job)") |
- except kvm_subprocess.ShellProcessTerminatedError: |
+ except aexpect.ShellProcessTerminatedError: |
get_results() |
raise error.TestError("Autotest job on guest failed " |
"(Remote session terminated during job)") |
@@ -643,14 +644,14 @@ def raw_ping(command, timeout, session, output_func): |
@param session: Local executon hint or session to execute the ping command. |
""" |
if session is None: |
- process = kvm_subprocess.run_bg(command, output_func=output_func, |
+ process = aexpect.run_bg(command, output_func=output_func, |
timeout=timeout) |
# Send SIGINT signal to notify the timeout of running ping process, |
# Because ping have the ability to catch the SIGINT signal so we can |
# always get the packet loss ratio even if timeout. |
if process.is_alive(): |
- kvm_utils.kill_process_tree(process.get_pid(), signal.SIGINT) |
+ virt_utils.kill_process_tree(process.get_pid(), signal.SIGINT) |
status = process.get_status() |
output = process.get_output() |
@@ -662,13 +663,13 @@ def raw_ping(command, timeout, session, output_func): |
try: |
output = session.cmd_output(command, timeout=timeout, |
print_func=output_func) |
- except kvm_subprocess.ShellTimeoutError: |
+ except aexpect.ShellTimeoutError: |
# Send ctrl+c (SIGINT) through ssh session |
session.send("\003") |
try: |
output2 = session.read_up_to_prompt(print_func=output_func) |
output += output2 |
- except kvm_subprocess.ExpectTimeoutError, e: |
+ except aexpect.ExpectTimeoutError, e: |
output += e.output |
# We also need to use this session to query the return value |
session.send("\003") |
@@ -676,7 +677,7 @@ def raw_ping(command, timeout, session, output_func): |
session.sendline(session.status_test_command) |
try: |
o2 = session.read_up_to_prompt() |
- except kvm_subprocess.ExpectError: |
+ except aexpect.ExpectError: |
status = -1 |
else: |
try: |