Consolidate _check_tenant_network_connectivity in NetworkScenarioTest

Moves _check_tenant_network_connectivity into the parent class for the
basic/advanced network scenario tests and keeps the better diagnostic
debug logging of the two in the common version.

Closes-Bug: #1323674

Change-Id: I4d3f7368e25405fc8baaf23ed1c95a65aef724b7
This commit is contained in:
Matt Riedemann 2014-05-27 10:52:35 -07:00
parent 343305ff9d
commit 2d005bea62
3 changed files with 33 additions and 45 deletions

View File

@ -803,6 +803,30 @@ class NetworkScenarioTest(OfficialClientTest):
debug.log_net_debug()
raise
def _check_tenant_network_connectivity(self, server,
username,
private_key,
should_connect=True,
servers_for_debug=None):
if not CONF.network.tenant_networks_reachable:
msg = 'Tenant networks not configured to be reachable.'
LOG.info(msg)
return
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
try:
for net_name, ip_addresses in server.networks.iteritems():
for ip_address in ip_addresses:
self._check_vm_connectivity(ip_address,
username,
private_key,
should_connect=should_connect)
except Exception:
LOG.exception('Tenant network connectivity check failed')
self._log_console_output(servers_for_debug)
debug.log_net_debug()
raise
def _check_remote_connectivity(self, source, dest, should_succeed=True):
"""
check ping server via source ssh connection

View File

@ -15,7 +15,6 @@
import testtools
from tempest.common import debug
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
@ -85,36 +84,12 @@ class TestNetworkAdvancedServerOps(manager.NetworkScenarioTest):
public_network_id)
self.addCleanup(self.cleanup_wrapper, self.floating_ip)
def _check_tenant_network_connectivity(self, server,
username,
private_key,
should_connect=True):
if not CONF.network.tenant_networks_reachable:
msg = 'Tenant networks not configured to be reachable.'
LOG.info(msg)
return
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
try:
for net_name, ip_addresses in server.networks.iteritems():
for ip_address in ip_addresses:
self._check_vm_connectivity(ip_address,
username,
private_key,
should_connect=should_connect)
except Exception:
LOG.exception('Tenant network connectivity check failed')
self._log_console_output(servers=[server])
debug.log_ip_ns()
raise
def _check_network_connectivity(self, should_connect=True):
username = CONF.compute.image_ssh_user
private_key = self.keypair.private_key
self._check_tenant_network_connectivity(self.server,
username,
private_key,
should_connect=should_connect)
self._check_tenant_network_connectivity(
self.server, username, private_key, should_connect=should_connect,
servers_for_debug=[self.server])
floating_ip = self.floating_ip.floating_ip_address
self._check_public_network_connectivity(floating_ip, username,
private_key, should_connect,

View File

@ -156,24 +156,13 @@ class TestNetworkBasicOps(manager.NetworkScenarioTest):
return dict(server=server, keypair=keypair)
def _check_tenant_network_connectivity(self):
if not CONF.network.tenant_networks_reachable:
msg = 'Tenant networks not configured to be reachable.'
LOG.info(msg)
return
# The target login is assumed to have been configured for
# key-based authentication by cloud-init.
ssh_login = CONF.compute.image_ssh_user
try:
for server, key in self.servers.iteritems():
for net_name, ip_addresses in server.networks.iteritems():
for ip_address in ip_addresses:
self._check_vm_connectivity(ip_address, ssh_login,
key.private_key)
except Exception:
LOG.exception('Tenant connectivity check failed')
self._log_console_output(servers=self.servers.keys())
debug.log_net_debug()
raise
# call the common method in the parent class
super(TestNetworkBasicOps, self).\
_check_tenant_network_connectivity(
server, ssh_login, key.private_key,
servers_for_debug=self.servers.keys())
def _create_and_associate_floating_ips(self):
public_network_id = CONF.network.public_network_id