summaryrefslogtreecommitdiff
path: root/neutron/tests/unit/objects/test_base.py
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <ralonsoh@redhat.com>2023-05-10 06:32:32 +0200
committerRodolfo Alonso <ralonsoh@redhat.com>2023-05-11 13:32:24 +0000
commit3b7699bc6614d0c03d55087e63c4ccd19878caa4 (patch)
tree8686953b07976e8f303c6f3039f96669e10748d6 /neutron/tests/unit/objects/test_base.py
parent9319ba00a986e693eeb4707055aa53111601e7c8 (diff)
downloadneutron-3b7699bc6614d0c03d55087e63c4ccd19878caa4.tar.gz
Add scope ID to the "GROUP BY" clause in ``get_scoped_floating_ips``
PostgreSQL requires to add the table keys selected in the SELECT clause in the later GROUP BY clause. This patch is adding "SubnetPool.address_scope_id" to this GROUP BY clause. Because the subnet pool (for IPv4) is unique for the FIP subnet, the returned elements in this query will be the same. Closes-Bug: #2019186 Change-Id: Ia446e17a44b1a260971ae237841451edb97ce39f
Diffstat (limited to 'neutron/tests/unit/objects/test_base.py')
-rw-r--r--neutron/tests/unit/objects/test_base.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/neutron/tests/unit/objects/test_base.py b/neutron/tests/unit/objects/test_base.py
index 4c7a4692d0..6a14951ec3 100644
--- a/neutron/tests/unit/objects/test_base.py
+++ b/neutron/tests/unit/objects/test_base.py
@@ -55,6 +55,7 @@ from neutron.objects import router
from neutron.objects import securitygroup
from neutron.objects import stdattrs
from neutron.objects import subnet
+from neutron.objects import subnetpool
from neutron.tests import base as test_base
from neutron.tests import tools
from neutron.tests.unit.db import test_db_base_plugin_v2
@@ -1583,7 +1584,7 @@ class BaseDbObjectTestCase(_BaseObjectTestCase,
fip_obj.create()
return fip_obj.id
- def _create_test_subnet_id(self, network_id=None):
+ def _create_test_subnet_id(self, network_id=None, subnet_pool_id=None):
if not network_id:
network_id = self._create_test_network_id()
test_subnet = {
@@ -1597,6 +1598,8 @@ class BaseDbObjectTestCase(_BaseObjectTestCase,
'ipv6_ra_mode': None,
'ipv6_address_mode': None
}
+ if subnet_pool_id:
+ test_subnet['subnetpool_id'] = subnet_pool_id
subnet_obj = subnet.Subnet(self.context, **test_subnet)
subnet_obj.create()
return subnet_obj.id
@@ -1722,6 +1725,21 @@ class BaseDbObjectTestCase(_BaseObjectTestCase,
_qos_policy.create()
return _qos_policy
+ def _create_test_subnet_pool(
+ self, prefix, default_prefixlen, min_prefixlen, max_prefixlen,
+ ip_version):
+ subnet_pool = {
+ 'prefixes': [prefix],
+ 'default_prefixlen': default_prefixlen,
+ 'min_prefixlen': min_prefixlen,
+ 'max_prefixlen': max_prefixlen,
+ 'ip_version': ip_version,
+ 'address_scope_id': uuidutils.generate_uuid(),
+ }
+ subnet_pool_obj = subnetpool.SubnetPool(self.context, **subnet_pool)
+ subnet_pool_obj.create()
+ return subnet_pool_obj.id, subnet_pool_obj.address_scope_id
+
def test_get_standard_attr_id(self):
if not self._test_class.has_standard_attributes():