Merge "Use random policy names in test_qos and test_qos_negative"
diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py
index 6674cb8..cbe5df6 100644
--- a/neutron_tempest_plugin/scenario/base.py
+++ b/neutron_tempest_plugin/scenario/base.py
@@ -367,7 +367,8 @@
                                    should_succeed=True,
                                    nic=None, mtu=None, fragmentation=True,
                                    timeout=None, pattern=None,
-                                   forbid_packet_loss=False):
+                                   forbid_packet_loss=False,
+                                   check_response_ip=True):
         """check ping server via source ssh connection
 
         :param source: RemoteClient: an ssh connection from which to ping
@@ -380,6 +381,7 @@
         :param timeout: Timeout for all ping packet(s) to succeed
         :param pattern: hex digits included in ICMP messages
         :param forbid_packet_loss: forbid or allow some lost packets
+        :param check_response_ip: check response ip
         :returns: boolean -- should_succeed == ping
         :returns: ping is false if ping failed
         """
@@ -422,7 +424,8 @@
                 LOG.debug('Packet loss detected')
                 return not should_succeed
 
-            if validators.validate_ip_address(dest) is None:
+            if (check_response_ip and
+                    validators.validate_ip_address(dest) is None):
                 # Assert that the return traffic was from the correct
                 # source address.
                 from_source = 'from %s' % dest
@@ -436,13 +439,15 @@
                                   nic=None, mtu=None, fragmentation=True,
                                   servers=None, timeout=None,
                                   ping_count=CONF.validation.ping_count,
-                                  pattern=None, forbid_packet_loss=False):
+                                  pattern=None, forbid_packet_loss=False,
+                                  check_response_ip=True):
         try:
             self.assertTrue(self._check_remote_connectivity(
                 source, dest, ping_count, should_succeed, nic, mtu,
                 fragmentation,
                 timeout=timeout, pattern=pattern,
-                forbid_packet_loss=forbid_packet_loss))
+                forbid_packet_loss=forbid_packet_loss,
+                check_response_ip=check_response_ip))
         except (lib_exc.SSHTimeout, ssh_exc.AuthenticationException) as ssh_e:
             LOG.debug(ssh_e)
             self._log_console_output(servers)
diff --git a/neutron_tempest_plugin/scenario/test_floatingip.py b/neutron_tempest_plugin/scenario/test_floatingip.py
index a5afc73..a5f6486 100644
--- a/neutron_tempest_plugin/scenario/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/test_floatingip.py
@@ -18,6 +18,7 @@
 from neutron_lib import constants as lib_constants
 from neutron_lib.services.qos import constants as qos_consts
 from neutron_lib.utils import test
+from oslo_log import log
 from tempest.common import utils
 from tempest.common import waiters
 from tempest.lib.common.utils import data_utils
@@ -37,6 +38,7 @@
 
 
 CONF = config.CONF
+LOG = log.getLogger(__name__)
 
 
 load_tests = testscenarios.load_tests_apply_scenarios
@@ -244,11 +246,17 @@
             self._check_port_details(
                 fip, port, status=lib_constants.PORT_STATUS_ACTIVE,
                 device_id=server['server']['id'], device_owner='compute:nova')
+            LOG.debug('Port check for server %s and FIP %s finished, '
+                      'lets detach port %s from server!',
+                      server['server']['id'], fip['id'], port['id'])
 
             # detach the port from the server; this is a cast in the compute
             # API so we have to poll the port until the device_id is unset.
             self.delete_interface(server['server']['id'], port['id'])
             port = self._wait_for_port_detach(port['id'])
+            LOG.debug('Port %s has been detached from server %s, lets check '
+                      'the status of port in FIP %s details!',
+                      port['id'], server['server']['id'], fip['id'])
             fip = self._wait_for_fip_port_down(fip['id'])
             self._check_port_details(
                 fip, port, status=lib_constants.PORT_STATUS_DOWN,
@@ -323,6 +331,8 @@
                            (fip_id, status, timeout, port))
                 raise exceptions.TimeoutException(message)
 
+        LOG.debug('Port %s attached to FIP %s is down after %s!',
+                  fip.get("port_id"), fip_id, int(time.time()) - start)
         return fip
 
 
diff --git a/neutron_tempest_plugin/scenario/test_local_ip.py b/neutron_tempest_plugin/scenario/test_local_ip.py
new file mode 100644
index 0000000..0cc9de1
--- /dev/null
+++ b/neutron_tempest_plugin/scenario/test_local_ip.py
@@ -0,0 +1,103 @@
+#   Copyright 2021 Huawei, 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 oslo_log import log as logging
+from tempest.common import utils
+from tempest.common import waiters
+from tempest.lib.common.utils import data_utils
+from tempest.lib import decorators
+
+from neutron_tempest_plugin.common import ssh
+from neutron_tempest_plugin import config
+from neutron_tempest_plugin.scenario import base
+from neutron_tempest_plugin.scenario import constants as const
+
+LOG = logging.getLogger(__name__)
+CONF = config.CONF
+
+
+class LocalIPTest(base.BaseTempestTestCase):
+    credentials = ['primary', 'admin']
+
+    @classmethod
+    @utils.requires_ext(extension="local_ip", service="network")
+    def resource_setup(cls):
+        super(LocalIPTest, cls).resource_setup()
+        cls.network = cls.create_network()
+        cls.subnet = cls.create_subnet(cls.network)
+        cls.keypair = cls.create_keypair()
+
+        # Create security group with admin privileges
+        cls.secgroup = cls.create_security_group(
+            name=data_utils.rand_name('secgroup'))
+
+        # Execute funcs to achieve ssh and ICMP capabilities
+        cls.create_loginable_secgroup_rule(secgroup_id=cls.secgroup['id'])
+        cls.create_pingable_secgroup_rule(secgroup_id=cls.secgroup['id'])
+
+        # Create router
+        cls.router = cls.create_router(
+            router_name=data_utils.rand_name("router-test"),
+            admin_state_up=True,
+            external_network_id=CONF.network.public_network_id)
+        cls.create_router_interface(cls.router['id'], cls.subnet['id'])
+
+    def _create_server(self, name=None):
+        port = self.create_port(
+            self.network, security_groups=[self.secgroup['id']])
+        server = self.create_server(
+            flavor_ref=CONF.compute.flavor_ref,
+            image_ref=CONF.compute.image_ref,
+            key_name=self.keypair['name'], name=name,
+            networks=[{'port': port['id']}])['server']
+        waiters.wait_for_server_status(self.os_primary.servers_client,
+                                       server['id'],
+                                       const.SERVER_STATUS_ACTIVE)
+
+        return {'port': port, 'server': server}
+
+    @decorators.idempotent_id('3aa4b288-011a-4aa2-9024-19ad2ce40bfd')
+    def test_local_ip_connectivity(self):
+        server1 = self._create_server(name='local_ip_vm1')
+        server2 = self._create_server(name='local_ip_vm2')
+
+        fip = self.create_and_associate_floatingip(server1['port']['id'])
+        ssh_client = ssh.Client(
+            fip['floating_ip_address'],
+            CONF.validation.image_ssh_user,
+            pkey=self.keypair['private_key'])
+
+        servers = [server1['server'], server2['server']]
+
+        # first check basic connectivity
+        self.check_remote_connectivity(
+            ssh_client,
+            server2['port']['fixed_ips'][0]['ip_address'],
+            servers=servers)
+
+        local_ip = self.create_local_ip(network_id=self.network['id'])
+        self.create_local_ip_association(local_ip['id'],
+                                         fixed_port_id=server2['port']['id'])
+        # check connectivity with local ip address
+        self.check_remote_connectivity(
+            ssh_client, local_ip['local_ip_address'],
+            servers=servers, check_response_ip=False)
+
+        # check basic connectivity after local ip association
+        self.check_remote_connectivity(
+            ssh_client,
+            server2['port']['fixed_ips'][0]['ip_address'],
+            servers=servers,
+            check_response_ip=False)
diff --git a/zuul.d/master_jobs.yaml b/zuul.d/master_jobs.yaml
index d24eae8..468128a 100644
--- a/zuul.d/master_jobs.yaml
+++ b/zuul.d/master_jobs.yaml
@@ -150,18 +150,21 @@
         ovsdb-server: false
         q-ovn-metadata-agent: false
         # Neutron services
+        neutron-local-ip-static: true
         q-agt: true
         q-dhcp: true
         q-l3: true
         q-meta: true
         q-metering: true
       network_api_extensions: *api_extensions
+      network_api_extensions_openvswitch:
+        - local_ip
       network_available_features: *available_features
       devstack_localrc:
         Q_AGENT: openvswitch
         Q_ML2_TENANT_NETWORK_TYPE: vxlan
         Q_ML2_PLUGIN_MECHANISM_DRIVERS: openvswitch
-        NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
+        NETWORK_API_EXTENSIONS: "{{ (network_api_extensions + network_api_extensions_openvswitch) | join(',') }}"
       devstack_local_conf:
         post-config:
           $NEUTRON_CONF:
@@ -204,6 +207,16 @@
       - ^neutron/plugins/ml2/drivers/macvtap/.*$
       - ^neutron/plugins/ml2/drivers/mech_sriov/.*$
       - ^neutron/plugins/ml2/drivers/ovn/.*$
+      - ^neutron/services/ovn_l3/.*$
+      - ^neutron/services/logapi/drivers/ovn/.*$
+      - ^neutron/services/portforwarding/drivers/ovn/.*$
+      - ^neutron/services/qos/drivers/linuxbridge/.*$
+      - ^neutron/services/qos/drivers/ovn/.*$
+      - ^neutron/services/trunk/drivers/linuxbridge/.*$
+      - ^neutron/services/trunk/drivers/ovn/.*$
+      - ^neutron/cmd/ovn/.*$
+      - ^neutron/common/ovn/.*$
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|sfc|tap_as_a_service|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^rally-jobs/.*$
@@ -226,12 +239,15 @@
         ovsdb-server: false
         q-ovn-metadata-agent: false
         # Neutron services
+        neutron-local-ip: true
         q-agt: true
         q-dhcp: true
         q-l3: true
         q-meta: true
         q-metering: true
       network_api_extensions: *api_extensions
+      network_api_extensions_openvswitch:
+        - local_ip
       network_available_features: *available_features
       # TODO(slaweq): remove trunks subport_connectivity test from blacklist
       # when bug https://bugs.launchpad.net/neutron/+bug/1838760 will be fixed
@@ -244,7 +260,7 @@
         Q_AGENT: openvswitch
         Q_ML2_TENANT_NETWORK_TYPE: vxlan
         Q_ML2_PLUGIN_MECHANISM_DRIVERS: openvswitch
-        NETWORK_API_EXTENSIONS: "{{ network_api_extensions | join(',') }}"
+        NETWORK_API_EXTENSIONS: "{{ (network_api_extensions + network_api_extensions_openvswitch) | join(',') }}"
       devstack_local_conf:
         post-config:
           $NEUTRON_CONF:
@@ -290,6 +306,16 @@
       - ^neutron/plugins/ml2/drivers/macvtap/.*$
       - ^neutron/plugins/ml2/drivers/mech_sriov/.*$
       - ^neutron/plugins/ml2/drivers/ovn/.*$
+      - ^neutron/services/ovn_l3/.*$
+      - ^neutron/services/logapi/drivers/ovn/.*$
+      - ^neutron/services/portforwarding/drivers/ovn/.*$
+      - ^neutron/services/qos/drivers/linuxbridge/.*$
+      - ^neutron/services/qos/drivers/ovn/.*$
+      - ^neutron/services/trunk/drivers/linuxbridge/.*$
+      - ^neutron/services/trunk/drivers/ovn/.*$
+      - ^neutron/cmd/ovn/.*$
+      - ^neutron/common/ovn/.*$
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|sfc|tap_as_a_service|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^rally-jobs/.*$
@@ -411,6 +437,17 @@
       - ^neutron/plugins/ml2/drivers/macvtap/.*$
       - ^neutron/plugins/ml2/drivers/mech_sriov/.*$
       - ^neutron/plugins/ml2/drivers/ovn/.*$
+      - ^neutron/services/ovn_l3/.*$
+      - ^neutron/services/logapi/drivers/openvswitch/.*$
+      - ^neutron/services/logapi/drivers/ovn/.*$
+      - ^neutron/services/portforwarding/drivers/ovn/.*$
+      - ^neutron/services/qos/drivers/openvswitch/.*$
+      - ^neutron/services/qos/drivers/ovn/.*$
+      - ^neutron/services/trunk/drivers/openvswitch/.*$
+      - ^neutron/services/trunk/drivers/ovn/.*$
+      - ^neutron/cmd/ovn/.*$
+      - ^neutron/common/ovn/.*$
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|sfc|tap_as_a_service|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^rally-jobs/.*$
@@ -540,7 +577,12 @@
       - ^neutron/plugins/ml2/drivers/openvswitch/.*$
       - ^neutron/plugins/ml2/drivers/macvtap/.*$
       - ^neutron/plugins/ml2/drivers/mech_sriov/.*$
+      - ^neutron/services/qos/drivers/linuxbridge/.*$
+      - ^neutron/services/qos/drivers/openvswitch/.*$
+      - ^neutron/services/trunk/drivers/linuxbridge/.*$
+      - ^neutron/services/trunk/drivers/openvswitch/.*$
       - ^neutron/scheduler/.*$
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|sfc|tap_as_a_service|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^rally-jobs/.*$
@@ -783,6 +825,7 @@
       - ^neutron/plugins/ml2/drivers/.*$
       - ^neutron/scheduler/.*$
       - ^neutron/services/(?!externaldns).*$
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|sfc|tap_as_a_service|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^rally-jobs/.*$
@@ -844,6 +887,7 @@
       - ^neutron/tests/unit/.*$
       - ^neutron/tests/fullstack/.*
       - ^neutron/tests/functional/.*
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|tap_as_a_service|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^tools/.*$
@@ -903,6 +947,7 @@
       - ^neutron/tests/unit/.*$
       - ^neutron/tests/fullstack/.*
       - ^neutron/tests/functional/.*
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(fwaas|neutron_dynamic_routing|sfc|tap_as_a_service|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^tools/.*$
@@ -968,6 +1013,7 @@
       - ^neutron/tests/unit/.*$
       - ^neutron/tests/fullstack/.*
       - ^neutron/tests/functional/.*
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|sfc|tap_as_a_service|vpnaas).*$
       - ^tools/.*$
       - ^tox.ini$
@@ -1026,6 +1072,7 @@
       - ^neutron/tests/unit/.*$
       - ^neutron/tests/fullstack/.*
       - ^neutron/tests/functional/.*
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|sfc|tap_as_a_service).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^tools/.*$
@@ -1129,6 +1176,7 @@
       - ^neutron/tests/unit/.*$
       - ^neutron/tests/fullstack/.*
       - ^neutron/tests/functional/.*
+      - ^neutron_tempest_plugin/api/test_.*$
       - ^neutron_tempest_plugin/(bgpvpn|fwaas|neutron_dynamic_routing|sfc|vpnaas).*$
       - ^neutron_tempest_plugin/services/bgp/.*$
       - ^tools/.*$