KVM test: Add the ability to test migration during guest installation
PATCH 1/2 KVM test: Add the ability to test migration during guest installation
From: Jason Wang <[email protected]>
It's helpful to test the installation during migration. So patch just reuse the unattended installation tests and migrate the vm during the wait loop. The params of "-initrd", "-kernel" and "-append" were also dropped as they may break the migration.
Changes from v1:
- Use the new super cool vm.migrate() method
--- client/tests/kvm/tests/unattended_install.py | 22 ++++++++++++++++++++-- client/tests/kvm/tests_base.cfg.sample | 3 +++ 2 files changed, 23 insertions(+), 2 deletions(-)
client/tests/kvm/tests/unattended_install.py +20 -2
@@ -1,4 +1,4 @@ -import logging, time, socket +import logging, time, socket, re from autotest_lib.client.common_lib import error import kvm_utils, kvm_test_utils
@@ -24,6 +24,11 @@ def run_unattended_install(test, params, env): post_install_delay = 0 install_timeout = float(params.get("timeout", 3000)) + migrate_background = params.get("migrate_background") == "yes" + if migrate_background: + mig_timeout = float(params.get("mig_timeout", "3600")) + mig_protocol = params.get("migration_protocol", "tcp") + logging.info("Starting unattended install watch process. " "Timeout set to %ds (%d min)", install_timeout, install_timeout/60)
@@ -46,7 +51,20 @@ def run_unattended_install(test, params, env): break except socket.error: pass - time.sleep(1) + + if migrate_background: + # Drop the params which may break the migration + # Better method is to used dnsmasq to do the unattended installation + if vm.params.get("initrd"): + vm.params["initrd"] = None + if vm.params.get("kernel"): + vm.params["kernel"] = None + if vm.params.get("extra_params"): + vm.params["extra_params"] = re.sub("--append '.*'", "", + vm.params["extra_params"]) + vm.migrate(timeout=mig_timeout, protocol=mig_protocol) + else: + time.sleep(1) client.close() end_time = time.time() time_elapsed = int(end_time - start_time)
client/tests/kvm/tests_base.cfg.sample +3 -0
@@ -103,6 +103,9 @@ variants: kernel = vmlinuz initrd = initrd.img nic_mode = tap + # uncomment the following line to test the migration in parallel + # migrate_with_background = yes + variants: # Install guest from cdrom - cdrom:
Signature · 1 line
1.7.3.4
PATCH 2/2 KVM test: Run client tests of autotest in parallel with migration
From: Jason Wang <[email protected]>
Run some workload in the background and do the migration would be helpful to verfiy the correctness, so this patch use the Thread class to wait for the completion of autotest cmd -- "bin/autotest control" and do the migration in parallel.
Changes from v1:
- Use the new super cool vm.migrate() method
--- client/tests/kvm/kvm_test_utils.py | 33 +++++++++++++++++++++++++++++-- client/tests/kvm/tests/autotest.py | 5 +++- client/tests/kvm/tests_base.cfg.sample | 11 ++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-)
client/tests/kvm/kvm_test_utils.py +30 -3
@@ -429,7 +429,7 @@ def get_memory_info(lvms): return meminfo -def run_autotest(vm, session, control_path, timeout, outputdir): +def run_autotest(vm, session, control_path, timeout, outputdir, params): """ Run an autotest control file inside a guest (linux only utility).
@@ -439,6 +439,9 @@ def run_autotest(vm, session, control_path, timeout, outputdir): @param timeout: Timeout under which the autotest control file must complete. @param outputdir: Path on host where we should copy the guest autotest results to. + + The following params is used by the migration + @param params: Test params used in the migration test """ def copy_if_hash_differs(vm, local_path, remote_path): """
@@ -515,6 +518,11 @@ def run_autotest(vm, session, control_path, timeout, outputdir): raise error.TestError("Invalid path to autotest control file: %s" % control_path) + migrate_background = params.get("migrate_background") == "yes" + if migrate_background: + mig_timeout = float(params.get("mig_timeout", "3600")) + mig_protocol = params.get("migration_protocol", "tcp") + compressed_autotest_path = "/tmp/autotest.tar.bz2" # To avoid problems, let's make the test use the current AUTODIR
@@ -551,12 +559,31 @@ def run_autotest(vm, session, control_path, timeout, outputdir): except kvm_subprocess.ShellError: pass try: + bg = None try: logging.info("---------------- Test output ----------------") - session.cmd_output("bin/autotest control", timeout=timeout, - print_func=logging.info) + if migrate_background: + mig_timeout = float(params.get("mig_timeout", "3600")) + mig_protocol = params.get("migration_protocol", "tcp") + + bg = kvm_utils.Thread(session.cmd_output, + kwargs={'cmd': "bin/autotest control", + 'timeout': timeout, + 'print_func': logging.info}) + + bg.start() + + while bg.is_alive(): + logging.info("Tests is not ended, start a round of" + "migration ...") + vm.migrate(timeout=mig_timeout, protocol=mig_protocol) + else: + session.cmd_output("bin/autotest control", timeout=timeout, + print_func=logging.info) finally: logging.info("------------- End of test output ------------") + if migrate_background and bg: + bg.join() except kvm_subprocess.ShellTimeoutError: if vm.is_alive(): get_results()
client/tests/kvm/tests/autotest.py +4 -1
@@ -19,8 +19,11 @@ def run_autotest(test, params, env): # Collect test parameters timeout = int(params.get("test_timeout", 300)) + migrate = params.get("migrate" , "no") == "yes" control_path = os.path.join(test.bindir, "autotest_control", params.get("test_control_file")) outputdir = test.outputdir - kvm_test_utils.run_autotest(vm, session, control_path, timeout, outputdir) + kvm_test_utils.run_autotest(vm, session, control_path, timeout, outputdir, + params) +
client/tests/kvm/tests_base.cfg.sample +11 -0
@@ -170,6 +170,17 @@ variants: - with_file_transfer: iterations = 1 type = migration_with_file_transfer + - with_autotest: + type = autotest + migrate_background = yes + test_timeout = 1800 + variants: + - dbench: + test_control_file = dbench.control + - stress: + test_control_file = stress.control + - monotonic_time: + test_control_file = monotonic_time.control - migrate_multi_host: install setup unattended_install.cdrom type = migration_multi_host
Signature · 1 line
1.7.3.4
Re: [PATCH 2/2] KVM test: Run client tests of autotest in parallel with migration
Quoted 41 lines · Lucas Meneghel Rodrigues
From: Jason Wang <[email protected]>
Run some workload in the background and do the migration would be helpful to verfiy the correctness, so this patch use the Thread class to wait for the completion of autotest cmd -- "bin/autotest control" and do the migration in parallel.
Changes from v1:
- Use the new super coolvm.migrate()methodSigned-off-by Jason Wang <[email protected]>--- client/tests/kvm/kvm_test_utils.py | 33 +++++++++++++++++++++++++++++-- client/tests/kvm/tests/autotest.py | 5 +++- client/tests/kvm/tests_base.cfg.sample | 11 ++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-)client/tests/kvm/kvm_test_utils.py +4
-1@@ -429,7 +429,7 @@ def get_memory_info(lvms): return meminfo -def run_autotest(vm, session, control_path, timeout, outputdir): +def run_autotest(vm, session, control_path, timeout, outputdir, params): """ Run an autotest control file inside a guest (linux only utility).@@ -439,6 +439,9 @@ def run_autotest(vm, session, control_path, timeout, outputdir): @param timeout: Timeout under which the autotest control file must complete. @param outputdir: Path on host where we should copy the guest autotest results to. + + The following params is used by the migration + @param params: Test params used in the migration test """ def copy_if_hash_differs(vm, local_path, remote_path): """
client/tests/kvm/kvm_test_utils.py def run_autotest(vm, session, control_path, timeout, outputdir): · line 524
Quoted 7 lines
client/tests/kvm/kvm_test_utils.py +4
-0@@ -515,6 +518,11 @@ def run_autotest(vm, session, control_path, timeout, outputdir): raise error.TestError("Invalid path to autotest control file: %s" % control_path) + migrate_background = params.get("migrate_background") == "yes" + if migrate_background: + mig_timeout = float(params.get("mig_timeout", "3600")) + mig_protocol = params.get("migration_protocol", "tcp")
Don't you think it's a cleaner to extract these parameters from params outside this function (in the autotest wrapper test) and pass them to this function instead of the params dict? We only need mig_protocol and mig_timeout. Migration will take place if mig_protocol is a nonempty string.
Alternatively, we can move the contents of this function back to the test itself, because there's only 1 test using this function, and then we can look at params directly like all tests do.
Quoted 76 lines
client/tests/kvm/kvm_test_utils.py +21
-2compressed_autotest_path = "/tmp/autotest.tar.bz2" # To avoid problems, let's make the test use the current AUTODIR@@ -551,12 +559,31 @@ def run_autotest(vm, session, control_path, timeout, outputdir): except kvm_subprocess.ShellError: pass try: + bg = None try: logging.info("---------------- Test output ----------------") - session.cmd_output("bin/autotest control", timeout=timeout, - print_func=logging.info) + if migrate_background: + mig_timeout = float(params.get("mig_timeout", "3600")) + mig_protocol = params.get("migration_protocol", "tcp") + + bg = kvm_utils.Thread(session.cmd_output, + kwargs={'cmd': "bin/autotest control", + 'timeout': timeout, + 'print_func': logging.info}) + + bg.start() + + while bg.is_alive(): + logging.info("Tests is not ended, start a round of" + "migration ...") + vm.migrate(timeout=mig_timeout, protocol=mig_protocol) + else: + session.cmd_output("bin/autotest control", timeout=timeout, + print_func=logging.info) finally: logging.info("------------- End of test output ------------") + if migrate_background and bg: + bg.join() except kvm_subprocess.ShellTimeoutError: if vm.is_alive(): get_results()client/tests/kvm/tests/autotest.py +4
-1@@ -19,8 +19,11 @@ def run_autotest(test, params, env): # Collect test parameters timeout = int(params.get("test_timeout", 300)) + migrate = params.get("migrate" , "no") == "yes" control_path = os.path.join(test.bindir, "autotest_control", params.get("test_control_file")) outputdir = test.outputdir - kvm_test_utils.run_autotest(vm, session, control_path, timeout, outputdir) + kvm_test_utils.run_autotest(vm, session, control_path, timeout, outputdir, + params) +client/tests/kvm/tests_base.cfg.sample +11
-0@@ -170,6 +170,17 @@ variants: - with_file_transfer: iterations = 1 type = migration_with_file_transfer + - with_autotest: + type = autotest + migrate_background = yes + test_timeout = 1800 + variants: + - dbench: + test_control_file = dbench.control + - stress: + test_control_file = stress.control + - monotonic_time: + test_control_file = monotonic_time.control - migrate_multi_host: install setup unattended_install.cdrom type = migration_multi_host