SNAT - Check connectivity to the gateway IP
Check connectivity to the gateway IP from an instance
without Floating IP
Change-Id: I9893b7514ded3f6e213b2095a39da045a901baed
diff --git a/neutron_tempest_plugin/scenario/test_floatingip.py b/neutron_tempest_plugin/scenario/test_floatingip.py
index 0febce2..b253890 100644
--- a/neutron_tempest_plugin/scenario/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/test_floatingip.py
@@ -21,6 +21,7 @@
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
@@ -59,6 +60,17 @@
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()
subnet = cls.create_subnet(network,
@@ -157,3 +169,30 @@
@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)