From e401b6162b72517bc38d9b13b932fd3995cf84e7 Mon Sep 17 00:00:00 2001 From: Renjing Xiao Date: Thu, 6 Feb 2025 18:28:35 +0000 Subject: [PATCH] Add nested snat test This test checks connectivity when ovn_router_indirect_snat is enabled. This functionality was added for ML2/OVN in https://review.opendev.org/c/openstack/neutron/+/926495 Depends-On: https://review.opendev.org/c/openstack/neutron-tempest-plugin/+/940906 Resolves-Bug: OSPRH-13329 Change-Id: I2b31d1c123286bcbd69f932bda069aa3af9beb18 --- .../tests/scenario/test_nested_routers.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 whitebox_neutron_tempest_plugin/tests/scenario/test_nested_routers.py diff --git a/whitebox_neutron_tempest_plugin/tests/scenario/test_nested_routers.py b/whitebox_neutron_tempest_plugin/tests/scenario/test_nested_routers.py new file mode 100644 index 0000000..7eaa75d --- /dev/null +++ b/whitebox_neutron_tempest_plugin/tests/scenario/test_nested_routers.py @@ -0,0 +1,47 @@ +# Copyright 2025 Red Hat, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from neutron_tempest_plugin.scenario import test_floatingip +from tempest import config +from tempest.lib import decorators +from whitebox_neutron_tempest_plugin.tests.scenario import base + +CONF = config.CONF +WB_CONF = config.CONF.whitebox_neutron_plugin_options + + +class DefaultSnatToExternalTest( + base.BaseTempestWhiteboxTestCase, test_floatingip.DefaultSnatToExternal +): + @classmethod + def resource_setup(cls): + super(DefaultSnatToExternalTest, cls).resource_setup() + if cls.check_service_setting( + {"client": cls.master_node_client}, + config_files=( + cls.neutron_conf, + "/etc/neutron/neutron.conf.d/02-neutron-custom.conf", + ), + section="ovn", + param="ovn_router_indirect_snat", + msg="Backend doesn't enable nested SNAT.", + ): + cls.feature_enabled_bool = True + else: + cls.feature_enabled_bool = False + + @decorators.idempotent_id('97473428-e17c-4fe2-a389-b931dbfab6b2') + def test_nested_snat_external_ip(self): + self._test_nested_snat_external_ip(self.feature_enabled_bool)