Merge "Fill *_id information for client when using static accounts" into mcp/epoxy
diff --git a/neutron_tempest_plugin/api/test_network_ip_availability.py b/neutron_tempest_plugin/api/test_network_ip_availability.py
index cb2820b..bab0a41 100644
--- a/neutron_tempest_plugin/api/test_network_ip_availability.py
+++ b/neutron_tempest_plugin/api/test_network_ip_availability.py
@@ -22,9 +22,12 @@
 from tempest.lib import exceptions
 
 from neutron_tempest_plugin.api import base
+from neutron_tempest_plugin import config
 
 from neutron_lib import constants as lib_constants
 
+CONF = config.CONF
+
 # 3 IP addresses are taken from every total for IPv4 these are reserved
 DEFAULT_IP4_RESERVED = 3
 # 2 IP addresses are taken from every total for IPv6 these are reserved
@@ -68,6 +71,20 @@
         availability = self._get_availability(network, net_availability)
         return availability and availability['used_ips']
 
+    def _wait_used_ips_after_subnet_create(self, network, initial_used_ips=0):
+
+        def _wait_used_ips_value(network, used_ips):
+            availabilities = self.admin_client.list_network_ip_availabilities()
+            current_used_ips = self._get_used_ips(network, availabilities)
+            return current_used_ips == used_ips
+
+        used_ips = initial_used_ips + CONF.network.service_ports_number
+
+        self.assertTrue(
+            test_utils.call_until_true(
+                _wait_used_ips_value, 60, 5, network, used_ips),
+            msg=f"Current used ips != {used_ips} after subnet create")
+
     def _assert_total_and_used_ips(self, expected_used, expected_total,
                                    network, net_availability):
         availability = self._get_availability(network, net_availability)
@@ -101,6 +118,7 @@
     @decorators.idempotent_id('3aecd3b2-16ed-4b87-a54a-91d7b3c2986b')
     def test_list_ip_availability_after_subnet_and_ports(self):
         subnet = self.create_subnet(self.network, enable_dhcp=False)
+        self._wait_used_ips_after_subnet_create(self.network)
         prefix = netaddr.IPNetwork(subnet['cidr']).prefixlen
         body = self.admin_client.list_network_ip_availabilities()
         used_ips_before_port_create = self._get_used_ips(self.network, body)
@@ -114,6 +132,7 @@
     @decorators.idempotent_id('9f11254d-757b-492e-b14b-f52144e4ee7b')
     def test_list_ip_availability_after_port_delete(self):
         self.create_subnet(self.network, enable_dhcp=False)
+        self._wait_used_ips_after_subnet_create(self.network)
         port = self.create_port(self.network)
         net_availability = self.admin_client.list_network_ip_availabilities()
         used_ips = self._get_used_ips(self.network, net_availability)
@@ -136,6 +155,7 @@
             self.network['id'])
         self._assert_total_and_used_ips(0, 0, self.network, net_availability)
         subnet = self.create_subnet(self.network, enable_dhcp=False)
+        self._wait_used_ips_after_subnet_create(self.network)
         prefix = netaddr.IPNetwork(subnet['cidr']).prefixlen
         net_availability = self.admin_client.show_network_ip_availability(
             self.network['id'])
@@ -153,6 +173,7 @@
     @decorators.idempotent_id('a4d1e291-c152-4d62-9316-8c9bf1c6aee2')
     def test_show_ip_availability_after_port_delete(self):
         self.create_subnet(self.network, enable_dhcp=False)
+        self._wait_used_ips_after_subnet_create(self.network)
         port = self.create_port(self.network)
         net_availability = self.admin_client.show_network_ip_availability(
             self.network['id'])
@@ -180,6 +201,7 @@
     def test_list_ipv6_ip_availability_after_subnet_and_ports(self):
         subnet = self.create_subnet(self.network, ip_version=self._ip_version,
                                     enable_dhcp=False)
+        self._wait_used_ips_after_subnet_create(self.network)
         prefix = netaddr.IPNetwork(subnet['cidr']).prefixlen
         body = self.admin_client.list_network_ip_availabilities()
         used_ips_before_port_create = self._get_used_ips(self.network, body)
diff --git a/neutron_tempest_plugin/api/test_security_groups.py b/neutron_tempest_plugin/api/test_security_groups.py
index 37cd80b..85a51f3 100644
--- a/neutron_tempest_plugin/api/test_security_groups.py
+++ b/neutron_tempest_plugin/api/test_security_groups.py
@@ -256,6 +256,9 @@
     def _create_max_allowed_sg_amount(self):
         sg_amount = self._get_sg_amount()
         sg_quota = self._get_sg_quota()
+        if sg_quota == -1:
+            self._set_sg_quota(sg_amount + 1)
+            sg_quota = self._get_sg_quota()
         sg_to_create = sg_quota - sg_amount
         self._create_security_groups(sg_to_create)
 
diff --git a/neutron_tempest_plugin/api/test_timestamp.py b/neutron_tempest_plugin/api/test_timestamp.py
index 9ec982d..c3227a9 100644
--- a/neutron_tempest_plugin/api/test_timestamp.py
+++ b/neutron_tempest_plugin/api/test_timestamp.py
@@ -150,6 +150,7 @@
                          show_port['updated_at'])
 
     @decorators.idempotent_id('87a8b196-4b90-44f0-b7f3-d2057d7d658e')
+    @utils.requires_ext(extension='default-subnetpools', service='network')
     def test_create_subnetpool_with_timestamp(self):
         sp = self._create_subnetpool()
         # Verifies body contains timestamp fields
@@ -157,6 +158,7 @@
         self.assertIsNotNone(sp['updated_at'])
 
     @decorators.idempotent_id('d48c7578-c3d2-4f9b-a7a1-be2008c770a0')
+    @utils.requires_ext(extension='default-subnetpools', service='network')
     def test_update_subnetpool_with_timestamp(self):
         sp = self._create_subnetpool()
         origin_updated_at = sp['updated_at']
@@ -171,6 +173,7 @@
         self.assertIsNot(origin_updated_at, new_updated_at)
 
     @decorators.idempotent_id('1d3970e6-bcf7-46cd-b7d7-0807759c73b4')
+    @utils.requires_ext(extension='default-subnetpools', service='network')
     def test_show_subnetpool_attribute_with_timestamp(self):
         sp = self._create_subnetpool()
         body = self.client.show_subnetpool(sp['id'])
diff --git a/neutron_tempest_plugin/scenario/admin/test_floatingip.py b/neutron_tempest_plugin/scenario/admin/test_floatingip.py
index d9abaf5..1774289 100644
--- a/neutron_tempest_plugin/scenario/admin/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/admin/test_floatingip.py
@@ -70,7 +70,7 @@
         servers, fips, server_ssh_clients = ([], [], [])
         # Create the availability zone with default zone and
         # a specific mentioned hypervisor.
-        az = avail_zone + ':' + hyper
+        az = avail_zone + '::' + hyper
         for i in range(num_servers):
             servers.append(self.create_server(
                 flavor_ref=CONF.compute.flavor_ref,
diff --git a/neutron_tempest_plugin/scenario/test_floatingip.py b/neutron_tempest_plugin/scenario/test_floatingip.py
index f3d03e6..4225b66 100644
--- a/neutron_tempest_plugin/scenario/test_floatingip.py
+++ b/neutron_tempest_plugin/scenario/test_floatingip.py
@@ -535,7 +535,9 @@
         def _wait_for_fip_associated():
             try:
                 self.check_servers_hostnames(servers[-1:], log_errors=False)
-            except (AssertionError, exceptions.SSHTimeout):
+            # NOTE(vsaienko): it might take some time by neutron to update VIP
+            # retry on any exception here.
+            except Exception:
                 return False
             return True