def _enable_iscsiid(self): HostSession.host_cmd_output(self, 'systemctl enable iscsid iscsi') HostSession.host_cmd_output(self, 'systemctl start iscsid iscsi') output = HostSession.host_cmd_output( self, 'systemctl status iscsid iscsi -l') if not re.findall(r'Active: active', output): ShellSession.test_error(self, 'Failed to start iscsid server.')
def discovery_iscsi_target(self, target_ip): cmd = 'iscsiadm --mode discovery --type sendtargets --portal %s' \ % target_ip output = HostSession.host_cmd_output(self, cmd) if int(HostSession.host_cmd_output(self, 'echo $?')): HostSession.test_error(self, 'Failed to discovery iscsi target') target_list = re.findall('iqn.\d{4}-\d{2}.com..*:.*', output) if not target_list: HostSession.test_print(self, 'No found any iscsi target.') HostSession.test_print(self, 'iSCSi target: %s' % target_list) return target_list
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='rhel_114178_virtio_scsi_local', params=params) id = test.get_id() host_session = HostSession(id, params) test.main_step_log('1. Create qcow2 image with backing file ' 'while specifying backing store format') host_session.create_image('qemu-img create -f raw /tmp/backing.raw 64M') host_session.create_image( 'qemu-img create -f qcow2 -F raw -b /tmp/backing.raw /tmp/test.qcow2') test.main_step_log( '2. Try to start qemu while specifying the chain manually via -blockdev' ) params.vm_base_cmd_add( 'blockdev', 'driver=file,filename=/tmp/backing.raw,node-name=backing') params.vm_base_cmd_add( 'blockdev', 'driver=qcow2,file.driver=file,file.filename=/tmp/test.qcow2,node-name=root,backing=backing' ) qemu_cmd = params.create_qemu_cmd() host_session.boot_guest(qemu_cmd) test.sub_step_log('Connecting to serial') serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) vm_ip = serial.serial_login() guest_session = GuestSession(vm_ip, id, params) guest_session.guest_cmd_output('lsblk') guest_session.guest_cmd_output('lsscsi') serial.serial_shutdown_vm()
def run_case(params): src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') incoming_port = str(params.get('incoming_port')) serial_port = int(params.get('serial_port')) qmp_port = int(params.get('qmp_port')) test = CreateTest(case_id='rhel7_10057', params=params) id = test.get_id() downtime = '30000' script = 'migration_dirtypage_1.c' query_timeout = 2400 active_timeout = 300 running_timeout = 300 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(ip=dst_host_ip, cmd=dst_qemu_cmd, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. src guest have ' 'programme running to generate dirty page') test.sub_step_log('run dirty page script') 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. Migrate to the destination') cmd = '{"execute":"migrate", "arguments": {"uri": "tcp:%s:%s"}}' % \ (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd) test.main_step_log('5.set downtime for migration') flag_active = False cmd = '{"execute":"query-migrate"}' end_time = time.time() + active_timeout while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output(cmd) if re.findall(r'"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): src_remote_qmp.test_error('Migration could not be active within %d' % active_timeout) 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('Set migration downtime successfully') else: test.test_error('Failed to change downtime') test.sub_step_log('Check the status of migration') flag = False cmd = '{"execute":"query-migrate"}' end_time = time.time() + query_timeout while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output(cmd=cmd) if re.findall(r'"remaining": 0', output): flag = True break elif re.findall(r'"status": "failed"', output): src_remote_qmp.test_error('migration failed') if (flag == False): test.test_error('Migration timeout in %d' % query_timeout) test.main_step_log('6.Check status of guest in dst host') cmd = '{"execute":"query-status"}' flag_running = False end_time = time.time() + running_timeout while time.time() < end_time: output = dst_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=3) if re.findall(r'"status": "running"', output): flag_running = True break if (flag_running == False): test.test_error('Dst guest is not running after migration finished %d ' 'seconds' % running_timeout) 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') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=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() external_host_ip = dst_host_ip dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) cmd_ping = 'ping %s -c 10' % external_host_ip output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') 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') 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')) 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') 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): serial_port = int(params.get('serial_port')) qmp_port = int(params.get('qmp_port')) nfs_server_list = params.get('nfs_server') src_host_ip = params.get('src_host_ip') dst_host_ip = params.get('dst_host_ip') guest_arch = params.get('guest_arch') test = CreateTest(case_id='rhel7_10071', params=params) id = test.get_id() host_session = HostSession(id, params) test.main_step_log('1. start VM in src host, install a guest') nfs_server_ip_list = [] for server in nfs_server_list: nfs_server_ip_list.append(server.split(':')[0]) test.test_print('NFS server ip:%s' % nfs_server_ip_list) rtt_info = {} rtt_val = [] test.sub_step_log('1.1 Chose a nfs server.') for ip in nfs_server_ip_list: ping_cmd = 'ping %s -c 5' % ip output = host_session.host_cmd_output(ping_cmd) rtt_line = output.splitlines()[-1] if float(rtt_line.split('/')[-3]) < float(params.get('rtt_tolerance')): rtt_info[ip] = rtt_line.split('/')[-3] rtt_val.append(float(rtt_line.split('/')[-3])) if not rtt_val: test.test_error('No available nfs server.') test.test_print('rtt info : %s' % rtt_info) min_rtt_val = min(rtt_val) mount_info = '' for ip, rtt in rtt_info.items(): if float(rtt) == min_rtt_val: for nfs_server in nfs_server_list: if ip in nfs_server: mount_info = nfs_server test.test_print('Mount point info : %s' % mount_info) tmp_install_dir = os.path.join(params.get('share_images_dir'), 'install') if not os.path.exists(tmp_install_dir): os.makedirs(tmp_install_dir) image_size = params.get('image_size') test.sub_step_log('1.2 Create a system image to install os.') params.vm_base_cmd_update( 'device', 'scsi-hd,id=image1,drive=drive_image1,' 'bus=virtio_scsi_pci0.0,channel=0,scsi-id=0,' 'lun=0,bootindex=0', 'scsi-hd,id=image1,drive=drive_image1,' 'bus=virtio_scsi_pci0.0,channel=0,' 'scsi-id=0,lun=0') params.vm_base_cmd_del( 'drive', 'id=drive_image1,if=none,snapshot=off,' 'aio=threads,cache=none,format=qcow2,' 'file=%s/%s' % (params.get('share_images_dir'), params.get('sys_image_name'))) if params.get('image_format') == 'qcow2': image = os.path.join(tmp_install_dir, (params.get('image_name') + '.qcow2')) host_session.host_cmd_output('rm -rf %s' % image) host_session.host_cmd_output('qemu-img create -f qcow2 %s %s' % (image, image_size)) params.vm_base_cmd_add( 'drive', 'id=drive_image1,if=none,snapshot=off,' 'aio=threads,cache=none,format=qcow2,' 'file=%s' % image) elif params.get('image_format') == 'raw': image = tmp_install_dir + params.get('image_name') + '.raw' host_session.host_cmd_output('qemu-img create -f raw %s %s' % (image, image_size)) params.vm_base_cmd_add( 'drive', 'id=drive_image1,if=none,snapshot=off,' 'aio=threads,cache=none,format=raw,' 'file=%s' % image) mnt_dir = os.path.join(tmp_install_dir, 'mnt') if not os.path.exists(mnt_dir): os.makedirs(mnt_dir) test.sub_step_log('1.3 Mount iso from nfs server.') host_session.host_cmd_output('mount -t nfs %s %s' % (mount_info, mnt_dir)) test.sub_step_log('1.4 Find the corresponding iso') iso_pattern = params.get('iso_name') + '*' + 'Server' + '*' \ + params.get('guest_arch') + '*' + 'dvd1.iso' iso_name = host_session.host_cmd_output('find %s -name %s' % (mnt_dir, iso_pattern)) if not iso_name: test.test_error('No found the corresponding %s iso.' % params.get('iso_name')) test.test_print('Found the corresponding iso: %s' % iso_name) isos_dir = os.path.join(tmp_install_dir, 'isos') if not os.path.exists(isos_dir): os.makedirs(isos_dir) test.sub_step_log('1.5 cp the corresponding iso to %s' % isos_dir) host_session.host_cmd_output('cp -f %s %s' % (iso_name, isos_dir)) iso_name = host_session.host_cmd_output('find %s -name %s' % (isos_dir, iso_pattern)) host_session.host_cmd_output('umount %s' % mnt_dir) params.vm_base_cmd_add( 'drive', 'id=drive_cd1,if=none,snapshot=off,aio=threads,' 'cache=none,media=cdrom,file=%s' % iso_name) params.vm_base_cmd_add('device', 'scsi-cd,id=cd1,drive=drive_cd1,bootindex=2') test.sub_step_log('1.6 Find the corresponding ks') ks_pattern = params.get('iso_name').split('.')[0] + '*' ks = host_session.host_cmd_output('find %s -name %s' % (MIGRATION_FILE, ks_pattern)) ks_iso = os.path.join(tmp_install_dir, 'ks.iso') test.sub_step_log('1.7 Make a %s form %s.' % (ks_iso, ks)) host_session.host_cmd_output('mkisofs -o %s %s' % (ks_iso, ks)) params.vm_base_cmd_add( 'drive', 'id=drive_unattended,if=none,snapshot=off,' 'aio=threads,cache=none,media=cdrom,' 'file=%s' % ks_iso) params.vm_base_cmd_add( 'device', 'scsi-cd,' 'id=unattended,drive=drive_unattended,bootindex=3') test.sub_step_log('1.8 cp vmlinuz and initrd.img form %s.' % iso_name) host_session.host_cmd_output('mount %s %s' % (iso_name, mnt_dir)) if (guest_arch == 'x86_64'): host_session.host_cmd_output('cp -f /%s/images/pxeboot/vmlinuz %s' % (mnt_dir, isos_dir)) host_session.host_cmd_output('cp -f /%s/images/pxeboot/initrd.img %s' % (mnt_dir, isos_dir)) elif (guest_arch == 'ppc64le'): host_session.host_cmd_output('cp -f /%s/ppc/ppc64/vmlinuz %s' % (mnt_dir, isos_dir)) host_session.host_cmd_output('cp -f /%s/ppc/ppc64/initrd.img %s' % (mnt_dir, isos_dir)) host_session.host_cmd_output('umount %s' % mnt_dir) test.sub_step_log('1.9 Check the name of mounted ks.iso.') host_session.host_cmd_output('mount %s %s' % (ks_iso, mnt_dir)) ks_name = host_session.host_cmd_output('ls %s' % mnt_dir) host_session.host_cmd_output('umount %s' % mnt_dir) params.vm_base_cmd_add('kernel', '"%s/vmlinuz"' % isos_dir) console_option = '' if params.get('guest_arch') == 'x86_64': console_option = 'ttyS0,115200' elif params.get('guest_arch') == 'ppc64le': console_option = 'hvc0,38400' params.vm_base_cmd_add( 'append', '"ksdevice=link inst.repo=cdrom:/dev/sr0 ' 'inst.ks=cdrom:/dev/sr1:/%s nicdelay=60 ' 'biosdevname=0 net.ifnames=0 ' 'console=tty0 console=%s"' % (ks_name, console_option)) params.vm_base_cmd_add('initrd', '"%s/initrd.img"' % isos_dir) test.sub_step_log( '1.10 Boot this guest and ready to install os automaticlly.') params.vm_base_cmd_add('S', 'None') src_qemu_cmd = params.create_qemu_cmd() host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src') src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) test.main_step_log('2.start listenning mode in dst host ' 'with "-incoming tcp:0:5800"') params.vm_base_cmd_del('S', 'None') params.vm_base_cmd_update( 'append', '"ksdevice=link inst.repo=cdrom:/dev/sr0 ' 'inst.ks=cdrom:/dev/sr1:/%s nicdelay=60 ' 'biosdevname=0 net.ifnames=0 ' 'console=tty0 console=%s"' % (ks_name, console_option), '\\""ksdevice=link inst.repo=cdrom:/dev/sr0 ' 'inst.ks=cdrom:/dev/sr1:/%s nicdelay=60 ' 'biosdevname=0 net.ifnames=0 ' 'console=tty0 console=%s"\\"' % (ks_name, console_option)) params.vm_base_cmd_add('incoming', 'tcp:0:%s' % params.get('incoming_port')) dst_qemu_cmd = params.create_qemu_cmd() 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. install guest and during guest copying files ' '(for windows) or installing packages (rhel guest).') src_serial = RemoteSerialMonitor(case_id=id, params=params, ip=src_host_ip, port=serial_port) src_remote_qmp.qmp_cmd_output('{ "execute": "cont" }') install_timeout = time.time() + int(params.get('install_timeout')) install_done = False started_install = False search_str = 'Installing libgcc' while time.time() < install_timeout: output = src_serial.serial_output(max_recv_data=128, search_str=search_str) test.test_print(output) if re.findall(r'Found the searched keyword', output): started_install = True break if started_install == False: test.test_error('No started to install under %s sec.' % params.get('install_timeout')) if started_install == True: test.main_step_log('4. migrate guest to destination host ' 'during copying files.') ret = do_migration(remote_qmp=src_remote_qmp, migrate_port=params.get('incoming_port'), dst_ip=dst_host_ip) if ret == True: dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) allput = '' while time.time() < install_timeout: output = dst_serial.serial_output() test.test_print(output) allput = allput + output if re.findall(r'Power down.', allput): install_done = True host_session.host_cmd_output('rm -rf %s/initrd.img' % isos_dir) host_session.host_cmd_output('rm -rf %s/vmlinuz' % isos_dir) host_session.host_cmd_output('rm -rf %s' % ks_iso) break if install_done == False: host_session.host_cmd_output('rm -rf %s/initrd.img' % isos_dir) host_session.host_cmd_output('rm -rf %s/vmlinuz' % isos_dir) host_session.host_cmd_output('rm -rf %s' % ks_iso) test.test_error('Install failed under %s sec' % params.get('install_timeout')) else: test.test_print('Install successfully.') params.vm_base_cmd_del( 'drive', 'id=drive_cd1,if=none,snapshot=off,aio=threads,' 'cache=none,media=cdrom,file=%s' % iso_name) params.vm_base_cmd_del('device', 'scsi-cd,id=cd1,drive=drive_cd1,bootindex=2') params.vm_base_cmd_del( 'drive', 'id=drive_unattended,if=none,snapshot=off,' 'aio=threads,cache=none,media=cdrom,' 'file=%s' % ks_iso) params.vm_base_cmd_del( 'device', 'scsi-cd,' 'id=unattended,drive=drive_unattended,bootindex=3') params.vm_base_cmd_del('kernel', '"%s/vmlinuz"' % isos_dir) params.vm_base_cmd_del( 'append', '\\""ksdevice=link inst.repo=cdrom:/dev/sr0 ' 'inst.ks=cdrom:/dev/sr1:/%s nicdelay=60 ' 'biosdevname=0 net.ifnames=0 ' 'console=tty0 console=%s"\\"' % (ks_name, console_option)) params.vm_base_cmd_del('initrd', '"%s/initrd.img"' % isos_dir) params.vm_base_cmd_del('incoming', 'tcp:0:%s' % params.get('incoming_port')) dst_qemu_cmd = params.create_qemu_cmd() test.sub_step_log('Boot guest again.') host_session.boot_remote_guest(cmd=dst_qemu_cmd, ip=dst_host_ip, vm_alias='dst') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, 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('4.1 guest keyboard and mouse work normally.') test.sub_step_log( '4.2 ping available, copy file succeed, network is fine.') external_host_ip = 'www.redhat.com' cmd_ping = 'ping %s -c 10' % external_host_ip output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') test.sub_step_log('4.3 Guest can reboot and shutdown successfully.') cmd_dd = 'dd if=/dev/zero of=file1 bs=1M count=1000 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.4 Guest can reboot and shutdown successfully.') dst_serial.serial_cmd(cmd='reboot') dst_serial.serial_login() 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_10035', params=params) id = test.get_id() src_host_session = HostSession(id, params) downtime = 10000 speed = 52428800 speed_m = speed / 1024 / 1024 stress_time = 120 gap_speed = 5 gap_downtime = 5000 test.main_step_log('1.Boot up a 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) 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.main_step_log('2. Running some application inside 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 --timeout %d' \ % stress_time 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('3. Boot up the 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) dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) test.main_step_log('4.Set the migration speed and downtime') downtime_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"downtime-limit": %d}}' % downtime src_remote_qmp.qmp_cmd_output(cmd=downtime_cmd) speed_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"max-bandwidth": %d}}' % speed src_remote_qmp.qmp_cmd_output(cmd=speed_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) \ and re.findall(r'"max-bandwidth": %d' % speed, output): test.test_print('Change downtime and speed successfully') else: test.test_error('Failed to change downtime and speed') test.main_step_log('5. Migrate guest from source host to destination host') 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('6.After migration finished,check migration statistics') cmd = '{"execute":"query-migrate"}' output = eval(src_remote_qmp.qmp_cmd_output(cmd=cmd)) transferred_ram = int(output.get('return').get('ram').get('transferred')) transferred_ram_cal = transferred_ram / 1024 / 1024 total_time = int(output.get('return').get('total-time')) total_time_cal = total_time / 1000 speed_cal = transferred_ram_cal / total_time_cal gap_cal = abs(speed_cal - speed_m) if (gap_cal >= gap_speed): test.test_error('The real migration speed and expected speed ' 'have a gap more than %d M/s' % gap_speed) else: test.test_print('The real migration speed is not more or less than ' 'expected speed by %d M/s' % gap_speed) real_downtime = int(output.get('return').get('downtime')) gap_cal = real_downtime - downtime if (gap_cal > gap_downtime): test.test_error('The real migration downtime and expected downtime ' 'have a gap more than %d milliseconds' % gap_downtime) else: test.test_print('The real migration downtime is not more or less than ' 'expected downtime by %d milliseconds' % gap_downtime) test.main_step_log('7.After migration finished, check the status of guest') test.sub_step_log('7.1 Reboot guest') test.sub_step_log('check dmesg info') cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd=cmd) if re.findall(r'Call Trace:', output) or not 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.2 DD a file inside guest') dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) 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('7.3 Shutdown guest') 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_10035', params=params) id = test.get_id() src_host_session = HostSession(id, params) downtime = 10000 speed_m = 20 speed = speed_m * 1024 * 1024 gap_speed = 5 gap_downtime = 5000 test.main_step_log('1.Boot up a 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) test.sub_step_log( '1.1 Connecting to src serial --- ignore for windows guest') test.main_step_log( '2. Running some application inside guest --- ignore for windows guest' ) test.main_step_log('3. Boot up the 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.sub_step_log('Wait 90s for guest boot up') time.sleep(90) test.main_step_log('4.Set the migration speed and downtime') downtime_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"downtime-limit": %d}}' % downtime src_remote_qmp.qmp_cmd_output(cmd=downtime_cmd) speed_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"max-bandwidth": %d}}' % speed src_remote_qmp.qmp_cmd_output(cmd=speed_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) \ and re.findall(r'"max-bandwidth": %d' % speed, output): test.test_print('Change downtime and speed successfully') else: test.test_error('Failed to change downtime and speed') test.main_step_log('5. Migrate guest from source host to destination host') 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('6.After migration finished,check migration statistics') cmd = '{"execute":"query-migrate"}' output = eval(src_remote_qmp.qmp_cmd_output(cmd=cmd)) transferred_ram = int(output.get('return').get('ram').get('transferred')) transferred_ram_cal = transferred_ram / 1024 / 1024 total_time = int(output.get('return').get('total-time')) total_time_cal = total_time / 1000 speed_cal = transferred_ram_cal / total_time_cal gap_cal = abs(speed_cal - speed_m) if (gap_cal >= gap_speed): test.test_error('The real migration speed %s M/s and expected speed ' 'have a gap more than %d M/s' % (speed_cal, gap_speed)) else: test.test_print('The real migration speed is not more or less than ' 'expected speed by %d M/s' % gap_speed) real_downtime = int(output.get('return').get('downtime')) gap_cal = real_downtime - downtime if (gap_cal > gap_downtime): test.test_error('The real migration downtime and expected downtime ' 'have a gap more than %d milliseconds' % gap_downtime) else: test.test_print('The real migration downtime is not more or less than ' 'expected downtime by %d milliseconds' % gap_downtime) test.main_step_log('7.After migration finished, check the status of guest') test.sub_step_log('7.1 Check dst guest status') status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: dst_remote_qmp.test_error('Dst vm is not running') test.sub_step_log('7.2 Reboot guest') dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') 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') time.sleep(30) status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: dst_remote_qmp.test_error('Dst vm is not running after reboot') output = dst_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: dst_remote_qmp.test_error('Failed to quit qemu on dst 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')) guest_passwd = params.get('guest_passwd') incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10027', params=params) id = test.get_id() src_host_session = HostSession(id, params) test.main_step_log('1. start vm on src host with \"-S\" in qemu cli') params.vm_base_cmd_add('S', 'None') 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 on the dst host ' 'with \"-incoming tcp:0:5800\" ' 'but without \"-S\" in qemu cli') params.vm_base_cmd_add('incoming', 'tcp:0:%s' % incoming_port) params.vm_base_cmd_del('S', 'None') dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(ip=dst_host_ip, cmd=dst_qemu_cmd, vm_alias='dst') test.sub_step_log('Check the status of dst guest') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. "cont" gust, after kernel start to load, ' 'implement migration during vm boot ') src_remote_qmp.qmp_cmd_output('{ "execute": "cont" }') test.sub_step_log('Connecting to src serial') src_serial = RemoteSerialMonitor(case_id=id, params=params, ip=src_host_ip, port=serial_port) search_str = '[ 0.000000]' while 1: output = src_serial.serial_output(max_recv_data=128, search_str=search_str) if re.findall(r'Found the searched keyword', output): test.test_print(output) do_migration(src_remote_qmp, incoming_port, dst_host_ip) break else: test.test_print(output) if re.findall(r'login:'******'Failed to find the keyword: %s' % search_str) test.main_step_log('4. After finish migration and guest boot up, ' 'check if guest works well') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) 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_passwd) dst_serial.test_print(guest_passwd, 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') incoming_port = params.get('incoming_port') serial_port = int(params.get('serial_port')) qmp_port = int(params.get('qmp_port')) test = CreateTest(case_id='rhel7_10062', params=params) id = test.get_id() query_migration_time = 2400 src_host_session = HostSession(id, params) src_qemu_cmd = params.create_qemu_cmd() test.main_step_log('Scenario 1:src: vhost des' 'fileCopy: from src host to guest ') test.main_step_log('1.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.main_step_log('1.2. Start listening mode without vhost in des host ') params.vm_base_cmd_del('netdev', 'tap,id=tap0,vhost=on') params.vm_base_cmd_add('netdev', 'tap,id=tap0') 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('1.3.Copy a large file(eg 2G) from host to guest ' 'in src host, then start to do migration ' 'during transferring file.') src_host_session.host_cmd(cmd='rm -rf /home/file_host') cmd = 'dd if=/dev/urandom of=/home/file_host bs=1M count=2048 oflag=direct' src_host_session.host_cmd_output(cmd, timeout=600) src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest') thread = threading.Thread(target=src_host_session.host_cmd_scp_put, args=('/home/file_host', '/home/file_guest', params.get('guest_passwd'), src_guest_ip, 600)) thread.name = 'scp_thread_put' thread.daemon = True thread.start() time.sleep(3) test.main_step_log('1.4. Migrate to the destination') 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 ') test.main_step_log( '1.5.After migration finishes,until transferring finished' 'reboot guest,Check file in host and guest.' 'value of md5sum is the same.') test.sub_step_log('check status of transferring the file') while True: pid = src_host_session.host_cmd_output('pgrep -x scp') if not pid: break time.sleep(3) test.sub_step_log('reboot guest') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) 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('network of guest should be woking') external_host_ip = 'www.redhat.com' cmd_ping = 'ping %s -c 10' % external_host_ip output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') test.sub_step_log('Check file in host and guest') file_src_host_md5 = src_host_session.host_cmd_output( cmd='md5sum /home/file_host') file_guest_md5 = dst_guest_session.guest_cmd_output( cmd='md5sum /home/file_guest') if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]: test.test_error('Value of md5sum error!') test.sub_step_log('1.6 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() src_host_session.check_guest_process(src_ip=src_host_ip, dst_ip=dst_host_ip) time.sleep(3) test.main_step_log('Scenario 2.src: des: vhost,' 'fileCopy: from src host to guest') src_host_session = HostSession(id, params) test.main_step_log('2.1. Start VM in src host ') incoming_val = 'tcp:0:%s' % (incoming_port) params.vm_base_cmd_del('incoming', incoming_val) 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.main_step_log('2.2 Start listening mode without vhost in des host ') params.vm_base_cmd_del('netdev', 'tap,id=tap0') params.vm_base_cmd_add('netdev', 'tap,id=tap0,vhost=on') 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('2.3.Copy a large file(eg 2G) from host to guest ' 'in src host, then start to do migration ' 'during transferring file.') src_host_session.host_cmd(cmd='rm -rf /home/file_host') cmd = 'dd if=/dev/urandom of=/home/file_host bs=1M count=2000 oflag=direct' src_host_session.host_cmd_output(cmd, timeout=600) src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest') thread = threading.Thread(target=src_host_session.host_cmd_scp_put, args=('/home/file_host', '/home/file_guest', params.get('guest_passwd'), src_guest_ip, 600)) thread.name = 'scp_thread_put' thread.daemon = True thread.start() time.sleep(3) test.main_step_log('2.4. Migrate to the destination') 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 ') test.main_step_log( '2.5.After migration finishes,until transferring finished' 'reboot guest,Check file in host and guest.' 'value of md5sum is the same.') test.sub_step_log('check status of transferring the file') while True: pid = src_host_session.host_cmd_output('pgrep -x scp') if not pid: break time.sleep(3) test.sub_step_log('reboot guest') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) 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('network of guest should be woking') external_host_ip = 'www.redhat.com' cmd_ping = 'ping %s -c 10' % external_host_ip output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') test.sub_step_log('Check file in host and guest') file_src_host_md5 = src_host_session.host_cmd_output( cmd='md5sum /home/file_host') file_guest_md5 = dst_guest_session.guest_cmd_output( cmd='md5sum /home/file_guest') if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]: test.test_error('Value of md5sum error!') test.sub_step_log('2.6.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() src_host_session.check_guest_process(src_ip=src_host_ip, dst_ip=dst_host_ip) time.sleep(3) test.main_step_log('Scenario 3.src:vhost des:,' 'fileCopy: from src guest to host') src_host_session = HostSession(id, params) test.main_step_log('3.1. Start VM in src host ') incoming_val = 'tcp:0:%s' % (incoming_port) params.vm_base_cmd_del('incoming', incoming_val) 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.main_step_log('3.2. Start listening mode without vhost in des host ') params.vm_base_cmd_del('netdev', 'tap,id=tap0,vhost=on') params.vm_base_cmd_add('netdev', 'tap,id=tap0') 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.3.Copy a large file(eg 2G) from host to guest ' 'in src host, then start to do migration ' 'during transferring file. ') src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest') cmd = 'dd if=/dev/urandom of=/home/file_guest ' \ 'bs=1M count=2000 oflag=direct' src_guest_session.guest_cmd_output(cmd, timeout=600) src_host_session.host_cmd_output(cmd='rm -rf /home/file_host') thread = threading.Thread(target=src_host_session.host_cmd_scp_get, args=('/home/file_host', '/home/file_guest', params.get('guest_passwd'), src_guest_ip, 600)) thread.name = 'scp_thread_get' thread.daemon = True thread.start() time.sleep(3) test.main_step_log('3.4. Migrate to the destination') 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 ') test.main_step_log( '3.5.After migration finishes,until transferring finished' 'reboot guest,Check file in host and guest.' 'value of md5sum is the same.') test.sub_step_log('check status of transferring the file') while True: pid = src_host_session.host_cmd_output('pgrep -x scp') if not pid: break time.sleep(3) test.sub_step_log('reboot guest') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) 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('network of guest should be woking') external_host_ip = 'www.redhat.com' cmd_ping = 'ping %s -c 10' % external_host_ip output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') test.sub_step_log('Check file in host and guest') file_src_host_md5 = src_host_session.host_cmd_output( cmd='md5sum /home/file_host') file_guest_md5 = dst_guest_session.guest_cmd_output( cmd='md5sum /home/file_guest') if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]: test.test_error('Value of md5sum error!') test.sub_step_log('3.6 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() src_host_session.check_guest_process(src_ip=src_host_ip, dst_ip=dst_host_ip) time.sleep(3) test.main_step_log('Scenario 4.src: des:vhost ,' 'fileCopy: from src guest to host') src_host_session = HostSession(id, params) test.main_step_log('4.1. Start VM in src host ') incoming_val = 'tcp:0:%s' % (incoming_port) params.vm_base_cmd_del('incoming', incoming_val) 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.main_step_log('4.2. Start listening mode without vhost in des host ') params.vm_base_cmd_del('netdev', 'tap,id=tap0') params.vm_base_cmd_add('netdev', 'tap,id=tap0,vhost=on') 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('4.3.Copy a large file(eg 2G) from host to guest ' 'in src host, then start to do migration ' 'during transferring file.') src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest') cmd = 'dd if=/dev/urandom of=/home/file_guest ' \ 'bs=1M count=2000 oflag=direct' src_guest_session.guest_cmd_output(cmd, timeout=600) src_host_session.host_cmd_output(cmd='rm -rf /home/file_host') thread = threading.Thread(target=src_host_session.host_cmd_scp_get, args=('/home/file_host', '/home/file_guest', params.get('guest_passwd'), src_guest_ip, 600)) thread.name = 'scp_thread_get' thread.daemon = True thread.start() time.sleep(3) test.main_step_log('4.4. Migrate to the destination') 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 ') test.main_step_log( '4.5.After migration finishes,until transferring finished' 'reboot guest,Check file in host and guest.' 'value of md5sum is the same.') while True: pid = src_host_session.host_cmd_output('pgrep -x scp') if not pid: break time.sleep(3) test.sub_step_log('reboot guest') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=serial_port) 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('network of guest should be woking') external_host_ip = 'www.redhat.com' cmd_ping = 'ping %s -c 10' % external_host_ip output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') test.sub_step_log('Check file in host and guest') file_src_host_md5 = src_host_session.host_cmd_output( cmd='md5sum /home/file_host') file_guest_md5 = dst_guest_session.guest_cmd_output( cmd='md5sum /home/file_guest') if file_src_host_md5.split(' ')[0] != file_guest_md5.split(' ')[0]: test.test_error('Value of md5sum error!') test.sub_step_log('4.6 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') test = CreateTest(case_id='rhel7_10052', params=params) id = test.get_id() src_host_session = HostSession(id, params) speed = 52428800 speed_m = speed / 1024 / 1024 downtime = 300 gap_speed = 5 test.main_step_log('1. Start a VM 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) 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. Start guest on dst host with listening mode ' '"incoming tcp:0:5800"') 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. On source host, set migration speed(max-bandwidth)') speed_cmd = '{"execute":"migrate-set-parameters","arguments":' \ '{"max-bandwidth": %d}}' % speed src_remote_qmp.qmp_cmd_output(cmd=speed_cmd) paras_chk_cmd = '{"execute":"query-migrate-parameters"}' output = src_remote_qmp.qmp_cmd_output(cmd=paras_chk_cmd) if re.findall(r'"max-bandwidth": %d' % speed, output): test.test_print('Set migration speed successfully') else: test.test_error('Failed to change speed') test.main_step_log('4. On source host, check the migration status') check_info = 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. After migration completed, check migration speed') output = eval(src_remote_qmp.qmp_cmd_output('{"execute":"query-migrate"}')) transferred_ram = int(output.get('return').get('ram').get('transferred')) src_remote_qmp.test_print('The transferred ram is: %d' % transferred_ram) transferred_ram_cal = transferred_ram / 1024 / 1024 total_time = int(output.get('return').get('total-time')) src_remote_qmp.test_print('The total time is: %d' % total_time) total_time_cal = total_time / 1000 speed_cal = transferred_ram_cal / total_time_cal gap_cal = abs(speed_cal - speed_m) if (gap_cal >= gap_speed): test.test_error('The real migration speed and expected speed have ' 'a gap more than %d M/s' % gap_speed) else: test.test_print('The real migration speed is not more or less than ' 'expected speed by %d M/s' % gap_speed) 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) 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('6.2 Ping external host') external_host_ip = 'www.redhat.com' cmd_ping = 'ping %s -c 10' % external_host_ip dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') test.sub_step_log('6.3 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_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') incoming_port = str(params.get('incoming_port')) qmp_port = int(params.get('qmp_port')) test = CreateTest(case_id='rhel7_10057_win', params=params) id = test.get_id() downtime = '30000' script = 'migration_dirtypage_1.c' query_timeout = 2400 active_timeout = 300 running_timeout = 300 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('Wait 90s for guest boot up') time.sleep(90) 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(ip=dst_host_ip, cmd=dst_qemu_cmd, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log( '3. src guest have ' 'programme running to generate dirty page --- skip for windows guest') test.main_step_log('4. Migrate to the destination') cmd = '{"execute":"migrate", "arguments": {"uri": "tcp:%s:%s"}}' % \ (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd) test.main_step_log('5.set downtime for migration') flag_active = False cmd = '{"execute":"query-migrate"}' end_time = time.time() + active_timeout while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output(cmd) if re.findall(r'"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): src_remote_qmp.test_error('Migration could not be active within %d' % active_timeout) 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('Set migration downtime successfully') else: test.test_error('Failed to change downtime') test.sub_step_log('Check the status of migration') flag = False cmd = '{"execute":"query-migrate"}' end_time = time.time() + query_timeout while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output(cmd=cmd) if re.findall(r'"remaining": 0', output): flag = True break elif re.findall(r'"status": "failed"', output): src_remote_qmp.test_error('migration failed') if (flag == False): test.test_error('Migration timeout in %d' % query_timeout) test.main_step_log('6.Check status of guest in dst host') cmd = '{"execute":"query-status"}' flag_running = False end_time = time.time() + running_timeout while time.time() < end_time: output = dst_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=3) if re.findall(r'"status": "running"', output): flag_running = True break if (flag_running == False): test.test_error('Dst guest is not running after migration finished %d ' 'seconds' % running_timeout) 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') output = dst_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: dst_remote_qmp.test_error('Failed to quit qemu on dst end')
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_11911_virtio_scsi_local', params=params) id = test.get_id() host_session = HostSession(id, params) test.main_step_log('1. prepare a installed guest.') test.main_step_log('2. create a data disk.') image_format = params.get('image_format') drive_format = params.get('drive_format') if 'qcow2' in image_format: host_session.create_image( 'qemu-img create -f qcow2 %s/test1.img 100G' % tmp_file) elif 'raw' in image_format: host_session.create_image('qemu-img create -f raw %s/test1.img 100G' % tmp_file) test.main_step_log('3. boot a guest attached data disk created by step 2.') params.vm_base_cmd_add( 'drive', 'id=drive_data0,if=none,snapshot=off,' 'aio=threads,cache=none,format=%s,' 'file=%s/test1.img' % (image_format, tmp_file)) if 'virtio-scsi' in drive_format: params.vm_base_cmd_add( 'device', 'scsi-hd,id=scsi-hd0,drive=drive_data0,' 'channel=0,scsi-id=10,lun=0') elif 'virtio-blk' in drive_format: params.vm_base_cmd_add( 'device', 'virtio-blk-pci,' 'drive=drive_data0,' 'id=virtio-blk0') qemu_cmd = params.create_qemu_cmd() host_session.boot_guest(cmd=qemu_cmd) serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) guest_ip = serial.serial_login() test.main_step_log('4. in guest: # mkfs.ext4 /dev/[vs]db ' '# mount /dev/[vs]db /mnt ' '# dd if=/dev/zero of=/mnt/test1 ' 'bs=4k count=1000 oflag=direct') guest_session = GuestSession(case_id=id, params=params, ip=guest_ip) test.sub_step_log('4.1 check the disk status inside guest') data_disk_list = guest_session.get_data_disk() guest_session.guest_cmd_output('mkfs.xfs %s' % data_disk_list[0]) guest_session.guest_cmd_output('mount %s /mnt' % data_disk_list[0]) guest_session.guest_cmd_output('mount | grep /mnt') guest_session.guest_cmd_output(cmd='dd if=/dev/zero ' 'of=/mnt/test1 bs=4k ' 'count=1000 oflag=direct', timeout=600) test.main_step_log('5. repeat step 4 using bs=8k / ' '16k / 32k/ 64k / 128k / 256k') bs_size_list = ['8k', '16k', '32k', '64k', '128k', '256k'] for bs_size in bs_size_list: guest_session.guest_cmd_output(cmd='dd if=/dev/zero ' 'of=/mnt/test1 bs=%s ' 'count=1000 oflag=direct' % bs_size, timeout=600) guest_session.guest_cmd_output('umount /mnt') test.main_step_log('6. start multi dd progress at the same time.' '- write 8 partition with ' 'bs= 4k/8k/16k/64k/128k/256k/4M/1G at the same time, ' '- read 8 partition with ' 'bs= 4k/8k/16k/64k/128k/256k/4M/1G at the same time') guest_session.guest_create_parts(dev=data_disk_list[0], num=8) data_disk_list = guest_session.get_data_disk()[1:] bs_size_list = ['8k', '16k', '32k', '64k', '128k', '256k', '4M', '1G'] map( lambda dev, size: guest_session.guest_cmd_output( cmd='dd if=/dev/zero of=%s bs=%s count=1000 oflag=direct &' % (dev, size), timeout=600), data_disk_list, bs_size_list) while 1: if not guest_session.guest_cmd_output('pgrep -x dd'): break time.sleep(5) map( lambda dev, size: guest_session.guest_cmd_output( cmd='dd if=%s of=/dev/null bs=%s count=1000 iflag=direct &' % (dev, size), timeout=600), data_disk_list, bs_size_list) while 1: if not guest_session.guest_cmd_output('pgrep -x dd'): break time.sleep(5) guest_session.guest_dmesg_check()
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') 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_58670', params=params) id = test.get_id() src_host_session = HostSession(id, params) val_M = '2000' val_s = '10000' ping_file = '/tmp/ping' 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') utils_migration.stressapptest(guest_session=src_guest_session, val_M=val_M, val_s=val_s) test.main_step_log('3. ping guest from host, keep it during whole ' 'migration process') flag = False endtime =time.time() + 300 while time.time() < endtime: output = src_host_session.host_cmd_output(cmd='pgrep ping') if output: src_host_session.host_cmd(cmd='pgrep ping | xargs kill -9') else: flag = True break if flag == False: test.test_error('Failed to kill existing ping process') cmd = 'ping %s > %s &' % (src_guest_ip, ping_file) src_host_session.host_cmd(cmd=cmd) test.main_step_log('4. 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('5. check postcopy capability 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('6. 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.main_step_log('7. Cancel migration') status = utils_migration.query_status(remote_qmp=src_remote_qmp, status='active') if (status == False): test.test_error('Migration status is not active') cmd = '{"execute":"migrate_cancel"}' src_remote_qmp.qmp_cmd_output(cmd=cmd) output = utils_migration.query_status(remote_qmp=src_remote_qmp, status='cancelled') if (output == True): test.test_print('Migration is cancelled successfully') if (output == False): test.test_error('Migration status is not cancelled') ping_pid = src_host_session.host_cmd_output(cmd='pgrep ping') if not ping_pid: test.test_error('The process of host ping guest is not existing') cmd = 'kill -9 %s' % ping_pid src_host_session.host_cmd(cmd=cmd) fo = open(ping_file, 'r') for line in fo.readlines(): line = line.strip() if re.findall(r'unknown host name', line) \ or re.findall(r'unreachable', line) \ or re.findall(r'timeout', line): test.test_error('There is error in ping file') test.test_print('There is no error in ping file') fo.close()
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_10059', params=params) id = test.get_id() src_host_session = HostSession(id, params) test.main_step_log('1. Start source vm') src_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(src_qemu_cmd, vm_alias='src') 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_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) src_guest_session = GuestSession(case_id=id, params=params, ip=src_guest_ip) test.main_step_log('2. Create a file in host') src_host_session.host_cmd(cmd='rm -rf /home/file_host') src_host_session.host_cmd(cmd='rm -rf /home/file_host2') cmd = 'dd if=/dev/urandom of=/home/file_host bs=1M count=5000 oflag=direct' src_host_session.host_cmd_output(cmd, timeout=600) test.main_step_log('3. Start des vm in migration-listen mode: "-incoming tcp:0:****"') params.vm_base_cmd_add('incoming', 'tcp:0:%s' %incoming_port) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_remote_guest(ip=dst_host_ip, cmd=dst_qemu_cmd, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('4. Transfer file from host to guest') src_guest_session.guest_cmd_output(cmd='rm -rf /home/file_guest') thread = threading.Thread(target=scp_thread_put, args=(src_host_session, '/home/file_host', '/home/file_guest', params.get('guest_passwd'), src_guest_ip, 600)) thread.name = 'scp_thread_put' thread.daemon = True thread.start() test.main_step_log('5. Start migration') do_migration(src_remote_qmp, incoming_port, dst_host_ip) test.main_step_log('6. Ping-pong migrate until file transfer finished') src_remote_qmp, dst_remote_qmp = ping_pong_migration(params, id, src_host_session, src_remote_qmp, dst_remote_qmp, times=10, query_thread='pgrep -x scp') test.sub_step_log('Login dst guest after ping-pong migration') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) test.sub_step_log('Check dmesg info ') cmd = 'dmesg' output = dst_serial.serial_cmd_output(cmd) if re.findall(r'Call Trace:', output): dst_serial.test_error('Guest hit call trace') dst_serial.serial_cmd('reboot') dst_guest_ip = dst_serial.serial_login() dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) cmd = "md5sum /home/file_host | awk '{print $1}'" file_src_host_md5 = src_host_session.host_cmd_output(cmd) cmd = "md5sum /home/file_guest | awk '{print $1}'" file_guest_md5 = dst_guest_session.guest_cmd_output(cmd) if file_src_host_md5 != file_guest_md5: test.test_error('Value of md5sum error!') test.main_step_log('7. Transfer file from guest to host') thread = threading.Thread(target=scp_thread_get, args=(src_host_session, '/home/file_host2', '/home/file_guest', params.get('guest_passwd'), dst_guest_ip, 600)) thread.name = 'scp_thread_get' thread.daemon = True thread.start() test.main_step_log('8. Ping-Pong migration until file transfer finished.') ping_pong_migration(params, id, src_host_session, src_remote_qmp, dst_remote_qmp, times=10, query_thread='pgrep -x scp') test.main_step_log('9. Check md5sum after file transfer') cmd = "md5sum /home/file_host | awk '{print $1}'" file_src_host_md5 = src_host_session.host_cmd_output(cmd) cmd = "md5sum /home/file_host2 | awk '{print $1}'" file_src_host2_md5 = src_host_session.host_cmd_output(cmd) if file_src_host_md5 != file_src_host2_md5: test.test_error('Value of md5sum error!') test.sub_step_log('Check dmesg info ') 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): dst_serial.test_error('Guest hit call trace')
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_win', params=params) id = test.get_id() guest_name = test.guest_name src_host_session = HostSession(id, params) balloon_val = '2147483648' 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 --- skip for windows guest') 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.') status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: dst_remote_qmp.test_error('Dst vm is not running') 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, ' 'and shutdown.') test.sub_step_log('11.1 Check src guest status') status = src_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: src_remote_qmp.test_error('Src vm is not running') test.sub_step_log('11.2 Reboot src guest') src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') test.sub_step_log('11.3 quit qemu on dst end and shutdown vm on src end') output = dst_remote_qmp.qmp_cmd_output('{"execute":"quit"}', recv_timeout=3) if output: dst_remote_qmp.test_error('Failed to quit qemu on dst end') time.sleep(30) status = src_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: src_remote_qmp.test_error('Src vm is not running after reboot') 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): serial_port = int( params.get('vm_cmd_base')['serial'][0].split(',')[0].split(':')[2]) nfs_server_list = params.get('nfs_server') test = CreateTest(case_id='unattended_installation', params=params) id = test.get_id() host_session = HostSession(id, params) nfs_server_ip_list = [] for server in nfs_server_list: nfs_server_ip_list.append(server.split(':')[0]) test.test_print('NFS server ip:%s' % nfs_server_ip_list) if 'x86_64' in params.get('guest_arch'): params.vm_base_cmd_add('machine', 'pc') elif 'ppc64' in params.get('guest_arch'): params.vm_base_cmd_add('machine', 'pseries') rtt_info = {} rtt_val = [] test.main_step_log('1. Chose a nfs server.') for ip in nfs_server_ip_list: ping_cmd = 'ping %s -c 5' % ip output = host_session.host_cmd_output(ping_cmd) rtt_line = output.splitlines()[-1] if float(rtt_line.split('/')[-3]) < float(params.get('rtt_tolerance')): rtt_info[ip] = rtt_line.split('/')[-3] rtt_val.append(float(rtt_line.split('/')[-3])) if not rtt_val: test.test_error('No available nfs server.') test.test_print('rtt info : %s' % rtt_info) min_rtt_val = min(rtt_val) mount_info = '' for ip, rtt in rtt_info.items(): if float(rtt) == min_rtt_val: for nfs_server in nfs_server_list: if ip in nfs_server: mount_info = nfs_server test.test_print('Mount point info : %s' % mount_info) image_dir = os.path.join(os.path.join(BASE_FILE, 'images'), params.get('image_name')) if not os.path.exists(image_dir): os.makedirs(image_dir) image_size = params.get('image_size') test.main_step_log('2. Create a system image to install os.') if params.get('image_format') == 'qcow2': image = os.path.join(image_dir, (params.get('image_name') + '.qcow2')) host_session.host_cmd_output('rm -rf %s' % image) host_session.host_cmd_output('qemu-img create -f qcow2 %s %s' % (image, image_size)) params.vm_base_cmd_add( 'drive', 'id=drive_image1,if=none,snapshot=off,' 'aio=threads,cache=none,format=qcow2,' 'file=%s' % image) elif params.get('image_format') == 'raw': image = image_dir + params.get('image_name') + '.raw' host_session.host_cmd_output('qemu-img create -f raw %s %s' % (image, image_size)) params.vm_base_cmd_add( 'drive', 'id=drive_image1,if=none,snapshot=off,' 'aio=threads,cache=none,format=raw,' 'file=%s' % image) elif params.get('image_format') == 'luks': pass if params.get('drive_format') == 'virtio_scsi': params.vm_base_cmd_add('device', 'scsi-hd,id=image1,drive=drive_image1') elif params.get('drive_format') == 'virtio_blk': params.vm_base_cmd_add('device', 'virtio-blk-pci,id=image1,drive=drive_image1') isos_dir = os.path.join(BASE_FILE, 'isos') if not os.path.exists(isos_dir): os.makedirs(isos_dir) test.main_step_log('3. Mount iso from nfs server.') host_session.host_cmd_output('mount -t nfs %s %s' % (mount_info, isos_dir)) test.main_step_log('4. Find the corresponding iso') iso_pattern = params.get('iso_name') + '*' + 'Server' + '-' \ + params.get('guest_arch') + '-' + 'dvd1.iso' iso_name = host_session.host_cmd_output('find %s -name %s' % (isos_dir, iso_pattern)) if not iso_name: test.test_error('No found the corresponding %s iso.' % params.get('iso_name')) test.test_print('Found the corresponding iso: %s' % iso_name) params.vm_base_cmd_add( 'drive', 'id=drive_cd1,if=none,snapshot=off,aio=threads,' 'cache=none,media=cdrom,file=%s' % iso_name) params.vm_base_cmd_add('device', 'scsi-cd,id=cd1,drive=drive_cd1,bootindex=2') ks_dir = os.path.join(BASE_FILE, 'ks') if not os.path.exists(ks_dir): os.makedirs(ks_dir) test.main_step_log('5. Find the corresponding ks') ks_pattern = params.get('iso_name').split('.')[0] + '*' ks = host_session.host_cmd_output('find %s -name %s' % (ks_dir, ks_pattern)) ks_iso = os.path.join(ks_dir, 'ks.iso') test.main_step_log('6. Make a %s form %s.' % (ks_iso, ks)) host_session.host_cmd_output('mkisofs -o %s %s' % (ks_iso, ks)) params.vm_base_cmd_add( 'drive', 'id=drive_unattended,if=none,snapshot=off,' 'aio=threads,cache=none,media=cdrom,' 'file=%s' % ks_iso) params.vm_base_cmd_add( 'device', 'scsi-cd,' 'id=unattended,drive=drive_unattended,bootindex=3') params.vm_base_cmd_add('m', params.get('mem_size')) params.vm_base_cmd_add( 'smp', '%d,cores=%d,threads=1,sockets=%d' % (int(params.get('vcpu')), int(params.get('vcpu')) / 2, int(params.get('vcpu')) / 2)) mount_dir = os.path.join(BASE_FILE, 'mnt') if not os.path.exists(mount_dir): os.makedirs(mount_dir) test.main_step_log('7. cp vmlinuz and initrd.img form %s.' % iso_name) host_session.host_cmd_output('mount %s %s' % (iso_name, mount_dir)) if 'x86_64' in params.get('guest_arch'): host_session.host_cmd_output('cp /%s/images/pxeboot/vmlinuz %s' % (mount_dir, image_dir)) host_session.host_cmd_output('cp /%s/images/pxeboot/initrd.img %s' % (mount_dir, image_dir)) host_session.host_cmd_output('umount %s' % mount_dir) if 'ppc64' in params.get('guest_arch'): host_session.host_cmd_output('cp /%s/ppc/ppc64/vmlinuz %s' % (mount_dir, image_dir)) host_session.host_cmd_output('cp /%s/ppc/ppc64/initrd.img %s' % (mount_dir, image_dir)) host_session.host_cmd_output('umount %s' % mount_dir) test.main_step_log('8. Check the name of mounted ks.iso.') host_session.host_cmd_output('mount %s %s' % (ks_iso, mount_dir)) ks_name = host_session.host_cmd_output('ls %s' % mount_dir) host_session.host_cmd_output('umount %s' % mount_dir) params.vm_base_cmd_add('kernel', '"%s/vmlinuz"' % image_dir) console_option = '' if 'x86_64' in params.get('guest_arch'): console_option = 'ttyS0,115200' if 'ppc64' in params.get('guest_arch'): console_option = 'hvc0,38400' params.vm_base_cmd_add( 'append', '"ksdevice=link inst.repo=cdrom:/dev/sr0 ' 'inst.ks=cdrom:/dev/sr1:/%s nicdelay=60 ' 'biosdevname=0 net.ifnames=0 ' 'console=tty0 console=%s"' % (ks_name, console_option)) params.vm_base_cmd_add('initrd', '"%s/initrd.img"' % image_dir) test.main_step_log( '9. Boot this guest and start to install os automaticlly.') qemu_cmd = params.create_qemu_cmd() host_session.boot_guest(cmd=qemu_cmd) guest_serial = RemoteSerialMonitor(case_id=id, params=params, ip='0', port=serial_port) end_timeout = time.time() + int(params.get('install_timeout')) install_done = False while time.time() < end_timeout: output = guest_serial.serial_output() test.test_print(output) if re.findall(r'Power down', output): install_done = True host_session.host_cmd_output('rm -rf %s/initrd.img' % image_dir) host_session.host_cmd_output('rm -rf %s/vmlinuz' % image_dir) host_session.host_cmd_output('rm -rf %s' % ks_iso) break if install_done == False: host_session.host_cmd_output('rm -rf %s/initrd.img' % image_dir) host_session.host_cmd_output('rm -rf %s/vmlinuz' % image_dir) host_session.host_cmd_output('rm -rf %s' % ks_iso) test.test_error('Install failed under %s sec' % params.get('install_timeout')) else: test.test_print('Install successfully.')
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_59369', params=params) id = test.get_id() src_host_session = HostSession(id, params) test.main_step_log('1. Boot guest with specified SMP configuration') params.vm_base_cmd_update('smp', '4,maxcpus=4,cores=2,threads=1,sockets=2', '2,maxcpus=4,cores=2,threads=2,sockets=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.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 hot-pluggable CPU information') cmd = '{"execute": "query-hotpluggable-cpus"}' output = src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5) if re.findall(r'"qom-path": "/machine/peripheral/core1"', output): src_remote_qmp.test_error('The info of hot-pluggable cpu is wrong') else: src_remote_qmp.test_print('The info of hot-pluggable cpu is right') test.main_step_log('3. Hot-plug the CPU core') cmd = '{"execute": "device_add", "arguments": ' \ '{"driver":"host-spapr-cpu-core","core-id": 2,"id":"core1"}}' output = src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5) if re.findall('error', output): test.test_error('Failed to execute cpu hotplug command') else: test.test_print('Cpu hotpulg command is executed successfully') test.main_step_log('4. Verify the core has been hot-plugged to the guest') test.sub_step_log('4.1 Check cpu info inside guest') cmd = "lscpu | sed -n '3p' | awk '{print $2}'" output = src_serial.serial_cmd_output(cmd=cmd) if not re.findall(r'4', output): test.test_error('The guest cpus info checked inside guest is wrong') test.sub_step_log('4.2 Check cpu info in src host') cmd = '{"execute": "query-hotpluggable-cpus"}' output = src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5) if re.findall(r'"qom-path": "/machine/peripheral/core1"', output): src_remote_qmp.test_print('The guest cpus info checked in src host ' 'is right') else: src_remote_qmp.test_print('The guest cpus info checked in src host ' 'is wrong') test.main_step_log('5. Boot the destination guest ' '(with the hot-plugged core)') cpu_val = 'host-spapr-cpu-core,core-id=2,id=core1' params.vm_base_cmd_add('device', cpu_val) 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) cmd = '{"execute": "query-hotpluggable-cpus"}' output = dst_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=5) if re.findall(r'"qom-path": "/machine/peripheral/core1"', output): src_remote_qmp.test_print('The guest cpus info of dst host is right') else: src_remote_qmp.test_print('The guest cpus info of dst host is wrong') test.main_step_log('6. Migrate guest from source to destination and ' 'wait until it finishes,quit qemu of 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') output = src_remote_qmp.qmp_cmd_output('{"execute":"quit"}', recv_timeout=5) if output: src_remote_qmp.test_error('Failed to quit qemu on src host') test.main_step_log('7. Run some command onto the hot-plugged core') dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port) time.sleep(10) cmd = 'taskset -c 2,3 dd if=/dev/urandom of=/dev/null bs=64K count=1000' output = dst_serial.serial_cmd_output(cmd=cmd, recv_timeout=5) if re.findall('Failed', output) or re.findall('Error', output): test.test_error('Failed to execute taskset inside guest') else: test.test_print('Succeed to execute taskset inside guest') test.main_step_log('8. Reboot and then shutdown guest') 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_serial.serial_login() cmd = "lscpu | sed -n '3p' | awk '{print $2}'" output = dst_serial.serial_cmd_output(cmd=cmd) if re.findall(r'4', output): test.test_print('After reboot, the guest cpus info is right') else: test.test_error('After reboot, the guest cpus info is wrong') 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') 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_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') incoming_port = str(params.get('incoming_port')) serial_port = int(params.get('serial_port')) qmp_port = int(params.get('qmp_port')) test = CreateTest(case_id='rhel7_10057', params=params) id = test.get_id() guest_passwd = params.get('guest_passwd') downtime = '30000' script = 'migration_dirtypage_1.c' query_timeout = 2400 active_timeout = 300 running_timeout = 300 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(ip=dst_host_ip, cmd=dst_qemu_cmd, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port) test.main_step_log('3. src guest have ' 'programme running to generate dirty page') test.sub_step_log('run dirty page script') 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' 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 dirty1' % script src_guest_session.guest_cmd_output(cmd=compile_cmd) output = src_guest_session.guest_cmd_output('ls /home | grep -w "dirty1"') if not output: test.test_error('Failed to compile %s' % script) dirty_cmd = 'cd /home;./dirty1' thread = threading.Thread(target=src_guest_session.guest_cmd_output, args=(dirty_cmd, 4800)) thread.name = 'dirty1' thread.daemon = True thread.start() time.sleep(10) output = src_guest_session.guest_cmd_output('pgrep -x dirty1') if not output: test.test_error('Dirty1 is not running in guest') test.main_step_log('4. Migrate to the destination') cmd = '{"execute":"migrate", "arguments": {"uri": "tcp:%s:%s"}}' % \ (dst_host_ip, incoming_port) src_remote_qmp.qmp_cmd_output(cmd) test.main_step_log('5.set downtime for migration') flag_active = False cmd = '{"execute":"query-migrate"}' end_time = time.time() + active_timeout while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output(cmd) if re.findall(r'"status": "active"', output): flag_active = True break elif re.findall(r'"status": "failed"', output): src_remote_qmp.qmp_cmd_output('Migration failed') if (flag_active == False): src_remote_qmp.qmp_cmd_output( 'Migration could not be active within %d' % active_timeout) 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('Set migration downtime successfully') else: test.test_error('Failed to change downtime') test.sub_step_log('Check the status of migration') flag = False cmd = '{"execute":"query-migrate"}' end_time = time.time() + query_timeout while time.time() < end_time: output = src_remote_qmp.qmp_cmd_output(cmd=cmd) if re.findall(r'"remaining": 0', output): flag = True break elif re.findall(r'"status": "failed"', output): src_remote_qmp.test_error('migration failed') if (flag == False): test.test_error('Migration timeout in %d' % query_timeout) test.main_step_log('6.Check status of guest in des host') cmd = '{"execute":"query-status"}' flag_running = False end_time = time.time() + running_timeout while time.time() < end_time: output = dst_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=3) if re.findall(r'"status": "running"', output): flag_running = True break if (flag_running == False): test.test_error('Dst guest is not running after migration finished %d ' 'seconds' % running_timeout) 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') dst_serial = RemoteSerialMonitor(case_id=id, params=params, ip=dst_host_ip, port=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() external_host_ip = dst_host_ip dst_guest_session = GuestSession(case_id=id, params=params, ip=dst_guest_ip) cmd_ping = 'ping %s -c 10' % external_host_ip output = dst_guest_session.guest_cmd_output(cmd=cmd_ping) if re.findall(r'100% packet loss', output): dst_guest_session.test_error('Ping failed') 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 = src_host_ip qmp_port = int(params.get('qmp_port')) serial_port = int(params.get('serial_port')) vnc_port = int(params.get('vnc_port')) share_images_dir = params.get('share_images_dir') test = CreateTest(case_id='rhel7_10075', params=params) id = test.get_id() src_host_session = HostSession(id, params) query_timeout = 1200 test.main_step_log('1. Boot a 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) test.sub_step_log( '1.1 Connecting to src serial --- ignore for windows guest') test.main_step_log('2. start listening port in the same host') vnc_port_new = int(vnc_port + 1) params.vm_base_cmd_update('vnc', ':%d' % vnc_port, ':%d' % vnc_port_new) qmp_port_new = int(qmp_port + 1) params.vm_base_cmd_update('qmp', 'tcp:0:%d,server,nowait' % qmp_port, 'tcp:0:%d,server,nowait' % qmp_port_new) serial_port_new = int(serial_port + 1) params.vm_base_cmd_update('serial', 'tcp:0:%d,server,nowait' % serial_port, 'tcp:0:%d,server,nowait' % serial_port_new) output = src_host_session.host_cmd_output('rm -f %s/unix' % share_images_dir) if output: test.test_error('Failed to delete the existed unix socket') incoming_val = 'unix:%s/unix' % share_images_dir params.vm_base_cmd_add('incoming', incoming_val) dst_qemu_cmd = params.create_qemu_cmd() src_host_session.boot_guest(cmd=dst_qemu_cmd, vm_alias='dst') dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port_new) test.main_step_log('3. do live migration') test.sub_step_log('3.1 Check whether the socket exists') output = src_host_session.host_cmd_output('ls %s | grep unix' % share_images_dir) if re.findall(r'unix', output): test.test_print('unix socket exists') else: test.test_error('Unix socket does not exist') test.sub_step_log('3.2 Begin to do migration') cmd = '{"execute":"migrate","arguments":{"uri":"unix:%s/unix"}}' \ % share_images_dir src_remote_qmp.qmp_cmd_output(cmd=cmd, recv_timeout=6) test.sub_step_log('Check the status of migration') flag = query_migration(remote_qmp=src_remote_qmp, chk_timeout=query_timeout) if (flag == False): test.test_error('Migration timeout in %d' % query_timeout) test.main_step_log('4. After migration, check if guest works well.') test.sub_step_log('4.1 Check dst guest status') status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: dst_remote_qmp.test_error('Dst vm is not running') test.sub_step_log('4.2. Reboot guest') dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') time.sleep(30) status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: dst_remote_qmp.test_error('Dst vm is not running after reboot') output = dst_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: dst_remote_qmp.test_error('Failed to quit qemu 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 end')
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_11948_virtio_scsi_local', params=params) id = test.get_id() host_session = HostSession(id, params) test.main_step_log('1. create a data image.') image_format = params.get('image_format') drive_format = params.get('drive_format') if 'qcow2' in image_format: host_session.create_image('qemu-img create -f qcow2 %s/test1.img 15G' % tmp_file) elif 'raw' in image_format: host_session.create_image('qemu-img create -f raw %s/test1.img 15G' % tmp_file) test.main_step_log('2. start guest with this image as data image') params.vm_base_cmd_add( 'drive', 'id=device1,if=none,snapshot=off,' 'aio=threads,cache=none,format=%s,' 'file=%s/test1.img' % (image_format, tmp_file)) if 'virtio-scsi' in drive_format: params.vm_base_cmd_add( 'device', 'scsi-hd,id=scsi-hd0,drive=device1,' 'channel=0,scsi-id=10,lun=0') elif 'virtio-blk' in drive_format: params.vm_base_cmd_add( 'device', 'virtio-blk-pci,' 'drive=device1,' 'id=virtio-blk0') qemu_cmd = params.create_qemu_cmd() host_session.boot_guest(cmd=qemu_cmd) serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port) guest_ip = serial.serial_login() test.main_step_log('3. create a file in the device and record md5 value.') guest_session = GuestSession(case_id=id, params=params, ip=guest_ip) test.sub_step_log('3.1 check the disk status inside guest') data_disk_list = guest_session.get_data_disk() test.sub_step_log('3.2 mount this device to /mnt') guest_session.guest_cmd_output('mkfs.xfs %s' % data_disk_list[0]) guest_session.guest_cmd_output('mount %s /mnt' % data_disk_list[0]) guest_session.guest_cmd_output('mount | grep /mnt') test.sub_step_log('3.3 create a file to /mnt with dd') guest_session.guest_cmd_output(cmd='dd if=/dev/urandom ' 'of=/mnt/test1 bs=1M ' 'count=500 oflag=direct', timeout=600) test.sub_step_log('3.4 check the value md5sum of file') before_md5 = guest_session.guest_cmd_output( 'md5sum /mnt/test1 | awk {\'print $1\'}') test.main_step_log('4. block resize device1 20G') qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port) qmp.qmp_cmd_output( '{ "execute": "block_resize", ' '"arguments": { "device": "device1", "size": 21474836480 }}') if guest_session.guest_get_disk_size( dev=guest_session.get_data_disk()[0]) != '20G': test.test_error('Failed to block resize device1 to 20G') test.sub_step_log('4.1 check the value md5sum of file after block resize') after_md5 = guest_session.guest_cmd_output( 'md5sum /mnt/test1 | awk {\'print $1\'}') if after_md5 != before_md5: test.test_error('value md5 changed after block resize.') if 'raw' in image_format: test.main_step_log('5. block resize device1 10G') qmp.qmp_cmd_output( '{ "execute": "block_resize", ' '"arguments": { "device": "device1", "size": 10737418240 }}') if guest_session.guest_get_disk_size( dev=guest_session.get_data_disk()[0]) != '10G': test.test_error('Failed to block resize device1 to 10G') test.sub_step_log( '5.1 check the value md5sum of file after block resize') after_md5 = guest_session.guest_cmd_output( 'md5sum /mnt/test1 | awk {\'print $1\'}') if after_md5 != before_md5: test.test_error('value md5 changed after block resize.') guest_session.guest_dmesg_check()
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')) incoming_port = params.get('incoming_port') test = CreateTest(case_id='rhel7_10056_win', params=params) id = test.get_id() src_host_session = HostSession(id, params) speed = '1073741824' active_timeout = 300 stress_time = 120 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('Wait 90s for guest boot up') time.sleep(90) 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 dst guest status and reboot guest') test.sub_step_log('4.1 Check dst guest status') status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: dst_remote_qmp.test_error('Dst vm is not running') test.sub_step_log('4.2. Reboot guest') dst_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}') 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') time.sleep(30) status = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}') if '\"status\": \"running\"' not in status: dst_remote_qmp.test_error('Dst vm is not running after reboot') output = dst_remote_qmp.qmp_cmd_output('{"execute":"quit"}') if output: dst_remote_qmp.test_error('Failed to quit qemu on dst end')