|
| 1 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 2 | +# |
| 3 | +# Copyright Redhat |
| 4 | +# |
| 5 | +# SPDX-License-Identifier: GPL-2.0 |
| 6 | +# |
| 7 | +# Author: Nannan Li <nanli@redhat.com> |
| 8 | +# |
| 9 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 | + |
| 11 | +from virttest.libvirt_xml.vm_xml import VMXML |
| 12 | + |
| 13 | +from provider.migration import base_steps |
| 14 | +from provider.virtual_network import network_base |
| 15 | + |
| 16 | + |
| 17 | +def run(test, params, env): |
| 18 | + """ |
| 19 | + Test file transfer during migration |
| 20 | +
|
| 21 | + :param test: test object |
| 22 | + :param params: Dictionary with the test parameters |
| 23 | + :param env: Dictionary with test environment. |
| 24 | + """ |
| 25 | + |
| 26 | + def run_test(): |
| 27 | + """ |
| 28 | + Test file transfer during migration |
| 29 | + """ |
| 30 | + test.log.info("TEST_STEP 1:Guest xml is: %s\n", VMXML.new_from_dumpxml(vm_name)) |
| 31 | + |
| 32 | + test.log.info("TEST_STEP 2: Starting migration with file transfers") |
| 33 | + migration_obj.setup_connection() |
| 34 | + if not vm.is_alive(): |
| 35 | + vm.start() |
| 36 | + migration_obj.run_migration() |
| 37 | + |
| 38 | + test.log.info("TEST_STEP 3: Testing network connectivity on destination host") |
| 39 | + backup_uri = vm.connect_uri |
| 40 | + vm.connect_uri = dest_uri |
| 41 | + |
| 42 | + session = vm.wait_for_login(timeout=login_timeout) |
| 43 | + ips = {'outside_ip': outside_ip} |
| 44 | + network_base.ping_check(params, ips, session) |
| 45 | + session.close() |
| 46 | + vm.connect_uri = backup_uri |
| 47 | + |
| 48 | + if migrate_vm_back: |
| 49 | + test.log.info("TEST_STEP4: Migrating VM back to source host") |
| 50 | + migration_obj.run_migration_back() |
| 51 | + |
| 52 | + def teardown_test(): |
| 53 | + """ |
| 54 | + Cleanup test environment |
| 55 | + """ |
| 56 | + migration_obj.cleanup_connection() |
| 57 | + |
| 58 | + vm_name = params.get("main_vm") |
| 59 | + vm = env.get_vm(vm_name) |
| 60 | + dest_uri = params.get("virsh_migrate_desturi") |
| 61 | + migrate_vm_back = params.get_boolean("migrate_vm_back", True) |
| 62 | + login_timeout = params.get_numeric("login_timeout", "240") |
| 63 | + outside_ip = params.get("outside_ip", "8.8.8.8") |
| 64 | + |
| 65 | + # Add required objects to params for action_during_mig |
| 66 | + params.update({"params": params, "test": test, "env": env}) |
| 67 | + |
| 68 | + migration_obj = base_steps.MigrationBase(test, vm, params) |
| 69 | + |
| 70 | + try: |
| 71 | + run_test() |
| 72 | + finally: |
| 73 | + teardown_test() |
0 commit comments