@@ -77,6 +77,9 @@ variants:
- migrate: install setup
type = migration
migration_test_command = help
+ migration_bg_command = "cd /tmp; nohup tcpdump -q -t ip host localhost"
+ migration_bg_check_command = pgrep tcpdump
+ migration_bg_kill_command = pkill tcpdump
kill_vm_on_error = yes
iterations = 2
used_mem = 1024
@@ -499,6 +502,9 @@ variants:
migrate:
migration_test_command = ver && vol
+ migration_bg_command = start ping -t localhost
+ migration_bg_check_command = tasklist | find /I "ping.exe"
+ migration_bg_kill_command = taskkill /IM ping.exe /F
stress_boot:
alive_test_cmd = systeminfo
timedrift:
@@ -1,4 +1,4 @@
-import logging
+import logging, time
from autotest_lib.client.common_lib import error
import kvm_subprocess, kvm_test_utils, kvm_utils
@@ -20,33 +20,63 @@ def run_migration(test, params, env):
@param env: Dictionary with the test environment.
"""
vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-
- # Log into guest and get the output of migration_test_command
session = kvm_test_utils.wait_for_login(vm)
- migration_test_command = params.get("migration_test_command")
- reference_output = session.get_command_output(migration_test_command)
- session.close()
- # Migrate the VM
- dest_vm = kvm_test_utils.migrate(vm, env)
+ # Get the output of migration_test_command
+ test_command = params.get("migration_test_command")
+ reference_output = session.get_command_output(test_command)
- # Log into guest and get the output of migration_test_command
- logging.info("Logging into guest after migration...")
- session = dest_vm.remote_login()
- if not session:
- raise error.TestFail("Could not log into guest after migration")
- logging.info("Logged in after migration")
- output = session.get_command_output(migration_test_command)
- session.close()
+ # Start some process in the background (and leave the session open)
+ background_command = params.get("migration_bg_command", "")
+ session.sendline(background_command)
+ time.sleep(5)
+
+ # Start another session with the guest and make sure the background
+ # process is running
+ session2 = kvm_test_utils.wait_for_login(vm)
+
+ try:
+ check_command = params.get("migration_bg_check_command", "")
+ if session2.get_command_status(check_command, timeout=30) != 0:
+ raise error.TestError("Could not start background process '%s'" %
+ background_command)
+ session2.close()
+
+ # Migrate the VM
+ dest_vm = kvm_test_utils.migrate(vm, env)
- # Compare output to reference output
- if output != reference_output:
- logging.info("Command output before migration differs from command "
- "output after migration")
- logging.info("Command: %s" % params.get("migration_test_command"))
- logging.info("Output before:" +
- kvm_utils.format_str_for_message(reference_output))
- logging.info("Output after:" +
- kvm_utils.format_str_for_message(output))
- raise error.TestFail("Command produced different output before and "
- "after migration")
+ # Log into the guest again
+ logging.info("Logging into guest after migration...")
+ session2 = kvm_utils.wait_for(dest_vm.remote_login, 30, 0, 2)
+ if not session2:
+ raise error.TestFail("Could not log into guest after migration")
+ logging.info("Logged in after migration")
+
+ # Make sure the background process is still running
+ if session2.get_command_status(check_command, timeout=30) != 0:
+ raise error.TestFail("Could not find running background process "
+ "after migration: '%s'" % background_command)
+
+ # Get the output of migration_test_command
+ output = session2.get_command_output(test_command)
+
+ # Compare output to reference output
+ if output != reference_output:
+ logging.info("Command output before migration differs from "
+ "command output after migration")
+ logging.info("Command: %s" % test_command)
+ logging.info("Output before:" +
+ kvm_utils.format_str_for_message(reference_output))
+ logging.info("Output after:" +
+ kvm_utils.format_str_for_message(output))
+ raise error.TestFail("Command '%s' produced different output "
+ "before and after migration" % test_command)
+
+ finally:
+ # Kill the background process
+ if session2.is_alive():
+ session2.get_command_output(params.get("migration_bg_kill_command",
+ ""))
+
+ session2.close()
+ session.close()
@@ -49,7 +49,7 @@ def run_timedrift_with_migration(test, params, env):
vm = kvm_test_utils.migrate(vm, env)
# Log in
logging.info("Logging in after migration...")
- session = vm.remote_login()
+ session = kvm_utils.wait_for(vm.remote_login, 30, 0, 2)
if not session:
raise error.TestFail("Could not log in after migration")
logging.info("Logged in after migration")