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()
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.")
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()
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()
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()
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()
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()
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()
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()
def test_auth_tenant(): LOG.tc_func_start() cli.openstack('server list', auth_info=auth.Tenant.get('tenant1')) LOG.tc_func_end()