|
| 1 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 2 | +# |
| 3 | +# Copyright Redhat |
| 4 | +# |
| 5 | +# SPDX-License-Identifier: GPL-2.0 |
| 6 | +# |
| 7 | +# Author: Liping Cheng <[email protected]> |
| 8 | +# |
| 9 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 | + |
| 11 | +from virttest import remote |
| 12 | +from virttest import utils_libvirtd |
| 13 | +from virttest import virsh |
| 14 | + |
| 15 | +from virttest.utils_test import libvirt |
| 16 | + |
| 17 | +from provider.migration import base_steps |
| 18 | + |
| 19 | + |
| 20 | +def run(test, params, env): |
| 21 | + """ |
| 22 | + This case is to test stopping virtqemud on the source/destination |
| 23 | + during migration. |
| 24 | +
|
| 25 | + :param test: test object |
| 26 | + :param params: Dictionary with the test parameters |
| 27 | + :param env: Dictionary with test environment. |
| 28 | + """ |
| 29 | + def verify_test(): |
| 30 | + """ |
| 31 | + Verify migration result |
| 32 | +
|
| 33 | + """ |
| 34 | + server_ip = params.get("server_ip") |
| 35 | + server_user = params.get("server_user", "root") |
| 36 | + server_pwd = params.get("server_pwd") |
| 37 | + dest_uri = params.get("virsh_migrate_desturi") |
| 38 | + expected_src_state = params.get("expected_src_state") |
| 39 | + expected_dest_state = params.get("expected_dest_state") |
| 40 | + test_case = params.get("test_case") |
| 41 | + |
| 42 | + func_returns = dict(migration_obj.migration_test.func_ret) |
| 43 | + migration_obj.migration_test.func_ret.clear() |
| 44 | + test.log.debug("Migration returns function results: %s", func_returns) |
| 45 | + if test_case == "stop_dst_virtqemud": |
| 46 | + dst_session = remote.wait_for_login('ssh', server_ip, '22', |
| 47 | + server_user, server_pwd, |
| 48 | + r"[\#\$]\s*$") |
| 49 | + utils_libvirtd.Libvirtd("virtqemud", session=dst_session).start() |
| 50 | + dst_session.close() |
| 51 | + if expected_dest_state and expected_dest_state == "nonexist": |
| 52 | + virsh.domstate(vm_name, uri=dest_uri, debug=True) |
| 53 | + if virsh.domain_exists(vm_name, uri=dest_uri): |
| 54 | + test.fail("The domain on target host is found, but expected not.") |
| 55 | + if test_case == "stop_src_virtqemud": |
| 56 | + utils_libvirtd.Libvirtd("virtqemud").start() |
| 57 | + if expected_src_state: |
| 58 | + if not libvirt.check_vm_state(vm.name, expected_src_state, uri=migration_obj.src_uri): |
| 59 | + test.fail("Migrated VM failed to be in %s state at source." % expected_src_state) |
| 60 | + |
| 61 | + vm_name = params.get("migrate_main_vm") |
| 62 | + vm = env.get_vm(vm_name) |
| 63 | + migration_obj = base_steps.MigrationBase(test, vm, params) |
| 64 | + |
| 65 | + try: |
| 66 | + migration_obj.setup_connection() |
| 67 | + migration_obj.run_migration() |
| 68 | + verify_test() |
| 69 | + migration_obj.run_migration_again() |
| 70 | + migration_obj.verify_default() |
| 71 | + finally: |
| 72 | + migration_obj.cleanup_connection() |
0 commit comments