Merge "SNAT - Check connectivity to the gateway IP"
This commit is contained in:
commit
cbbb1c5740
@ -21,6 +21,7 @@ from tempest.lib import decorators
|
||||
import testscenarios
|
||||
from testscenarios.scenarios import multiply_scenarios
|
||||
|
||||
from neutron_lib import constants as lib_constants
|
||||
from neutron_tempest_plugin.common import ssh
|
||||
from neutron_tempest_plugin.common import utils as common_utils
|
||||
from neutron_tempest_plugin import config
|
||||
@ -58,6 +59,17 @@ class FloatingIpTestCasesMixin(object):
|
||||
else:
|
||||
cls._dest_network = cls._create_dest_network()
|
||||
|
||||
@classmethod
|
||||
def _get_external_gateway(cls):
|
||||
if CONF.network.public_network_id:
|
||||
subnets = cls.os_admin.network_client.list_subnets(
|
||||
network_id=CONF.network.public_network_id)
|
||||
|
||||
for subnet in subnets['subnets']:
|
||||
if (subnet['gateway_ip']
|
||||
and subnet['ip_version'] == lib_constants.IP_VERSION_4):
|
||||
return subnet['gateway_ip']
|
||||
|
||||
@classmethod
|
||||
def _create_dest_network(cls):
|
||||
network = cls.create_network()
|
||||
@ -157,3 +169,30 @@ class FloatingIpSeparateNetwork(FloatingIpTestCasesMixin,
|
||||
@decorators.idempotent_id('f18f0090-3289-4783-b956-a0f8ac511e8b')
|
||||
def test_east_west(self):
|
||||
self._test_east_west()
|
||||
|
||||
|
||||
class DefaultSnatToExternal(FloatingIpTestCasesMixin,
|
||||
base.BaseTempestTestCase):
|
||||
same_network = True
|
||||
|
||||
@decorators.idempotent_id('3d73ea1a-27c6-45a9-b0f8-04a283d9d764')
|
||||
def test_snat_external_ip(self):
|
||||
"""Check connectivity to an external IP"""
|
||||
gateway_external_ip = self._get_external_gateway()
|
||||
|
||||
if not gateway_external_ip:
|
||||
raise self.skipTest("IPv4 gateway is not configured for public "
|
||||
"network or public_network_id is not "
|
||||
"configured")
|
||||
proxy = self._create_server()
|
||||
proxy_client = ssh.Client(proxy['fip']['floating_ip_address'],
|
||||
CONF.validation.image_ssh_user,
|
||||
pkey=self.keypair['private_key'])
|
||||
src_server = self._create_server(create_floating_ip=False)
|
||||
src_server_ip = src_server['port']['fixed_ips'][0]['ip_address']
|
||||
ssh_client = ssh.Client(src_server_ip,
|
||||
CONF.validation.image_ssh_user,
|
||||
pkey=self.keypair['private_key'],
|
||||
proxy_client=proxy_client)
|
||||
self.check_remote_connectivity(ssh_client,
|
||||
gateway_external_ip)
|
||||
|
Loading…
Reference in New Issue
Block a user