Make test_detail_quota() test more generic
Backends such as OVN will create a port to be used by the metadata agent
upon creating a network. That port will be substract from the tenant's
quota and that was what was previsouly causing this test to fail in OVN.
This patch is changing the approach to make it more generic by calculating
the number of used ports based on the number existent after the network
is created and prior to the new port being created.
A similar approach was used in the patch
https://review.openstack.org/#/c/559758/ for the same reason.
Change-Id: I952d31c4473159a3fdd0552eeae98750ee27a1f9
diff --git a/neutron_tempest_plugin/api/admin/test_quotas.py b/neutron_tempest_plugin/api/admin/test_quotas.py
index 1acfc18..ae773c8 100644
--- a/neutron_tempest_plugin/api/admin/test_quotas.py
+++ b/neutron_tempest_plugin/api/admin/test_quotas.py
@@ -121,17 +121,26 @@
new_quotas = {'network': {'used': 1, 'limit': 2, 'reserved': 0},
'port': {'used': 1, 'limit': 2, 'reserved': 0}}
- # update quota limit for tenant
- new_quota = {'network': new_quotas['network']['limit'], 'port':
- new_quotas['port']['limit']}
- quota_set = self._setup_quotas(tenant_id, **new_quota)
-
# create test resources
network = self._create_network(tenant_id)
post_body = {"network_id": network['id'],
"tenant_id": tenant_id}
+
+ # NOTE(lucasagomes): Some backends such as OVN will create a port
+ # to be used by the metadata agent upon creating a network. In
+ # order to make this test more generic we need to calculate the
+ # number of expected used ports after the network is created and
+ # prior for the port being created
+ ports = self.admin_client.list_ports(tenant_id=tenant_id)
+ new_quotas['port']['used'] += len(ports['ports'])
+
self._create_port(**post_body)
+ # update quota limit for tenant
+ new_quota = {'network': new_quotas['network']['limit'], 'port':
+ new_quotas['port']['limit']}
+ quota_set = self._setup_quotas(tenant_id, **new_quota)
+
# confirm from extended API quotas were changed
# as requested for tenant
quota_set = self.admin_client.show_details_quota(tenant_id)