Пример #1
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    incoming_port = params.get('incoming_port')
    guest_arch = params.get('guest_arch')
    test = CreateTest(case_id='rhel7_10026', params=params)
    id = test.get_id()
    guest_pwd = params.get('guest_passwd')
    src_host_session = HostSession(id, params)
    login_timeout = 1200

    test.main_step_log('1. Start vm on src host')
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)
    src_serial = RemoteSerialMonitor(id, params, src_host_ip, serial_port)
    src_guest_ip = src_serial.serial_login()

    test.main_step_log('2. Start listening mode on dst host')
    incoming_val = 'tcp:0:%s' % incoming_port
    params.vm_base_cmd_add('incoming', incoming_val)
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_remote_guest(cmd=dst_qemu_cmd,
                                       ip=dst_host_ip,
                                       vm_alias='dst')
    dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port)
    dst_serial = RemoteSerialMonitor(id, params, dst_host_ip, serial_port)

    test.main_step_log('3. keep reboot vm with system_reset, let guest '
                       'in bios stage, before kernel loading')
    src_remote_qmp.qmp_cmd_output('{"execute":"system_reset"}')
    if 'ppc64' in guest_arch:
        keyword = 'SLOF'
    elif 'x86_64' in guest_arch:
        keyword = '[    0.000000]'
    while 1:
        serial_output = src_serial.serial_output(max_recv_data=128,
                                                 search_str=keyword)
        test.test_print(serial_output)
        if re.findall(r'Found the searched keyword', serial_output):
            break
        if re.findall(r'login', serial_output):
            test.test_error('Failed to catch migration point')

    test.main_step_log('4. implement migrate during vm reboot')
    chk_info = do_migration(src_remote_qmp, incoming_port, dst_host_ip)
    if (chk_info == True):
        test.test_print('Migration succeed')
    elif (chk_info == False):
        test.test_error('Migration timeout')

    test.main_step_log('5. After migration, check if guest works well')
    timeout = 600
    endtime = time.time() + timeout
    bootup = False
    while time.time() < endtime:
        cmd = 'root'
        dst_serial.send_cmd(cmd)
        output = dst_serial.rec_data(recv_timeout=8)
        dst_serial.test_print(info=output, serial_debug=True)
        if re.findall(r'Password', output):
            dst_serial.send_cmd(guest_pwd)
            dst_serial.test_print(guest_pwd, serial_debug=True)
            output = dst_serial.rec_data(recv_timeout=8)
            dst_serial.test_print(info=output, serial_debug=True)
            if re.search(r"login:"******"login:"******"execute":"quit"}')
    if output:
        src_remote_qmp.test_error('Failed to quit qemu on src end')
Пример #2
0
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')
Пример #3
0
def run_case(params):
    src_host_ip = params.get('src_host_ip')
    dst_host_ip = params.get('dst_host_ip')
    qmp_port = int(params.get('qmp_port'))
    serial_port = int(params.get('serial_port'))
    incoming_port = params.get('incoming_port')
    test = CreateTest(case_id='rhel7_10068', params=params)
    id = test.get_id()
    guest_pwd = params.get('guest_passwd')

    test.main_step_log('1.Start VM in src host')
    params.vm_base_cmd_add('S', 'None')
    params.vm_base_cmd_add('monitor', 'tcp:0:5555,server,nowait')

    src_host_session = HostSession(id, params)
    src_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_guest(cmd=src_qemu_cmd, vm_alias='src')

    test.sub_step_log('Check the status of src guest')
    src_remote_qmp = RemoteQMPMonitor(id, params, src_host_ip, qmp_port)

    test.main_step_log('2. Start listening mode in dst host ')
    params.vm_base_cmd_del('S', 'None')
    params.vm_base_cmd_del('monitor', 'tcp:0:5555,server,nowait')
    incoming_val = 'tcp:0:%s' % (incoming_port)
    params.vm_base_cmd_add('incoming', incoming_val)
    dst_qemu_cmd = params.create_qemu_cmd()
    src_host_session.boot_remote_guest(cmd=dst_qemu_cmd,
                                       ip=dst_host_ip,
                                       vm_alias='dst')
    dst_remote_qmp = RemoteQMPMonitor(id, params, dst_host_ip, qmp_port)
    dst_serial = RemoteSerialMonitor(case_id=id,
                                     params=params,
                                     ip=dst_host_ip,
                                     port=serial_port)

    test.main_step_log('3. Start live migration with '
                       'running below script on src host')
    cmd='echo c | nc localhost 5555; sleep 0.6; ' \
        'echo migrate tcp:%s:%s | nc localhost 5555' % \
        (dst_host_ip, incoming_port)
    src_host_session.host_cmd(cmd=cmd)

    test.main_step_log('4.Check guest on des, guest should work well')
    migration_flag = query_migration(src_remote_qmp)
    if (migration_flag == False):
        src_remote_qmp.test_error('migration timeout')
    output = dst_remote_qmp.qmp_cmd_output('{"execute":"query-status"}')
    if not re.findall(r'"status": "running"', output):
        dst_remote_qmp.test_error('migration status error')

    test.main_step_log('5.Reboot guest, guest should work well.')
    timeout = 600
    endtime = time.time() + timeout
    bootup = False
    while time.time() < endtime:
        cmd = 'root'
        dst_serial.send_cmd(cmd)
        output = dst_serial.rec_data(recv_timeout=8)
        dst_serial.test_print(info=output, serial_debug=True)
        if re.findall(r'Password', output):
            dst_serial.send_cmd(guest_pwd)
            dst_serial.test_print(guest_pwd, serial_debug=True)
            output = dst_serial.rec_data(recv_timeout=8)
            dst_serial.test_print(info=output, serial_debug=True)
            if re.search(r"login:"******"login:"******"execute":"quit"}',
                                           recv_timeout=3)
    if output:
        src_remote_qmp.test_error('Failed to quit qemu on src host')

    dst_serial.serial_shutdown_vm()