Skip to content

Commit 053da21

Browse files
committed
add case for migrating guest while scp files
xxxx-95968 - [virtual network][virtual-nic-device] Migrate guest while scp files Signed-off-by: nanli <nanli@redhat.com>
1 parent a302a6f commit 053da21

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
- virtual_network.qemu_test.migrate_with_file_transfer:
2+
type = migrate_with_file_transfer
3+
create_vm_libvirt = "yes"
4+
kill_vm_libvirt = "yes"
5+
start_vm = "yes"
6+
take_regular_screendumps = no
7+
storage_type = 'nfs'
8+
setup_local_nfs = 'yes'
9+
disk_type = "file"
10+
disk_source_protocol = "netfs"
11+
nfs_mount_dir = "/var/lib/libvirt/migrate"
12+
nfs_mount_options = "soft,timeo=50,retrans=3"
13+
virsh_migrate_dest_state = running
14+
virsh_migrate_options = "--live --p2p --verbose"
15+
virsh_migrate_connect_uri = "qemu:///system"
16+
migration_setup = "yes"
17+
ssh_remote_auth = True
18+
mnt_path_name = ${nfs_mount_dir}
19+
nfs_server_ip = "${migrate_source_host}"
20+
migrate_desturi_port = "22"
21+
migrate_desturi_type = "ssh"
22+
virsh_migrate_desturi = "qemu+ssh://${migrate_dest_host}/system"
23+
migrate_main_vm = "${main_vm}"
24+
login_timeout = "360"
25+
migrate_speed = 15
26+
iterations = 1
27+
guest_path = "/tmp/file"
28+
file_size = "500"
29+
transfer_timeout = "240"
30+
migrate_vm_back = "no"
31+
migration_type = "precopy"
32+
virsh_migrate_extra = ""
33+
action_during_mig = [{"func": "utils_test.run_file_transfer", "func_param": {"test": params.get('test'), "params": params.get('params'), "env": params.get('env')}}]
34+
Windows:
35+
guest_path = "C:\\tmpfile"
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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

Comments
 (0)