Merge "Make neutron-tempest-plugin-scenario-linuxbridge job gating"
diff --git a/neutron_tempest_plugin/api/base.py b/neutron_tempest_plugin/api/base.py
index fdd8ba9..6246eb7 100644
--- a/neutron_tempest_plugin/api/base.py
+++ b/neutron_tempest_plugin/api/base.py
@@ -284,8 +284,9 @@
         return network
 
     @classmethod
-    def create_subnet(cls, network, gateway=None, cidr=None, mask_bits=None,
-                      ip_version=None, client=None, **kwargs):
+    def create_subnet(cls, network, gateway='', cidr=None, mask_bits=None,
+                      ip_version=None, client=None, reserve_cidr=True,
+                      **kwargs):
         """Wrapper utility that returns a test subnet.
 
         Convenient wrapper for client.create_subnet method. It reserves and
@@ -298,6 +299,7 @@
         It can be a str or a netaddr.IPAddress
         If gateway is not given, then it will use default address for
         given subnet CIDR, like "192.168.0.1" for "192.168.0.0/24" CIDR
+        if gateway is given as None then no gateway will be assigned
 
         :param cidr: CIDR of the subnet to create
         It can be either None, a str or a netaddr.IPNetwork instance
@@ -318,6 +320,10 @@
 
         :param client: client to be used to connect to network service
 
+        :param reserve_cidr: if True then it reserves assigned CIDR to avoid
+        using the same CIDR for further subnets in the scope of the same
+        test case class
+
         :param **kwargs: optional parameters to be forwarded to wrapped method
 
         [1] http://netaddr.readthedocs.io/en/latest/tutorial_01.html#supernets-and-subnets  # noqa
@@ -335,22 +341,23 @@
                         "Gateway IP version doesn't match IP version")
             else:
                 ip_version = gateway_ip.version
+        else:
+            ip_version = ip_version or cls._ip_version
 
         for subnet_cidr in cls.get_subnet_cidrs(
                 ip_version=ip_version, cidr=cidr, mask_bits=mask_bits):
-            if cls.try_reserve_subnet_cidr(subnet_cidr):
-                gateway_ip = gateway or str(subnet_cidr.ip + 1)
-                try:
-                    body = client.create_subnet(
-                        network_id=network['id'],
-                        cidr=str(subnet_cidr),
-                        ip_version=subnet_cidr.version,
-                        gateway_ip=str(gateway_ip),
-                        **kwargs)
-                    break
-                except lib_exc.BadRequest as e:
-                    if 'overlaps with another subnet' not in str(e):
-                        raise
+            if gateway is not None:
+                kwargs['gateway_ip'] = str(gateway or (subnet_cidr.ip + 1))
+            try:
+                body = client.create_subnet(
+                    network_id=network['id'],
+                    cidr=str(subnet_cidr),
+                    ip_version=subnet_cidr.version,
+                    **kwargs)
+                break
+            except lib_exc.BadRequest as e:
+                if 'overlaps with another subnet' not in str(e):
+                    raise
         else:
             message = 'Available CIDR for subnet creation could not be found'
             raise ValueError(message)
@@ -359,6 +366,8 @@
             cls.subnets.append(subnet)
         else:
             cls.admin_subnets.append(subnet)
+        if reserve_cidr:
+            cls.reserve_subnet_cidr(subnet_cidr)
         return subnet
 
     @classmethod
diff --git a/neutron_tempest_plugin/scenario/test_floatingip.py b/neutron_tempest_plugin/scenario/test_floatingip.py
index 8062a46..bc40176 100644
--- a/neutron_tempest_plugin/scenario/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/test_floatingip.py
@@ -212,15 +212,6 @@
     def resource_setup(cls):
         super(FloatingIPQosTest, cls).resource_setup()
 
-    @classmethod
-    def skip_checks(cls):
-        super(FloatingIPQosTest, cls).skip_checks()
-        if utils.is_extension_enabled("dvr", "network"):
-            raise cls.skipException(
-                "Skip until bug "
-                "https://bugs.launchpad.net/neutron/+bug/1758316 "
-                "will be fixed.")
-
     @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_trunk.py b/neutron_tempest_plugin/scenario/test_trunk.py
index 6fdcd5b..2ff7e5d 100644
--- a/neutron_tempest_plugin/scenario/test_trunk.py
+++ b/neutron_tempest_plugin/scenario/test_trunk.py
@@ -34,7 +34,8 @@
     'sudo su -c '
     '"ip l a link $IFACE name $IFACE.%(tag)d type vlan id %(tag)d &&'
     'ip l s up dev $IFACE.%(tag)d && '
-    'dhclient $IFACE.%(tag)d"')
+    '{ ps -ef | grep -q "dhclient .*$IFACE.%(tag)d" || '
+    'dhclient $IFACE.%(tag)d"; }')
 
 
 class TrunkTest(base.BaseTempestTestCase):
@@ -230,7 +231,7 @@
         vlan_tag = 10
 
         vlan_network = self.create_network()
-        self.create_subnet(vlan_network)
+        self.create_subnet(vlan_network, gateway=None)
 
         servers = [
             self._create_server_with_port_and_subport(vlan_network, vlan_tag)