示例#1
0
def test_nova():
    LOG.tc_func_start()
    ProjVar.set_var(SOURCE_OPENRC=True)
    cli.openstack('server list')
    cli.openstack('server list', auth_info=None)
    ProjVar.set_var(SOURCE_OPENRC=None)
    LOG.tc_func_end()
示例#2
0
def test_connection_close():
    LOG.tc_func_start()
    setup()
    ssh_client.close()
    try:
        ssh_client.send('echo "hello \nworld2"')
        fail("Connection closed already, shouldn't be able to send cmd!")
    except:
        LOG.tc_func_end("hello world throwed exception.")
示例#3
0
def test_credential_incorrect():
    LOG.tc_func_start()
    ssh_client1 = SSHClient(host=hostname,
                            user='******',
                            password='******')
    try:
        ssh_client1.connect(retry=True)
        fail("Test failed, how can connect pass??")
    except pxssh.ExceptionPxssh as e:
        assert "permission denied" in e.__str__()
        LOG.tc_func_end()
示例#4
0
def test_reconnect_after_swact():
    LOG.tc_func_start()
    setup()
    # TODO: dynamically determine active controller
    ssh_client.exec_cmd("system host-swact controller-0")
    time.sleep(10)  # wait for ssh_client disconnect due to swact
    ssh_client.connect(timeout=3, retry=True, prompt=ssh.CONTROLLER_PROMPT)
    ssh_client.send("date")
    ssh_client.expect()
    assert ssh_client.is_connected()
    LOG.tc_func_end()
示例#5
0
def test_expect_list():
    LOG.tc_func_start()
    ssh_client.connect()
    ssh_client.send(r'source /etc/platform/openrc')
    ssh_client.expect('.*keystone_admin.*')
    ssh_client.set_prompt('.*keystone_admin.*')
    ssh_client.send(r'system host-list', flush=True)
    ssh_client.expect([r'compute\-0', r'controller\-1'])
    ssh_client.expect([r'compute\-0', r'compute\-1'])
    ssh_client.flush()
    LOG.tc_func_end()
示例#6
0
def test_ssh_from_ssh():
    LOG.tc_func_start()
    ssh_client.connect()
    compute_ssh = SSHFromSSH(ssh_client, 'compute-0', username, password)
    compute_ssh.connect()
    exit_code, output = compute_ssh.exec_cmd('date1')
    assert exit_code == 127
    assert 'command not found' in output
    compute_ssh.close()
    assert not compute_ssh.is_connected()
    assert ssh_client.is_connected()
    LOG.tc_func_end()
示例#7
0
def test_system():
    LOG.tc_func_start()
    cli.system('host-list')
    cli.system('host-show', 1)
    try:
        cli.system('host-list', auth_info=auth.Tenant.get('tenant1'))
        raise Exception("you should fail!")
    except CLIRejected:
        LOG.info("nova test passed without authentication")
    ProjVar.set_var(SOURCE_OPENRC=True)
    cli.system('host-list', auth_info=None)
    ProjVar.set_var(SOURCE_OPENRC=None)
    LOG.tc_func_end()
示例#8
0
def test_send_cmd():
    LOG.tc_func_start()
    ssh_client.connect()
    ssh_client.send('/sbin/ip route')
    ssh_client.expect('default')
    ssh_client.expect('eth1')
    ssh_client.flush()
    output = ssh_client.exec_cmd('date')
    assert 'eth' not in output
    ssh_client.send(r'source /etc/platform/openrc')
    ssh_client.set_prompt('.*keystone_admin.*')
    ssh_client.expect()
    exit_code, output = ssh_client.exec_cmd('system host-list')
    assert exit_code == 0
    LOG.tc_func_end()
示例#9
0
def testcase_log(msg, nodeid, separator=None, log_type=None):
    if separator is None:
        separator = '-----------'

    print_msg = separator + '\n' + msg
    logging_msg = '\n{}{} {}'.format(separator, msg, nodeid)
    if console_log:
        print(print_msg)
    if log_type == 'tc_res':
        global tc_end_time
        tc_end_time = strftime("%Y%m%d %H:%M:%S", gmtime())
        LOG.tc_result(msg=msg, tc_name=nodeid)
    elif log_type == 'tc_start':
        LOG.tc_func_start(nodeid)
    elif log_type == 'tc_setup':
        LOG.tc_setup_start(nodeid)
    elif log_type == 'tc_teardown':
        LOG.tc_teardown_start(nodeid)
    else:
        LOG.debug(logging_msg)
示例#10
0
def test_get_info():
    pv0_storage_nodes = system_helper.get_storage_nodes(pv0)
    assert 'storage-0' in pv0_storage_nodes and 'storage-1' in pv0_storage_nodes
    assert not system_helper.get_storage_nodes(r720)
    assert not system_helper.is_aio_system()
    LOG.tc_func_start()
    assert system_helper.is_aio_system(r720)
    LOG.tc_func_end()
    LOG.tc_func_start()
    assert not system_helper.is_aio_system(r730_3_7)
    LOG.tc_func_end()
    LOG.tc_func_start()
    assert not system_helper.get_storage_nodes(r730_3_7)
    LOG.tc_func_end()
示例#11
0
def test_auth_tenant():
    LOG.tc_func_start()
    cli.openstack('server list', auth_info=auth.Tenant.get('tenant1'))
    LOG.tc_func_end()