Force connection auth as part of RemoteClient in scenario
Some operations use ssh.exec_command() (or maybe other methods) without first verifying that ssh connection is available. This might cause ambiguity when debugging failed tests. This patch forces connection verification as part of ssh_client creation in scenario tests, and will cause early failure if connection is faulty Change-Id: I002fee2a231e48e834f80f62cc70a489eaa8d2c1
This commit is contained in:
parent
787852ffca
commit
3960c4dcb4
@ -406,7 +406,16 @@ class OfficialClientTest(tempest.test.BaseTestCase):
|
||||
username = CONF.scenario.ssh_user
|
||||
if private_key is None:
|
||||
private_key = self.keypair.private_key
|
||||
return remote_client.RemoteClient(ip, username, pkey=private_key)
|
||||
linux_client = remote_client.RemoteClient(ip, username,
|
||||
pkey=private_key)
|
||||
try:
|
||||
linux_client.validate_authentication()
|
||||
except exceptions.SSHTimeout:
|
||||
LOG.exception('ssh connection to %s failed' % ip)
|
||||
debug.log_net_debug()
|
||||
raise
|
||||
|
||||
return linux_client
|
||||
|
||||
def _log_console_output(self, servers=None):
|
||||
if not servers:
|
||||
@ -868,9 +877,7 @@ class NetworkScenarioTest(OfficialClientTest):
|
||||
msg=msg)
|
||||
if should_connect:
|
||||
# no need to check ssh for negative connectivity
|
||||
linux_client = self.get_remote_client(ip_address, username,
|
||||
private_key)
|
||||
linux_client.validate_authentication()
|
||||
self.get_remote_client(ip_address, username, private_key)
|
||||
|
||||
def _check_public_network_connectivity(self, ip_address, username,
|
||||
private_key, should_connect=True,
|
||||
@ -884,12 +891,14 @@ class NetworkScenarioTest(OfficialClientTest):
|
||||
username,
|
||||
private_key,
|
||||
should_connect=should_connect)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
ex_msg = 'Public network connectivity check failed'
|
||||
if msg:
|
||||
ex_msg += ": " + msg
|
||||
LOG.exception(ex_msg)
|
||||
self._log_console_output(servers)
|
||||
# network debug is called as part of ssh init
|
||||
if not isinstance(e, exceptions.SSHTimeout):
|
||||
debug.log_net_debug()
|
||||
raise
|
||||
|
||||
@ -911,9 +920,11 @@ class NetworkScenarioTest(OfficialClientTest):
|
||||
username,
|
||||
private_key,
|
||||
should_connect=should_connect)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
LOG.exception('Tenant network connectivity check failed')
|
||||
self._log_console_output(servers_for_debug)
|
||||
# network debug is called as part of ssh init
|
||||
if not isinstance(e, exceptions.SSHTimeout):
|
||||
debug.log_net_debug()
|
||||
raise
|
||||
|
||||
|
@ -148,7 +148,6 @@ class TestLoadBalancerBasic(manager.NetworkScenarioTest):
|
||||
ssh_client = self.get_remote_client(
|
||||
server_or_ip=ip,
|
||||
private_key=private_key)
|
||||
ssh_client.validate_authentication()
|
||||
|
||||
# Write a backend's responce into a file
|
||||
resp = """HTTP/1.0 200 OK\r\nContent-Length: 8\r\n\r\n%s"""
|
||||
|
@ -93,10 +93,11 @@ class TestMinimumBasicScenario(manager.OfficialClientTest):
|
||||
def ssh_to_server(self):
|
||||
try:
|
||||
self.linux_client = self.get_remote_client(self.floating_ip.ip)
|
||||
self.linux_client.validate_authentication()
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
LOG.exception('ssh to server failed')
|
||||
self._log_console_output()
|
||||
# network debug is called as part of ssh init
|
||||
if not isinstance(e, test.exceptions.SSHTimeout):
|
||||
debug.log_net_debug()
|
||||
raise
|
||||
|
||||
|
@ -336,6 +336,8 @@ class TestSecurityGroupsBasicOps(manager.NetworkScenarioTest):
|
||||
self.assertTrue(self._check_remote_connectivity(access_point, ip,
|
||||
should_succeed),
|
||||
msg)
|
||||
except test.exceptions.SSHTimeout:
|
||||
raise
|
||||
except Exception:
|
||||
debug.log_net_debug()
|
||||
raise
|
||||
|
@ -93,11 +93,10 @@ class TestServerBasicOps(manager.OfficialClientTest):
|
||||
instance.add_floating_ip(floating_ip)
|
||||
# Check ssh
|
||||
try:
|
||||
linux_client = self.get_remote_client(
|
||||
self.get_remote_client(
|
||||
server_or_ip=floating_ip.ip,
|
||||
username=self.image_utils.ssh_user(self.image_ref),
|
||||
private_key=self.keypair.private_key)
|
||||
linux_client.validate_authentication()
|
||||
except Exception:
|
||||
LOG.exception('ssh to server failed')
|
||||
self._log_console_output()
|
||||
|
Loading…
Reference in New Issue
Block a user