Add skip funtion for checking enabled extensions in the l3 agent

This function check the extension configured in the l3 network agent
and if the extension is no enabled the test is skipped

That validation should not be applied when the l3 agent does not exist,
e.g.: OVN configurations

Change-Id: Icbc379d6b8ab0d720d2ae242d79949fb4dd9d27c
diff --git a/neutron_tempest_plugin/scenario/base.py b/neutron_tempest_plugin/scenario/base.py
index 127701c..6910c11 100644
--- a/neutron_tempest_plugin/scenario/base.py
+++ b/neutron_tempest_plugin/scenario/base.py
@@ -207,6 +207,21 @@
         LOG.debug("Created router %s", router['name'])
         return router
 
+    @classmethod
+    def skip_if_no_extension_enabled_in_l3_agents(cls, extension):
+        l3_agents = cls.os_admin.network_client.list_agents(
+                binary='neutron-l3-agent')['agents']
+        if not l3_agents:
+            # the tests should not be skipped when neutron-l3-agent does not
+            # exist (this validation doesn't apply to the setups like
+            # e.g. ML2/OVN)
+            return
+        for agent in l3_agents:
+            if extension in agent['configurations'].get('extensions', []):
+                return
+        raise cls.skipTest("No L3 agent with '%s' extension enabled found." %
+                           extension)
+
     @removals.remove(version='Stein',
                      message="Please use create_floatingip method instead of "
                              "create_and_associate_floatingip.")
diff --git a/neutron_tempest_plugin/scenario/test_floatingip.py b/neutron_tempest_plugin/scenario/test_floatingip.py
index 262f429..bf890ad 100644
--- a/neutron_tempest_plugin/scenario/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/test_floatingip.py
@@ -341,15 +341,6 @@
     def resource_setup(cls):
         super(FloatingIPQosTest, cls).resource_setup()
 
-    def skip_if_no_extension_enabled_in_l3_agents(self, extension):
-        l3_agents = self.os_admin.network_client.list_agents(
-                binary='neutron-l3-agent')['agents']
-        for agent in l3_agents:
-            if extension in agent['configurations'].get('extensions', []):
-                return
-        raise self.skipTest("No L3 agent with '%s' extension enabled found." %
-                            extension)
-
     @decorators.idempotent_id('5eb48aea-eaba-4c20-8a6f-7740070a0aa3')
     def test_qos(self):
         """Test floating IP is binding to a QoS policy with
diff --git a/neutron_tempest_plugin/scenario/test_port_forwardings.py b/neutron_tempest_plugin/scenario/test_port_forwardings.py
index 6a5d3c9..a3adc03 100644
--- a/neutron_tempest_plugin/scenario/test_port_forwardings.py
+++ b/neutron_tempest_plugin/scenario/test_port_forwardings.py
@@ -31,11 +31,13 @@
 
 class PortForwardingTestJSON(base.BaseTempestTestCase):
 
+    credentials = ['primary', 'admin']
     required_extensions = ['router', 'floating-ip-port-forwarding']
 
     @classmethod
     def resource_setup(cls):
         super(PortForwardingTestJSON, cls).resource_setup()
+        cls.skip_if_no_extension_enabled_in_l3_agents("port_forwarding")
         cls.network = cls.create_network()
         cls.subnet = cls.create_subnet(cls.network)
         cls.router = cls.create_router_by_client()