def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') share_images_dir = params.get('share_images_dir') matrix = params.get('matrix') disk1_name = params.get('disk1_name').split('.')[0] disk1_format = params.get('disk1_name').split('.')[1] disk2_name = params.get('disk2_name').split('.')[0] disk2_format = params.get('disk2_name').split('.')[1] disk3_name = params.get('disk3_name').split('.')[0] disk3_format = params.get('disk3_name').split('.')[1] disk4_name = params.get('disk4_name').split('.')[0] disk4_format = params.get('disk4_name').split('.')[1] disk5_name = params.get('disk5_name').split('.')[0] disk5_format = params.get('disk5_name').split('.')[1] iso = params.get('cdrom1_name') test = CreateTest(case_id='rhel_135046', params=params) id = test.get_id() src_host_session = HostSession(id, params) test.test_print('=======Create test environment=======') test.sub_step_log('~~~~1. Create 5 data disks~~~~') utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk1_name, disk_format=disk1_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk2_name, disk_format=disk2_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk3_name, disk_format=disk3_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk4_name, disk_format=disk4_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk5_name, disk_format=disk5_format, disk_size=2048) test.sub_step_log('~~~~2. Create 1 iso~~~~') utils_stable_abi_ppc.create_iso(host_session=src_host_session, disk_dir=share_images_dir, iso=iso) test.sub_step_log('~~~~3. Configure host hugepage~~~~') utils_stable_abi_ppc.configure_host_hugepage( host_session=src_host_session, matrix=matrix, dst_ip=dst_host_ip, mount_point='/mnt/kvm_hugepage') test.sub_step_log('~~~~4. Check matrix~~~~') flag = utils_stable_abi_ppc.check_matrix(host_session=src_host_session, dst_ip=dst_host_ip, matrix=matrix) test.main_step_log('1. start guest on Source Host host must have ' 'following devices') if (flag == 'p9_to_p8'): params.vm_base_cmd_update( 'machine', 'pseries', 'pseries-rhel7.3.0-sxxm,max-cpu-compat=power8') else: params.vm_base_cmd_update('machine', 'pseries', 'pseries-rhel7.3.0-sxxm') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') test.sub_step_log('1.1 Connecting to src serial') src_remote_qmp = RemoteQMPMonitor(id, params, ip=src_host_ip, port=qmp_port) src_serial = RemoteSerialMonitor(id, params, ip=src_host_ip, port=serial_port) src_guest_ip = src_serial.serial_login() test.sub_step_log('2 Start guest on Destination Host host with same ' 'qemu cli as step1 but appending') if (flag == 'p8_to_p9'): params.vm_base_cmd_update( 'machine', 'pseries-rhel7.3.0-sxxm', 'pseries-rhel7.3.0-sxxm,max-cpu-compat=power8') elif (flag == 'p9_to_p8'): params.vm_base_cmd_update( 'machine', 'pseries-rhel7.3.0-sxxm,max-cpu-compat=power8', 'pseries-rhel7.3.0-sxxm') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) params.vm_base_cmd_update( 'chardev', 'socket,id=serial_id_serial0,host=%s,' 'port=%s,server,nowait' % (src_host_ip, serial_port), 'socket,id=serial_id_serial0,host=%s,port=%s,' 'server,nowait' % (dst_host_ip, serial_port)) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, ip=dst_host_ip, port=qmp_port) test.main_step_log( '3.In guest, execute the program to generate dirty pages') src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) utils_migration.dirty_page_test(host_session=src_host_session, guest_session=src_guest_session, guest_ip=src_guest_ip, script='migration_dirtypage_2.c') test.main_step_log('4.Enable postcopy on both sides and do migration') utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp, capabilities='postcopy-ram', state='true') utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp, capabilities='postcopy-ram', state='true') cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}'\ % (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd=cmd) test.main_step_log('5.check the migration status, after generating dirty ' 'pages, change to postcopy mode') utils_migration.switch_to_postcopy(remote_qmp=src_remote_qmp) chk_info = utils_migration.query_migration(remote_qmp=src_remote_qmp) if chk_info == False: test.test_error('Migration timeout') test.main_step_log('6.Check devices function one by one') dst_serial = RemoteSerialMonitor(id, params, ip=dst_host_ip, port=serial_port) output = dst_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') dst_guest_ip = dst_serial.serial_login() dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) test.sub_step_log('a.Check networking') dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('b.Check block by the following methods') utils_migration.filebench_test(dst_guest_session) test.sub_step_log('c.Check VNC console and check keyboard by input keys') time.sleep(3) test.main_step_log('7.Migrate the guest back to src host and please ' 'refer to step 4 and step 5') src_remote_qmp.qmp_cmd_output('{"execute":"quit"}') time.sleep(3) src_host_session.check_guest_process(src_ip=src_host_ip) if (flag == 'p8_to_p9'): params.vm_base_cmd_update( 'machine', 'pseries-rhel7.3.0-sxxm,max-cpu-compat=power8', 'pseries-rhel7.3.0-sxxm') elif (flag == 'p9_to_p8'): params.vm_base_cmd_update( 'machine', 'pseries-rhel7.3.0-sxxm', 'pseries-rhel7.3.0-sxxm,max-cpu-compat=power8') params.vm_base_cmd_update( 'chardev', 'socket,id=serial_id_serial0,host=%s,' 'port=%s,server,nowait' % (dst_host_ip, serial_port), 'socket,id=serial_id_serial0,host=%s,port=%s,' 'server,nowait' % (src_host_ip, serial_port)) src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, ip=src_host_ip, port=qmp_port) utils_migration.dirty_page_test(host_session=src_host_session, guest_session=dst_guest_session, guest_ip=dst_guest_ip, script='migration_dirtypage_2.c') utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp, capabilities='postcopy-ram', state='true') utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp, capabilities='postcopy-ram', state='true') cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}'\ % (src_host_ip, incoming_port) dst_remote_qmp.qmp_cmd_output(cmd=cmd) utils_migration.switch_to_postcopy(remote_qmp=dst_remote_qmp) chk_info = utils_migration.query_migration(remote_qmp=dst_remote_qmp) if chk_info == False: test.test_error('Migration timeout') test.main_step_log('8.Repeat step6') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) output = src_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('a.Check networking') src_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('b.Check block by the following methods') utils_migration.filebench_test(src_guest_session) test.sub_step_log('c.Check VNC console and check keyboard by input keys')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_93722', params=params) id = test.get_id() src_host_session = HostSession(id, params) size = '2147483648' test.main_step_log('1.configure hugepage(both src and dst)') output = src_host_session.host_cmd_output(cmd='lscpu') if re.findall(r'POWER8', output): matrix = 'P8_P8' elif re.findall(r'POWER9', output): matrix = 'P9_P9' utils_stable_abi_ppc.configure_host_hugepage( host_session=src_host_session, matrix=matrix, dst_ip=dst_host_ip, mount_point='/mnt/kvm_hugepage') test.main_step_log( '2.Boot a guest with hugepage memdev and numa on src host') params.vm_base_cmd_add( 'object', 'memory-backend-file,id=ram-node0,prealloc=yes,' 'mem-path=/dev/hugepages,size=%s' % size) params.vm_base_cmd_add('numa', 'node,nodeid=0,cpus=0-1,memdev=ram-node0') params.vm_base_cmd_add( 'object', 'memory-backend-file,id=ram-node1,prealloc=yes,' 'mem-path=/dev/hugepages,size=%s' % size) params.vm_base_cmd_add('numa', 'node,nodeid=1,cpus=2-3,memdev=ram-node1') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_serial.serial_login() test.main_step_log('3. Boot a guest on dst host') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('4.On src host and dst host, ' 'enable postcopy and do migration') test.sub_step_log('set src host postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp, capabilities='postcopy-ram', state='true') test.sub_step_log('set dst host postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp, capabilities='postcopy-ram', state='true') test.sub_step_log('start to do migration') cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \ % (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd=cmd) utils_migration.switch_to_postcopy(remote_qmp=src_remote_qmp, dirty_count_threshold=0) chk_info = utils_migration.query_migration(remote_qmp=src_remote_qmp) if chk_info == False: test.test_error('Migration timeout') test.sub_step_log('Check guest status after migration finished') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) output = dst_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10)
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10067', params=params) id = test.get_id() src_host_session = HostSession(id, params) downtime = '10000' query_migration_time = 1200 test.main_step_log('1. Start VM with high load, with each method is ok') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('1.2 Running iozone in src guest') utils_migration.iozone_test(guest_session=src_guest_session) test.main_step_log('2. Start listening mode') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. Set a reasonable downtime value for migration') downtime_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"downtime-limit": %s}}' % downtime src_remote_qmp.qmp_cmd_output(cmd=downtime_cmd) paras_chk_cmd = '{"execute":"query-migrate-parameters"}' output = src_remote_qmp.qmp_cmd_output(cmd=paras_chk_cmd) if re.findall(r'"downtime-limit": %s' % downtime, output): test.test_print('Change downtime successfully') else: test.test_error('Failed to change downtime') test.main_step_log('4.Do live migration') check_info = utils_migration.do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip, chk_timeout_2=query_migration_time) if (check_info == False): test.test_error('Migration timeout after changing downtime') test.main_step_log('5. Check the status of guest on dst host') test.sub_step_log('5.1. Reboot guest') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd) if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() test.sub_step_log('5.2 Ping external host') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('5.3 DD a file inside guest') cmd_dd = 'dd if=/dev/zero of=file1 bs=1M count=100 oflag=direct' output = dst_guest_session.guest_cmd_output(cmd=cmd_dd, timeout=600) if not output or re.findall('error', output): test.test_error('Failed to dd a file in guest') test.sub_step_log('5.4 Shutdown guest successfully') dst_serial.serial_shutdown_vm() output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: src_remote_qmp.test_error('Failed to quit qemu on src end')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10044', params=params) id = test.get_id() src_host_session = HostSession(id, params) speed = 33554432 downtime = 10000 gap_downtime = 5000 script = 'migration_dirtypage_2.c' test.main_step_log('1. guest with heavy memory load with either of ' 'the following methods') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.2 Run some program to generate dirty page') utils_migration.dirty_page_test(host_session=src_host_session, guest_session=src_guest_session, guest_ip=src_guest_ip, script=script) test.main_step_log('2. Start listening mode on dst host') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. Set a reasonable migrate downtime') downtime_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"downtime-limit": %d}}' % downtime src_remote_qmp.qmp_cmd_output(cmd=downtime_cmd) paras_chk_cmd = '{"execute":"query-migrate-parameters"}' output = src_remote_qmp.qmp_cmd_output(cmd=paras_chk_cmd) if re.findall(r'"downtime-limit": %d' % downtime, output): test.test_print('Set migration downtime successfully') else: test.test_error('Failed to change downtime') test.main_step_log('4. Do live migration.') check_info = utils_migration.do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip, downtime_val=downtime, speed_val=speed) if (check_info == False): test.test_error('Migration timeout') test.main_step_log('5. when the "Migration status" is "completed", ' 'check the "downtime" value') output = eval(src_remote_qmp.qmp_cmd_output('{"execute":"query-migrate"}')) real_downtime = int(output.get('return').get('downtime')) src_remote_qmp.test_print('The real downtime is: %d' % real_downtime) gap_cal = real_downtime - downtime if (gap_cal > gap_downtime): test.test_error('The real downtime value is much more than the value ' 'that you set by %s milliseconds' % gap_downtime) else: test.test_print('The real downtime value is not much more than ' 'the value that you set') test.main_step_log('6 Check the status of guest') test.sub_step_log('6.1. Reboot guest') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') dst_guest_ip = dst_serial.serial_login() test.sub_step_log('6.2 Ping external host') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('6.3 Shutdown guest successfully') dst_serial.serial_shutdown_vm() output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: src_remote_qmp.test_error('Failed to quit qemu on src end')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') share_images_dir = params.get('share_images_dir') test = CreateTest(case_id='rhel7_10040', params=params) id = test.get_id() src_host_session = HostSession(id, params) test.main_step_log('1. Boot guest with a system disk, a block data disk ' 'and a scsi data disk.') test.sub_step_log('1.1 Create two images on src host') d0 = 'd0' d1 = 'd1' qcow2 = 'qcow2' create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=d0, disk_format=qcow2, disk_size=1024) create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=d1, disk_format=qcow2, disk_size=1024) test.sub_step_log('1.2 Boot a guest') params.vm_base_cmd_add( 'drive', 'file=%s/d0.qcow2,format=qcow2,if=none,' 'id=drive-virtio-blk0,werror=stop,' 'rerror=stop' % share_images_dir) params.vm_base_cmd_add( 'device', 'virtio-blk-pci,drive=drive-virtio-blk0,' 'id=virtio-blk0,bus=pci.0,addr=10,' 'bootindex=10') params.vm_base_cmd_add( 'drive', 'file=%s/d1.qcow2,if=none,id=drive_r4,' 'format=qcow2,cache=none,aio=native,' 'werror=stop,rerror=stop' % share_images_dir) params.vm_base_cmd_add( 'device', 'scsi-hd,drive=drive_r4,id=r4,' 'bus=virtio_scsi_pci0.0,channel=0,' 'scsi-id=0,lun=1') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.3 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() test.main_step_log('2. In HMP, hot remove the block data disk ' 'and scsi data disk.') src_remote_qmp.qmp_cmd_output( '{"execute":"device_del","arguments":' '{"id":"virtio-blk0"}}', recv_timeout=5) src_remote_qmp.qmp_cmd_output( '{"execute":"device_del","arguments":' '{"id":"r4"}}', recv_timeout=5) test.sub_step_log('Check guest disk again') time.sleep(3) output = src_remote_qmp.qmp_cmd_output('{"execute":"query-block"}', recv_timeout=5) if re.findall(r'virtio-blk0', output) or re.findall(r'r4', output): src_remote_qmp.test_error('Failed to hot remove two data disks.') test.main_step_log('3. Boot guest with \'-incoming\' on des host ' 'with only system disk.') params.vm_base_cmd_del( 'drive', 'file=%s/d0.qcow2,format=qcow2,if=none,' 'id=drive-virtio-blk0,werror=stop,' 'rerror=stop' % share_images_dir) params.vm_base_cmd_del( 'device', 'virtio-blk-pci,drive=drive-virtio-blk0,' 'id=virtio-blk0,bus=pci.0,addr=10,' 'bootindex=10') params.vm_base_cmd_del( 'drive', 'file=%s/d1.qcow2,if=none,id=drive_r4,' 'format=qcow2,cache=none,aio=native,' 'werror=stop,rerror=stop' % share_images_dir) params.vm_base_cmd_del( 'device', 'scsi-hd,drive=drive_r4,id=r4,' 'bus=virtio_scsi_pci0.0,channel=0,' 'scsi-id=0,lun=1') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-block"}', recv_timeout=10) if re.findall('virtio-blk0', output) or re.findall('r4', output): dst_remote_qmp.test_error('Destination guest boot error') test.main_step_log('4. Start live migration from src host') flag = do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip) if (flag == False): test.test_error('Migration timeout') test.main_step_log('5. Check guest status. Reboot guest , guest has ' '1 system disk and keeps working well.') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd=cmd) if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace') test.sub_step_log('5.1 Reboot dst guest') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() test.sub_step_log('5.2 Check if guest only has 1 system disk') output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-block"}', recv_timeout=5) if re.findall('drive-virtio-blk0', output) or re.findall('r4', output): dst_remote_qmp.test_error('Destination guest has other disk ' 'except 1 system disk') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) output = dst_guest_session.guest_cmd_output(cmd='fdisk -l', timeout=60) if re.findall(r'/dev/sda', output): dst_guest_session.test_print('The system disk is in disk') test.sub_step_log('5.3 Can access guest from external host') dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('5.4 quit qemu on src end and shutdown vm on dst end') dst_serial.serial_shutdown_vm() output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}', recv_timeout=3) if output: src_remote_qmp.test_error('Failed to quit qemu on src host')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10056', params=params) id = test.get_id() src_host_session = HostSession(id, params) speed = '1073741824' active_timeout = 300 test.main_step_log('1. Start VM with high load, with each method is ok') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('1.2 Running stress in src guest') utils_migration.stress_test(guest_session=src_guest_session) test.main_step_log('2. Start listening mode on dst host and ' 'on src host do migration') test.sub_step_log('2.1 Start listening mode on dst host') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.sub_step_log('2.2. Do live migration from src to dst') cmd = '{"execute":"migrate", "arguments": {"uri": "tcp:%s:%s"}}' % \ (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd) test.main_step_log('3.Enlarge migration speed') flag_active = utils_migration.query_status(remote_qmp=src_remote_qmp, status='active') if (flag_active == False): src_remote_qmp.test_error('Migration could not be active within %d' % active_timeout) utils_migration.change_speed(remote_qmp=src_remote_qmp, speed_val=speed) test.sub_step_log('3.2 Check migration status again') flag_1 = utils_migration.query_migration(remote_qmp=src_remote_qmp) if (flag_1 == False): test.test_error('Migration timeout after changing speed') test.main_step_log('4. After migration, check if guest works well.') test.sub_step_log('4.1 Guest mouse and keyboard') test.sub_step_log('4.2. Reboot guest') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd=cmd) if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() test.sub_step_log('4.3 Ping external host') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10) test.sub_step_log('4.4 dd a file inside guest') cmd_dd = 'dd if=/dev/zero of=file1 bs=100M count=10 oflag=direct' output = dst_guest_session.guest_cmd_output(cmd=cmd_dd, timeout=600) if not output or re.findall('error', output): test.test_error('Failed to dd a file in guest') test.sub_step_log('4.5 Shutdown guest successfully') dst_serial.serial_shutdown_vm() output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}', recv_timeout=3) if output: src_remote_qmp.test_error('Failed to quit qemu on src end')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10061', params=params) id = test.get_id() guest_name = test.guest_name src_host_session = HostSession(id, params) test.main_step_log('1. Start VM in the src host, guest running stress') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('1.2 Running stress in src guest') utils_migration.stress_test(guest_session=src_guest_session) test.main_step_log('2. Start listening mode in the dst host.') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. Do live migration') cmd = '{"execute":"migrate", "arguments": {"uri": "tcp:%s:%s"}}' % ( dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd=cmd) test.sub_step_log('Check the status of migration') flag_active = utils_migration.query_status(remote_qmp=src_remote_qmp, status='active') if (flag_active == False): test.test_error('Migration is not active') test.main_step_log('4. During migration in progress, cancel migration') cmd = '{"execute":"migrate_cancel"}' src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=3) output = src_remote_qmp.qmp_cmd_output('{"execute":"query-migrate"}', recv_timeout=3) if re.findall(r'"status": "cancelled"', output): src_remote_qmp.test_print('Src cancel migration successfully') else: src_remote_qmp.test_error('Failed to cancel migration') test.main_step_log('5. Start listening mode againg in the dst host') test.sub_step_log('5.1 Check if the dst qemu quit automatically') dst_chk_cmd = 'ssh root@%s ps -axu | grep %s | grep -v grep' \ % (dst_host_ip, guest_name) output = src_host_session.host_cmd_output(cmd=dst_chk_cmd) if not output: src_host_session.test_print('DST QEMU quit automatically after ' 'src cancelling migration') else: src_host_session.test_error('DST QEMU does not quit automatically ' 'after src cancelling migration') test.sub_step_log('5.2 Start listening mode again in dst host') src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('6. Do live migration again') output = utils_migration.do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip) if (output == False): test.test_error('Migration timeout') test.main_step_log('7. After migration succeed, ' 'checking the status of guest on the dst host') test.sub_step_log('7.1 Guest keyboard and mouse work normally.') test.sub_step_log('7.2 Reboot guest') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd=cmd) if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() test.sub_step_log( '7.3 Ping external host/copy file between guest and host') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('7.4 DD a file inside guest') cmd_dd = 'dd if=/dev/zero of=file1 bs=1M count=100 oflag=direct' output = dst_guest_session.guest_cmd_output(cmd=cmd_dd, timeout=600) if not output or re.findall('error', output): test.test_error('Failed to dd a file in guest') test.sub_step_log('7.5 Shutdown guest successfully') dst_serial.serial_shutdown_vm()
def run_case(params): src_host_ip = params.get('src_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) test = CreateTest(case_id='rhel7_11912_virtio_scsi_local', params=params) id = test.get_id() host_session = HostSession(id, params) test.main_step_log('1. do system_reset when guest booting') qemu_cmd = params.create_qemu_cmd() host_session.boot_guest(qemu_cmd, vm_alias='src') test.sub_step_log('Connecting to serial') serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) timeout = 300 endtime = time.time() + timeout searched_str = 'Trying to load' searched_done = False while time.time() < endtime: output = serial.serial_output(max_recv_data=500, search_str=searched_str) if re.findall(r'Found the searched keyword', output): test.test_print(output) searched_done = True remote_qmp.qmp_cmd_output('{ "execute": "system_reset" }') break else: test.test_print(output) if re.findall(r'login:'******'Failed to find the keyword: %s' % searched_str) if searched_done == False: test.test_error('Failed to find the keyword: %s under %s.' % (searched_str, timeout)) guset_ip = serial.serial_login() guest_session = GuestSession(case_id=id, params=params, ip=guset_ip) test.sub_step_log('guest ping through(http://www.redhat.com) ' 'and there is no any error in dmesg.') guest_session.guest_ping_test(count=5, dst_ip='www.redhat.com') guest_session.guest_dmesg_check() test.main_step_log( '2. reboot guest and do system_reset during guest rebooting') guest_session.guest_cmd_output(cmd='reboot') guest_session.close() searched_str = 'Stopped Network' searched_done = False while time.time() < endtime: output = serial.serial_output(max_recv_data=500, search_str=searched_str) if re.findall(r'Found the searched keyword', output): test.test_print(output) searched_done = True remote_qmp.qmp_cmd_output('{ "execute": "system_reset" }') break else: test.test_print(output) if re.findall(r'login:'******'Failed to find the keyword: %s' % searched_str) if searched_done == False: test.test_error('Failed to find the keyword: %s under %s.' % (searched_str, timeout)) test.main_step_log('3.repeate step 2 at least 10 times.') for i in range(1, 11): test.sub_step_log('Repeate %s time.' % i) searched_str = 'SLOF' searched_done = False while time.time() < endtime: output = serial.serial_output(max_recv_data=500, search_str=searched_str) if re.findall(r'Found the searched keyword', output): test.test_print(output) searched_done = True remote_qmp.qmp_cmd_output('{ "execute": "system_reset" }') break else: test.test_print(output) if re.findall(r'login:'******'Failed to find the keyword: %s' % searched_str) if searched_done == False: test.test_error('Failed to find the keyword: %s under %s.' % (searched_str, timeout)) guset_ip = serial.serial_login() guest_session = GuestSession(case_id=id, params=params, ip=guset_ip) test.sub_step_log('guest ping through(http://www.redhat.com) ' 'and there is no any error in dmesg.') guest_session.guest_ping_test(count=5, dst_ip='www.redhat.com') guest_session.guest_dmesg_check() test.sub_step_log( 'reboot guest and do system_reset during guest rebooting') guest_session.guest_cmd_output(cmd='reboot') guest_session.close() searched_str = 'Stopped Network' searched_done = False while time.time() < endtime: output = serial.serial_output(max_recv_data=500, search_str=searched_str) if re.findall(r'Found the searched keyword', output): test.test_print(output) searched_done = True remote_qmp.qmp_cmd_output('{ "execute": "system_reset" }') break else: test.test_print(output) if re.findall(r'login:'******'Failed to find the keyword: %s' % searched_str) if searched_done == False: test.test_error('Failed to find the keyword: %s under %s.' % (searched_str, timeout))
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10061', params=params) id = test.get_id() guest_name = test.guest_name src_host_session = HostSession(id, params) downtime = '20000' speed = '1073741824' chk_time_1 = 20 chk_time_2 = 1200 test.main_step_log('1. Start VM in the src host, guest running stress') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('1.2 Running stress in src guest') chk_cmd = 'yum list installed | grep stress.`arch`' output = src_guest_session.guest_cmd_output(cmd=chk_cmd) if not output: install_cmd = 'yum install -y stress.`arch`' install_info = src_guest_session.guest_cmd_output(cmd=install_cmd) if re.findall('Complete', install_info): test.test_print('Guest install stress pkg successfully') else: test.test_error('Guest failed to install stress pkg') stress_cmd = 'stress --cpu 4 --vm 4 --vm-bytes 256M' thread = threading.Thread(target=src_guest_session.guest_cmd_output, args=(stress_cmd, 1200)) thread.name = 'stress' thread.daemon = True thread.start() time.sleep(10) output = src_guest_session.guest_cmd_output('pgrep -x stress') if not output: test.test_error('Stress is not running in guest') test.main_step_log('2. Start listening mode in the dst host.') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. Do live migration') cmd = '{"execute":"migrate", "arguments": {"uri": "tcp:%s:%s"}}' % ( dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd=cmd) test.sub_step_log('Check the status of migration') flag_active = False cmd = '{"execute":"query-migrate"}' end_time = time.time() + chk_time_1 while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output(cmd=cmd) if re.findall('"status": "active"', output): flag_active = True break elif re.findall(r'"status": "failed"', output): src_remote_qmp.test_error('migration failed') if (flag_active == False): test.test_error('Migration is not active within %d' % chk_time_1) test.main_step_log('4. During migration in progress, cancel migration') cmd = '{"execute":"migrate_cancel"}' src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=3) output = src_remote_qmp.qmp_cmd_output('{"execute":"query-migrate"}', recv_timeout=3) if re.findall(r'"status": "cancelled"', output): src_remote_qmp.test_print('Src cancel migration successfully') else: src_remote_qmp.test_error('Failed to cancel migration') test.main_step_log('5. Start listening mode againg in the dst host') test.sub_step_log('5.1 Check if the dst qemu quit automatically') dst_chk_cmd = 'ssh root@%s ps -axu | grep %s | grep -v grep' \ % (dst_host_ip, guest_name) output = src_host_session.host_cmd_output(cmd=dst_chk_cmd) if not output: src_host_session.test_print('DST QEMU quit automatically after ' 'src cancelling migration') else: src_host_session.test_error('DST QEMU does not quit automatically ' 'after src cancelling migration') test.sub_step_log('5.2 Start listening mode again in dst host') src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('6. Do live migration again') output = do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip) if (output == False): test.test_error('Migration timeout') test.main_step_log('7. After migration succeed, ' 'checking the status of guest on the dst host') test.sub_step_log('7.1 Guest keyboard and mouse work normally.') test.sub_step_log('7.2 Reboot guest') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd=cmd) if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() test.sub_step_log( '7.3 Ping external host/copy file between guest and host') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('7.4 DD a file inside guest') cmd_dd = 'dd if=/dev/zero of=file1 bs=1M count=100 oflag=direct' output = dst_guest_session.guest_cmd_output(cmd=cmd_dd, timeout=600) if not output or re.findall('error', output): test.test_error('Failed to dd a file in guest') test.sub_step_log('7.5 Shutdown guest successfully') dst_serial.serial_shutdown_vm()
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = src_host_ip qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) share_images_dir = params.get('share_images_dir') test = CreateTest(case_id='rhel7_10022', params=params) id = test.get_id() guest_name = test.guest_name test.main_step_log('1. Boot a guest.') src_host_session = HostSession(id, params) src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') test.sub_step_log('Check the status of src guest') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('Connecting to src serial') src_serial = RemoteSerialMonitor(case_id=id, params=params, ip=src_host_ip, port=serial_port) src_guest_ip = src_serial.serial_login() guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('Check dmesg info ') cmd = 'dmesg' output = guest_session.guest_cmd_output(cmd) if re.findall(r'Call Trace:', output): guest_session.test_error('Guest hit call trace') test.main_step_log('2. Save VM state into a compressed file in host') src_remote_qmp.qmp_cmd_output('{"execute":"stop"}') src_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') src_remote_qmp.qmp_cmd_output('{"execute":"migrate_set_speed", ' '"arguments": { "value": 104857600 }}') statefile = '/%s/STATEFILE.gz' % share_images_dir src_host_session.host_cmd(cmd=('rm -rf %s' % statefile)) src_remote_qmp.qmp_cmd_output('{"execute":"migrate",' '"arguments":{"uri": "exec:gzip -c > %s"}}' % statefile, recv_timeout=5) test.sub_step_log('Check the status of migration') info = query_migration(src_remote_qmp) if (info == True): test.test_print('Migration succeed') if (info == False): test.test_error('Migration timeout') src_remote_qmp.qmp_cmd_output('{"execute":"quit"}') src_host_session.check_guest_process(src_ip=src_host_ip) test.main_step_log('3. Load the file in dest host(src host).') params.vm_base_cmd_add('incoming', '"exec: gzip -c -d %s"' % statefile) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=dst_qemu_cmd, vm_alias='dst') test.sub_step_log('3.1 Login dst guest') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) while True: output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if re.findall(r'"paused"', output): break time.sleep(3) dst_remote_qmp.qmp_cmd_output('{"execute":"cont"}') dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=src_host_ip, port=serial_port) guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.main_step_log('4. Check if guest works well.') test.sub_step_log('4.1 Guest mouse and keyboard.') test.sub_step_log( '4.2. Ping external host / copy file between guest and host') guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('4.3 dd a file inside guest.') cmd_dd = 'dd if=/dev/zero of=/tmp/dd.io bs=512b count=2000 oflag=direct' guest_session.guest_cmd_output(cmd=cmd_dd, timeout=600) test.sub_step_log('check dmesg info') cmd = 'dmesg' output = guest_session.guest_cmd_output(cmd=cmd) if re.findall(r'Call Trace:', output) or not output: guest_session.test_error('Guest hit call trace') test.sub_step_log('4.4. Reboot and then shutdown guest.') dst_serial.serial_cmd(cmd='reboot') dst_serial.serial_login() dst_serial.serial_shutdown_vm()
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10068', params=params) id = test.get_id() guest_pwd = params.get('guest_passwd') test.main_step_log('1.Start VM in src host') params.vm_base_cmd_add('S', 'None') params.vm_base_cmd_add('monitor', 'tcp:0:5555,server,nowait') src_host_session = HostSession(id, params) src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') test.sub_step_log('Check the status of src guest') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.main_step_log('2. Start listening mode in dst host ') params.vm_base_cmd_del('S', 'None') params.vm_base_cmd_del('monitor', 'tcp:0:5555,server,nowait') incoming_val = 'tcp:0:%s' % (incoming_port) params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) test.main_step_log('3. Start live migration with ' 'running below script on src host') cmd='echo c | nc localhost 5555; sleep 0.6; ' \ 'echo migrate tcp:%s:%s | nc localhost 5555' % \ (dst_host_ip, incoming_port) src_host_session.host_cmd(cmd=cmd) test.main_step_log('4.Check guest on des, guest should work well') migration_flag = query_migration(src_remote_qmp) if (migration_flag == False): src_remote_qmp.test_error('migration timeout') output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if not re.findall(r'"status": "running"', output): dst_remote_qmp.test_error('migration status error') test.main_step_log('5.Reboot guest, guest should work well.') timeout = 600 endtime = time.time() + timeout bootup = False while time.time() < endtime: cmd = 'root' dst_serial.send_cmd(cmd) output = dst_serial.rec_data(recv_timeout=8) dst_serial.test_print(info=output, serial_debug=True) if re.findall(r'Password', output): dst_serial.send_cmd(guest_pwd) dst_serial.test_print(guest_pwd, serial_debug=True) output = dst_serial.rec_data(recv_timeout=8) dst_serial.test_print(info=output, serial_debug=True) if re.search(r"login:"******"login:"******"execute":"quit"}', recv_timeout=3) if output: src_remote_qmp.test_error('Failed to quit qemu on src host') dst_serial.serial_shutdown_vm()
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_85702', params=params) id = test.get_id() src_host_session = HostSession(id, params) script = 'migration_dirtypage_2.c' test.main_step_log('1.Boot a vm in src host with qemu cli:') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.main_step_log('2.Boot a vm in dst host') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3.In the guest, execute the below program ' 'to generate dirty pages') utils_migration.dirty_page_test(host_session=src_host_session, guest_session=src_guest_session, guest_ip=src_guest_ip, script=script) test.main_step_log('4. Set migration configuration in HMP and do migration') test.sub_step_log('set src host xbzrle and postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp, capabilities='xbzrle', state='true') utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp, capabilities='postcopy-ram', state='true') test.sub_step_log('set dst host xbzrle and postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp, capabilities='xbzrle', state='true') utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp, capabilities='postcopy-ram', state='true') test.sub_step_log('start to do migration') cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \ % (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd=cmd) test.main_step_log('5. Check migration status, after producing dirty pages' ' switch to post-copy.') utils_migration.switch_to_postcopy(remote_qmp=src_remote_qmp) chk_info = utils_migration.query_migration(remote_qmp=src_remote_qmp) if chk_info == False: test.test_error('Migration timeout') test.sub_step_log('Check guest status after migration finished') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) output = dst_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10)
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10067', params=params) id = test.get_id() src_host_session = HostSession(id, params) iozone_url = 'http://www.iozone.org/src/current/iozone3_471.tar' iozone_ver = 'iozone3_471' downtime = '10000' query_migration_time = 1200 test.main_step_log('1. Start VM with high load, with each method is ok') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('1.2 Running iozone in src guest') cmd = 'yum list installed | grep ^gcc.`arch`' output = src_guest_session.guest_cmd_output(cmd=cmd) if not output: output = src_guest_session.guest_cmd_output('yum install -y gcc') if not re.findall(r'Complete!', output): src_guest_session.test_error('gcc install Error') src_guest_session.guest_cmd_output('rm -rf /home/iozone*') src_guest_session.guest_cmd_output('cd /home;wget %s' % iozone_url) output = src_guest_session.guest_cmd_output('ls /home | grep %s.tar' % iozone_ver) if not output: test.test_error('Failed to get iozone file') time.sleep(10) src_guest_session.guest_cmd_output('cd /home; tar -xvf %s.tar' % iozone_ver) arch = src_guest_session.guest_cmd_output('arch') if re.findall(r'ppc64le', arch): cmd = 'cd /home/%s/src/current/;make linux-powerpc64' % iozone_ver src_guest_session.guest_cmd_output(cmd=cmd) elif re.findall(r'x86_64', arch): cmd = 'cd /home/%s/src/current/;make linux-AMD64' % iozone_ver src_guest_session.guest_cmd_output(cmd=cmd) elif re.findall(r'S390X', arch): cmd = 'cd /home/%s/src/current/;make linux-S390X' % iozone_ver src_guest_session.guest_cmd_output(cmd=cmd) time.sleep(5) iozone_cmd = 'cd /home/%s/src/current/;./iozone -a' % iozone_ver thread = threading.Thread(target=src_guest_session.guest_cmd_output, args=(iozone_cmd, 1200)) thread.name = 'iozone' thread.daemon = True thread.start() time.sleep(10) pid = src_guest_session.guest_cmd_output('pgrep -x iozone') if pid: src_guest_session.test_print('iozone is running in guest') else: src_guest_session.test_error('iozone is not running in guest') test.main_step_log('2. Start listening mode') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. Set a reasonable downtime value for migration') downtime_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"downtime-limit": %s}}' % downtime src_remote_qmp.qmp_cmd_output(cmd=downtime_cmd) paras_chk_cmd = '{"execute":"query-migrate-parameters"}' output = src_remote_qmp.qmp_cmd_output(cmd=paras_chk_cmd) if re.findall(r'"downtime-limit": %s' % downtime, output): test.test_print('Change downtime successfully') else: test.test_error('Failed to change downtime') test.main_step_log('4.Do live migration') check_info = do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip, chk_timeout_2=query_migration_time) if (check_info == False): test.test_error('Migration timeout after changing downtime') test.main_step_log('5. Check the status of guest on dst host') test.sub_step_log('5.1. Reboot guest') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd) if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() test.sub_step_log('5.2 Ping external host') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('5.3 DD a file inside guest') cmd_dd = 'dd if=/dev/zero of=file1 bs=1M count=100 oflag=direct' output = dst_guest_session.guest_cmd_output(cmd=cmd_dd, timeout=600) if not output or re.findall('error', output): test.test_error('Failed to dd a file in guest') test.sub_step_log('5.4 Shutdown guest successfully') dst_serial.serial_shutdown_vm() output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: src_remote_qmp.test_error('Failed to quit qemu on src end')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_49062', params=params) id = test.get_id() src_host_session = HostSession(id, params) val_M = '2000' val_s = '10000' test.main_step_log('1. Launch guest on source host') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('2. stress guest(migration could finish for scenario1/' 'could never finish for scenario 2)') utils_migration.stressapptest(guest_session=src_guest_session, val_M=val_M, val_s=val_s) test.main_step_log('3. Launch guest on destination host') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('4. On source qemu & dst qemu, set postcopy mode on') test.sub_step_log('set src host postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp, capabilities='postcopy-ram', state='true') test.sub_step_log('set dst host postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp, capabilities='postcopy-ram', state='true') test.main_step_log('5. migrate guest to destination') cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \ % (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd=cmd) test.sub_step_log('6. Change into postcopy mode') output = utils_migration.query_migration(remote_qmp=src_remote_qmp, chk_timeout=300) if (output == False): test.test_print('Migration can not finish without postcopy') cmd = '{"execute":"migrate-start-postcopy"}' src_remote_qmp.qmp_cmd_output(cmd=cmd) info = utils_migration.query_migration(remote_qmp=src_remote_qmp) if (info == False): test.test_error('Migration timeout with postcopy') else: test.test_print('Migration finished without postcopy') test.main_step_log( '7. Check guest status before and after migration finished') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) output = dst_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10) test.main_step_log('8. Check postcopy statistics') cmd = '{"execute":"query-migrate"}' output = src_remote_qmp.qmp_cmd_output(cmd=cmd) if re.findall(r'"postcopy-requests": 0', output): test.test_error('the value postcopy-requests is zero') else: test.test_print('the value postcopy-requests is not zero') test.main_step_log( '9.repeat step2~8 to migrate guest back to source host.') test.sub_step_log('9.1 quit src qemu') src_remote_qmp.qmp_cmd_output(cmd='{"execute":"quit"}') src_host_session.check_guest_process(src_ip=src_host_ip) test.sub_step_log('9.2 boot src guest again') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('9.3 stress guest') utils_migration.stressapptest(guest_session=dst_guest_session, val_M=val_M, val_s=val_s) test.sub_step_log('9.4 set src and dst postcopy-ram on') test.sub_step_log('set src host postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=src_remote_qmp, capabilities='postcopy-ram', state='true') test.sub_step_log('set dst host postcopy-ram on') utils_migration.set_migration_capabilities(remote_qmp=dst_remote_qmp, capabilities='postcopy-ram', state='true') test.sub_step_log('9.5 migrate guest to source') cmd = '{"execute":"migrate", "arguments": { "uri": "tcp:%s:%s" }}' \ % (src_host_ip, incoming_port) dst_remote_qmp.qmp_cmd_output(cmd=cmd) test.sub_step_log('9.6. Change into postcopy mode') output = utils_migration.query_migration(remote_qmp=dst_remote_qmp, chk_timeout=300) if (output == False): test.test_print('Migration can not finish without postcopy') cmd = '{"execute":"migrate-start-postcopy"}' dst_remote_qmp.qmp_cmd_output(cmd=cmd) info = utils_migration.query_migration(remote_qmp=dst_remote_qmp) if (info == False): test.test_error('Migration timeout with postcopy') else: test.test_print('Migration finished without postcopy') test.main_step_log( '9.7. Check guest status before and after migration finished') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) output = src_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') src_serial.serial_cmd(cmd='reboot') src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) src_guest_session.guest_ping_test(dst_ip='www.redhat.com', count=10) test.main_step_log('9.8. Check postcopy statistics') cmd = '{"execute":"query-migrate"}' output = dst_remote_qmp.qmp_cmd_output(cmd=cmd) if re.findall(r'"postcopy-requests": 0', output): test.test_error('the value postcopy-requests is zero') else: test.test_print('the value postcopy-requests is not zero')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') paused_timeout = 60 test = CreateTest(case_id='rhel7_10064', params=params) id = test.get_id() src_host_session = HostSession(id, params) src_qemu_cmd = params.create_qemu_cmd() test.main_step_log('1. Start VM in src host') src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('Check dmesg info ') cmd = 'dmesg' output = src_guest_session.guest_cmd_output(cmd) if re.findall(r'Call Trace:', output): src_guest_session.test_error('Guest hit call trace') test.main_step_log('2. Start listening mode in dst host ') incoming_val = 'tcp:0:%s' % (incoming_port) params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. Do I/O operations load(iozone) in the guest') test.sub_step_log('run iozone -a') utils_migration.iozone_test(guest_session=src_guest_session) test.main_step_log('4. Stop guest on src guest before migration') cmd = '{"execute":"stop"}' src_remote_qmp.qmp_cmd_output(cmd) flag_paused = False end_time = time.time() + paused_timeout while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output('{"execute":"query-status"}', recv_timeout=3) if re.findall(r'"status": "paused"', output): flag_paused = True break if (flag_paused == False): test.test_error('Guest could not become to paused within %d' % paused_timeout) test.main_step_log('5. Start migration from src to dst host') flag = utils_migration.do_migration(src_remote_qmp, incoming_port, dst_host_ip) if (flag == False): test.test_error('migration timeout') test.main_step_log('6.After migration finished ,check guests status.') flag_paused = False end_time = time.time() + paused_timeout while time.time() < end_time: output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if re.findall(r'"status": "paused"', output): flag_paused = True break if (flag_paused == False): test.test_error('Guest is not paused on dst side ' 'after migration finished') dst_remote_qmp.qmp_cmd_output('{"execute":"cont"}') output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if not re.findall(r'"status": "running"', output): dst_remote_qmp.test_error('migration status Error') test.main_step_log('7. Check if guest works well.') test.sub_step_log('7.1 Guest mouse and keyboard.') test.sub_step_log('7.2 Check dmesg info ') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd) if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace') test.sub_step_log('8. Reboot and then shutdown guest.') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) test.sub_step_log(' Can access guest from external host') guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('quit qemu on src end and shutdown vm on dst end') output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}', recv_timeout=3) if output: src_remote_qmp.test_error('Failed to quit qemu on src host') dst_serial.serial_shutdown_vm()
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') guest_arch = params.get('guest_arch') test = CreateTest(case_id='rhel7_10026', params=params) id = test.get_id() guest_pwd = params.get('guest_passwd') src_host_session = HostSession(id, params) login_timeout = 1200 test.main_step_log('1. Start vm on src host') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() test.main_step_log('2. Start listening mode on dst host') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) test.main_step_log('3. keep reboot vm with system_reset, let guest ' 'in bios stage, before kernel loading') src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') if 'ppc64' in guest_arch: keyword = 'SLOF' elif 'x86_64' in guest_arch: keyword = '[ 0.000000]' while 1: serial_output = src_serial.serial_output(max_recv_data=128, search_str=keyword) test.test_print(serial_output) if re.findall(r'Found the searched keyword', serial_output): break if re.findall(r'login', serial_output): test.test_error('Failed to catch migration point') test.main_step_log('4. implement migrate during vm reboot') chk_info = do_migration(src_remote_qmp, incoming_port, dst_host_ip) if (chk_info == True): test.test_print('Migration succeed') elif (chk_info == False): test.test_error('Migration timeout') test.main_step_log('5. After migration, check if guest works well') timeout = 600 endtime = time.time() + timeout bootup = False while time.time() < endtime: cmd = 'root' dst_serial.send_cmd(cmd) output = dst_serial.rec_data(recv_timeout=8) dst_serial.test_print(info=output, serial_debug=True) if re.findall(r'Password', output): dst_serial.send_cmd(guest_pwd) dst_serial.test_print(guest_pwd, serial_debug=True) output = dst_serial.rec_data(recv_timeout=8) dst_serial.test_print(info=output, serial_debug=True) if re.search(r"login:"******"login:"******"execute":"quit"}') if output: src_remote_qmp.test_error('Failed to quit qemu on src end')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) share_images_dir = params.get('share_images_dir') sys_image_name = params.get('sys_image_name') matrix = params.get('matrix') disk1_name = params.get('disk1_name').split('.')[0] disk1_format = params.get('disk1_name').split('.')[1] disk2_name = params.get('disk2_name').split('.')[0] disk2_format = params.get('disk2_name').split('.')[1] disk3_name = params.get('disk3_name').split('.')[0] disk3_format = params.get('disk3_name').split('.')[1] disk4_name = params.get('disk4_name').split('.')[0] disk4_format = params.get('disk4_name').split('.')[1] disk5_name = params.get('disk5_name').split('.')[0] disk5_format = params.get('disk5_name').split('.')[1] iso = params.get('cdrom1_name') test = CreateTest(case_id='rhel_133480', params=params) id = test.get_id() src_host_session = HostSession(id, params) test.test_print('=======Create test environment=======') test.sub_step_log('~~~~1. Create 5 data disks~~~~') utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk1_name, disk_format=disk1_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk2_name, disk_format=disk2_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk3_name, disk_format=disk3_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk4_name, disk_format=disk4_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk5_name, disk_format=disk5_format, disk_size=2048) test.sub_step_log('~~~~2. Create 1 iso~~~~') utils_stable_abi_ppc.create_iso(host_session=src_host_session, disk_dir=share_images_dir, iso=iso) test.sub_step_log('~~~~3. Configure host hugepage~~~~') utils_stable_abi_ppc.configure_host_hugepage( host_session=src_host_session, matrix=matrix, dst_ip=dst_host_ip, mount_point='/mnt/kvm_hugepage') test.main_step_log('1. Guest must be installed on Source Host host and ' 'copy it to Destination Host host. guest must have ' 'following devices') test.main_step_log('2.install guest on Source Host (old host)') test.main_step_log( '3.Copy image from Source Host host to Destination Host host') dst_del_img = 'ssh root@%s rm -rf /tmp/%s' % (dst_host_ip, sys_image_name) src_host_session.host_cmd(cmd=dst_del_img) cmd = 'scp %s/%s root@%s:/tmp/%s' % (share_images_dir, sys_image_name, dst_host_ip, sys_image_name) src_host_session.host_cmd(cmd=cmd) md5_cmd_src = "md5sum %s/%s | awk '{print $1}'" % (share_images_dir, sys_image_name) md5_src_images = src_host_session.host_cmd_output(cmd=md5_cmd_src) md5_cmd_dst = "ssh root@%s md5sum /tmp/%s | awk '{print $1}'" % ( dst_host_ip, sys_image_name) md5_dst_images = src_host_session.host_cmd_output(cmd=md5_cmd_dst) if not (md5_src_images == md5_dst_images): test.test_error('Failed to scp system image to dst host') test.main_step_log('4.Boot guest on Destination Host host and check ' 'devices function one by one with machine ' 'type \"-M pseries-rhel7.6.0 \"') params.vm_base_cmd_update( 'chardev', 'socket,id=serial_id_serial0,host=%s,port=%s,server,nowait' % (src_host_ip, serial_port), 'socket,id=serial_id_serial0,host=%s,port=%s,server,nowait' % (dst_host_ip, serial_port)) if (matrix == 'P8_P9'): cmd = 'ssh root@%s lscpu' % dst_host_ip output = src_host_session.host_cmd_output(cmd=cmd) if re.findall(r'POWER9', output): params.vm_base_cmd_update( 'machine', 'pseries', 'pseries-rhel7.6.0,max-cpu-compat=power8') else: params.vm_base_cmd_update('machine', 'pseries', 'pseries-rhel7.6.0') else: params.vm_base_cmd_update('machine', 'pseries', 'pseries-rhel7.6.0') dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, ip=dst_host_ip, port=qmp_port) dst_serial = RemoteSerialMonitor(id, params, ip=dst_host_ip, port=serial_port) dst_guest_ip = dst_serial.serial_login() dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) test.sub_step_log('a.Check networking') dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('b.Check block by the following methods') utils_migration.filebench_test(dst_guest_session) test.sub_step_log('c.Check VNC console and check keyboard by input keys') dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') dst_serial.serial_login()
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10044', params=params) id = test.get_id() guest_passwd = params.get('guest_passwd') src_host_session = HostSession(id, params) downtime = 10000 gap_downtime = 5000 script = 'migration_dirtypage_2.c' test.main_step_log('1. guest with heavy memory load with either of ' 'the following methods') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.sub_step_log('1.2 Run some program to generate dirty page') test.test_print('scp %s to guest' % script) src_guest_session.guest_cmd_output('cd /home;rm -f %s' % script) src_host_session.host_cmd_scp_put(local_path='%s/c_scripts/%s' % (BASE_DIR, script), remote_path='/home/%s' % script, passwd=guest_passwd, remote_ip=src_guest_ip, timeout=300) chk_cmd = 'ls /home | grep -w "%s"' % script output = src_guest_session.guest_cmd_output(cmd=chk_cmd) if not output: test.test_error('Failed to get %s' % script) arch = src_guest_session.guest_cmd_output('arch') gcc_cmd = 'yum list installed | grep -w "gcc.%s"' % arch output = src_guest_session.guest_cmd_output(cmd=gcc_cmd) if not re.findall(r'gcc.%s' % arch, output): install_cmd = 'yum install -y ^gcc.`arch`' install_info = src_guest_session.guest_cmd_output(install_cmd) if re.findall('Complete', install_info): test.test_print('Guest install gcc pkg successfully') else: test.test_error('Guest failed to install gcc pkg') compile_cmd = 'cd /home;gcc %s -o dirty2' % script src_guest_session.guest_cmd_output(cmd=compile_cmd) output = src_guest_session.guest_cmd_output('ls /home | grep -w "dirty2"') if not output: test.test_error('Failed to compile %s' % script) dirty_cmd = 'cd /home;./dirty2' thread = threading.Thread(target=src_guest_session.guest_cmd_output, args=(dirty_cmd, 4800)) thread.name = 'dirty2' thread.daemon = True thread.start() time.sleep(10) output = src_guest_session.guest_cmd_output('pgrep -x dirty2') if not output: test.test_error('Dirty2 is not running in guest') test.main_step_log('2. Start listening mode on dst host') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. Set a reasonable migrate downtime') downtime_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"downtime-limit": %d}}' % downtime src_remote_qmp.qmp_cmd_output(cmd=downtime_cmd) paras_chk_cmd = '{"execute":"query-migrate-parameters"}' output = src_remote_qmp.qmp_cmd_output(cmd=paras_chk_cmd) if re.findall(r'"downtime-limit": %d' % downtime, output): test.test_print('Set migration downtime successfully') else: test.test_error('Failed to change downtime') test.main_step_log('4. Do live migration.') check_info = do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip) if (check_info == False): test.test_error('Migration timeout') test.main_step_log('5. when the "Migration status" is "completed", ' 'check the "downtime" value') output = eval(src_remote_qmp.qmp_cmd_output('{"execute":"query-migrate"}')) real_downtime = int(output.get('return').get('downtime')) src_remote_qmp.test_print('The real downtime is: %d' % real_downtime) gap_cal = real_downtime - downtime if (gap_cal > gap_downtime): test.test_error('The real downtime value is much more than the value ' 'that you set by %s milliseconds' % gap_downtime) else: test.test_print('The real downtime value is not much more than ' 'the value that you set') test.main_step_log('6 Check the status of guest') test.sub_step_log('6.1. Reboot guest') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') dst_guest_ip = dst_serial.serial_login() test.sub_step_log('6.2 Ping external host') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('6.3 Shutdown guest successfully') dst_serial.serial_shutdown_vm() output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: src_remote_qmp.test_error('Failed to quit qemu on src end')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') share_images_dir = params.get('share_images_dir') matrix = params.get('matrix') disk1_name = params.get('disk1_name').split('.')[0] disk1_format = params.get('disk1_name').split('.')[1] disk2_name = params.get('disk2_name').split('.')[0] disk2_format = params.get('disk2_name').split('.')[1] disk3_name = params.get('disk3_name').split('.')[0] disk3_format = params.get('disk3_name').split('.')[1] disk4_name = params.get('disk4_name').split('.')[0] disk4_format = params.get('disk4_name').split('.')[1] disk5_name = params.get('disk5_name').split('.')[0] disk5_format = params.get('disk5_name').split('.')[1] iso = params.get('cdrom1_name') test = CreateTest(case_id='rhel7_120633', params=params) id = test.get_id() src_host_session = HostSession(id, params) test.test_print('=======Create test environment=======') test.sub_step_log('~~~~1. Create 5 data disks~~~~') utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk1_name, disk_format=disk1_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk2_name, disk_format=disk2_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk3_name, disk_format=disk3_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk4_name, disk_format=disk4_format, disk_size=2048) utils_migration.create_disk(host_session=src_host_session, disk_dir=share_images_dir, disk_name=disk5_name, disk_format=disk5_format, disk_size=2048) test.sub_step_log('~~~~2. Create 1 iso~~~~') utils_stable_abi_ppc.create_iso(host_session=src_host_session, disk_dir=share_images_dir, iso=iso) test.sub_step_log('~~~~3. Configure host hugepage~~~~') utils_stable_abi_ppc.configure_host_hugepage( host_session=src_host_session, matrix=matrix, dst_ip=dst_host_ip, mount_point='/mnt/kvm_hugepage') test.sub_step_log('~~~~4. Check matrix~~~~') flag = utils_stable_abi_ppc.check_matrix(host_session=src_host_session, dst_ip=dst_host_ip, matrix=matrix) test.main_step_log('1. start guest on Source Host host must have ' 'following devices') if (flag == 'p9_to_p8'): params.vm_base_cmd_update('machine', 'pseries', 'pseries-rhel7.3.0,max-cpu-compat=power8') else: params.vm_base_cmd_update('machine', 'pseries', 'pseries-rhel7.3.0') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, ip=src_host_ip, port=serial_port) src_serial.serial_login() src_remote_qmp = RemoteQMPMonitor(id, params, ip=src_host_ip, port=qmp_port) test.sub_step_log('2 Start guest on Destination Host host with same ' 'qemu cli as step1 but appending') if (flag == 'p8_to_p9'): params.vm_base_cmd_update('machine', 'pseries-rhel7.3.0', 'pseries-rhel7.3.0,max-cpu-compat=power8') elif (flag == 'p9_to_p8'): params.vm_base_cmd_update('machine', 'pseries-rhel7.3.0,max-cpu-compat=power8', 'pseries-rhel7.3.0') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) params.vm_base_cmd_update( 'chardev', 'socket,id=serial_id_serial0,host=%s,port=%s,server,nowait' % (src_host_ip, serial_port), 'socket,id=serial_id_serial0,host=%s,port=%s,server,nowait' % (dst_host_ip, serial_port)) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, ip=dst_host_ip, port=qmp_port) test.main_step_log('3. Migrate guest from Source Host host to Destination' ' Host host') check_info = utils_migration.do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip) if (check_info == False): test.test_error('Migration timeout') test.main_step_log('4.Check devices function one by one') dst_serial = RemoteSerialMonitor(id, params, ip=dst_host_ip, port=serial_port) output = dst_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') dst_guest_ip = dst_serial.serial_login() dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) test.sub_step_log('a.Check networking') dst_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('b.Check block by the following methods') utils_migration.filebench_test(dst_guest_session) test.sub_step_log('c.Check VNC console and check keyboard by input keys') time.sleep(3) test.main_step_log('5.Migrate the guest back to Source Host host and ' 'please refer to step 3') src_remote_qmp.qmp_cmd_output('{"execute":"quit"}', recv_timeout=3) time.sleep(3) src_host_session.check_guest_process(src_ip=src_host_ip) if (flag == 'p8_to_p9'): params.vm_base_cmd_update('machine', 'pseries-rhel7.3.0,max-cpu-compat=power8', 'pseries-rhel7.3.0') elif (flag == 'p9_to_p8'): params.vm_base_cmd_update('machine', 'pseries-rhel7.3.0', 'pseries-rhel7.3.0,max-cpu-compat=power8') params.vm_base_cmd_update( 'chardev', 'socket,id=serial_id_serial0,host=%s,port=%s,server,nowait' % (dst_host_ip, serial_port), 'socket,id=serial_id_serial0,host=%s,port=%s,server,nowait' % (src_host_ip, serial_port)) src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, ip=src_host_ip, port=qmp_port) check_info = utils_migration.do_migration(remote_qmp=dst_remote_qmp, migrate_port=incoming_port, dst_ip=src_host_ip) if (check_info == False): test.test_error('Migration timeout') test.main_step_log('6.Repeat step 4') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) output = src_serial.serial_cmd_output('dmesg') if re.findall(r'Call Trace:', output): test.test_error('Guest hit call trace after migration') src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') src_guest_ip = src_serial.serial_login() src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.sub_step_log('a.Check networking') src_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('b.Check block by the following methods') utils_migration.filebench_test(src_guest_session) test.sub_step_log('c.Check VNC console and check keyboard by input keys')
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10078', params=params) id = test.get_id() guest_name = test.guest_name src_host_session = HostSession(id, params) balloon_val = '1073741824' chk_timeout = 180 test.main_step_log('1. Boot guest on src host with memory balloon device.') params.vm_base_cmd_add( 'device', 'virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') test.sub_step_log('1.1 Connecting to src serial') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_guest_ip = src_serial.serial_login() test.main_step_log('2 Check if memory balloon device works.') test.sub_step_log('2.1 Check if balloon device exists') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) output = src_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}') original_val = eval(output).get('return').get('actual') if re.findall(r'No balloon', output): src_remote_qmp.test_error('No balloon device has been activated.') test.sub_step_log('2.2 Change the value of balloon to %s bytes' % balloon_val) change_balloon_val(new_value=balloon_val, remote_qmp=src_remote_qmp) test.sub_step_log('2.3 Restore balloon to original value') change_balloon_val(new_value=original_val, remote_qmp=src_remote_qmp) test.main_step_log('3. Hot unplug this memory balloon from guest.') cmd = '{"execute":"device_del","arguments":{"id":"balloon0"}}' src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5) test.sub_step_log('Check if the balloon is hot unplug successfully') cmd = '{"execute":"query-balloon"}' output = src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5) if re.findall(r'No balloon', output): test.test_print("Balloon device is hot unplug successfully") test.main_step_log('4. Boot guest with \'-incoming\' and ' 'without memory balloon device on des host.') params.vm_base_cmd_del( 'device', 'virtio-balloon-pci,id=balloon0,' 'bus=pci.0,addr=0x9') incoming_val = 'tcp:0:%s' % incoming_port params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}', recv_timeout=5) if re.findall(r'No balloon', output): test.test_print("Destination guest don't have balloon device") test.main_step_log('5. Start live migration, should finish successfully') flag = do_migration(remote_qmp=src_remote_qmp, migrate_port=incoming_port, dst_ip=dst_host_ip) if (flag == False): test.test_error('Migration timeout') test.main_step_log('6. Check guest on des, guest should work well.') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) test.sub_step_log('Reboot dst guest and get ip of destination guest') dst_serial.serial_cmd(cmd='reboot') dst_guest_ip = dst_serial.serial_login() test.test_print('The ip of destination guest is %s' % dst_guest_ip) test.main_step_log('7. Hot plug a memory balloon device to ' 'destination guest.') cmd = '{"execute":"device_add","arguments":{"driver":"virtio-balloon-pci",' \ '"bus":"pci.0","addr":"0x9","id":"balloon0"}}' dst_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5) output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}', recv_timeout=5) if re.findall(r'No balloon', output): dst_remote_qmp.test_error('Failed to hotplug balloon device') test.main_step_log('8. Repeat step2') change_balloon_val(new_value=balloon_val, remote_qmp=dst_remote_qmp) change_balloon_val(new_value=original_val, remote_qmp=dst_remote_qmp) test.main_step_log('9. Quit qemu on src host. Then boot guest with ' '\'-incoming\' on src host') output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: test.test_error('Failed to quit qemu on src host') src_host_session.check_guest_process(src_ip=src_host_ip) params.vm_base_cmd_add( 'device', 'virtio-balloon-pci,id=balloon0,' 'bus=pci.0,addr=0x9') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) output = src_remote_qmp.qmp_cmd_output('{"execute":"query-balloon"}') if re.findall(r'No balloon', output): src_remote_qmp.test_error('src host do not has balloon device') test.main_step_log('10. Do migration from dst to src') flag = do_migration(remote_qmp=dst_remote_qmp, migrate_port=incoming_port, dst_ip=src_host_ip) if (flag == False): test.test_error('Migration timeout') test.main_step_log('11&12. Check guest on src, reboot, ' 'ping external host,and shutdown.') test.sub_step_log('11.1 Reboot src guest') src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') src_guest_ip = src_serial.serial_login() test.sub_step_log('11.2 Ping external host and shutdown guest') src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) src_guest_session.guest_ping_test('www.redhat.com', 10) test.sub_step_log('11.3 quit qemu on dst end and shutdown vm on src end') src_serial.serial_shutdown_vm() output = dst_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: dst_remote_qmp.test_error('Failed to quit qemu on dst host')