Fix resource schemas and releated get_sorts
test cases
When I'm trying to introduce a central sort-keys validation within patch [1] to `get_sorts` method in `neutron.api.api_common` module, I get blocked by some resource schemas and test cases. After reading neutron API docs and some inspection, I believe there exists uses of improper sort keys in test cases and some resource schemes need to keep aligned with offical documents. * Schemas of resource SecurityGroups/SG Rules/Segments don't provide `is_sort_key` flag for their sort key properties claimed in offical docs as neutron-lib does. See [2] for more details. * Test cases of resource NetworkSegmentRange use unsupported sort keys, e.g: physical_network. Replace it with `name` property. See [2] for more details. [1] https://review.opendev.org/#/c/653903/ [2] https://developer.openstack.org/api-ref/network/v2/index.html Change-Id: I45a51736e4075e3dbc16827486869d70b659622d
This commit is contained in:
parent
36517c6016
commit
ed3f1087fa
@ -221,13 +221,16 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'validate': {'type:uuid': None},
|
||||
'is_visible': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'primary_key': True},
|
||||
'name': {'allow_post': True, 'allow_put': True,
|
||||
'is_visible': True, 'default': '', 'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {
|
||||
'type:name_not_default': db_const.NAME_FIELD_SIZE}},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True, 'is_filter': True},
|
||||
@ -239,39 +242,42 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'validate': {'type:uuid': None},
|
||||
'is_visible': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'primary_key': True},
|
||||
'security_group_id': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'required_by_policy': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'remote_group_id': {'allow_post': True, 'allow_put': False,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'direction': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {'type:values': ['ingress', 'egress']}},
|
||||
'protocol': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'default': None,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True, 'is_filter': True,
|
||||
'convert_to': convert_protocol},
|
||||
'port_range_min': {'allow_post': True, 'allow_put': False,
|
||||
'convert_to': convert_validate_port_value,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'port_range_max': {'allow_post': True, 'allow_put': False,
|
||||
'convert_to': convert_validate_port_value,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True},
|
||||
'is_sort_key': True, 'is_filter': True},
|
||||
'ethertype': {'allow_post': True, 'allow_put': False,
|
||||
'is_visible': True, 'default': 'IPv4',
|
||||
'is_filter': True,
|
||||
'is_filter': True, 'is_sort_key': True,
|
||||
'convert_to': convert_ethertype_to_case_insensitive,
|
||||
'validate': {'type:values': sg_supported_ethertypes}},
|
||||
'remote_ip_prefix': {'allow_post': True, 'allow_put': False,
|
||||
'default': None, 'is_visible': True,
|
||||
'is_filter': True,
|
||||
'is_sort_key': True, 'is_filter': True,
|
||||
'convert_to': convert_ip_prefix_to_cidr},
|
||||
'tenant_id': {'allow_post': True, 'allow_put': False,
|
||||
'required_by_policy': True,
|
||||
'is_sort_key': True,
|
||||
'validate': {
|
||||
'type:string': db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_visible': True, 'is_filter': True},
|
||||
|
@ -45,17 +45,20 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True,
|
||||
'primary_key': True},
|
||||
'tenant_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:string':
|
||||
db_const.PROJECT_ID_FIELD_SIZE},
|
||||
'is_sort_key': True,
|
||||
'is_visible': False},
|
||||
'network_id': {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:uuid': None},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
PHYSICAL_NETWORK: {'allow_post': True,
|
||||
'allow_put': False,
|
||||
@ -63,23 +66,27 @@ RESOURCE_ATTRIBUTE_MAP = {
|
||||
'validate': {'type:string':
|
||||
providernet.PHYSICAL_NETWORK_MAX_LEN},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
NETWORK_TYPE: {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'validate': {'type:string':
|
||||
providernet.NETWORK_TYPE_MAX_LEN},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
SEGMENTATION_ID: {'allow_post': True,
|
||||
'allow_put': False,
|
||||
'default': constants.ATTR_NOT_SPECIFIED,
|
||||
'convert_to': converters.convert_to_int,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True},
|
||||
'name': {'allow_post': True,
|
||||
'allow_put': True,
|
||||
'default': constants.ATTR_NOT_SPECIFIED,
|
||||
'validate': {'type:string_or_none': NAME_LEN},
|
||||
'is_filter': True,
|
||||
'is_sort_key': True,
|
||||
'is_visible': True}
|
||||
},
|
||||
subnet_def.COLLECTION_NAME: {
|
||||
|
@ -313,7 +313,7 @@ class TestNetworkSegmentRange(NetworkSegmentRangeTestBase):
|
||||
name='foo-range2', physical_network='phys_net2')
|
||||
self._test_list_with_sort('network-segment-range',
|
||||
(range2, range1),
|
||||
[('physical_network', 'desc')])
|
||||
[('name', 'desc')])
|
||||
|
||||
def test_list_network_segment_ranges_with_pagination(self):
|
||||
range1 = self._test_create_network_segment_range(
|
||||
@ -325,7 +325,7 @@ class TestNetworkSegmentRange(NetworkSegmentRangeTestBase):
|
||||
self._test_list_with_pagination(
|
||||
'network-segment-range',
|
||||
(range1, range2, range3),
|
||||
('physical_network', 'asc'), 2, 2)
|
||||
('name', 'asc'), 2, 2)
|
||||
|
||||
def test_list_network_segment_ranges_with_pagination_reverse(self):
|
||||
range1 = self._test_create_network_segment_range(
|
||||
@ -337,7 +337,7 @@ class TestNetworkSegmentRange(NetworkSegmentRangeTestBase):
|
||||
self._test_list_with_pagination_reverse(
|
||||
'network-segment-range',
|
||||
(range1, range2, range3),
|
||||
('physical_network', 'asc'), 2, 2)
|
||||
('name', 'asc'), 2, 2)
|
||||
|
||||
def test_delete_network_segment_range(self):
|
||||
network_segment_range = self._test_create_network_segment_range()
|
||||
|
Loading…
x
Reference in New Issue
Block a user