Added API extensions to detect sorting/pagination features
Those features are available only when allow_sorting and
allow_pagination options are enabled (the current default is False).
They don't depend on plugin support, because when plugins don't
implement them natively, emulated mode is applied by API router itself.
So to make it plugin agnostic, we introduce a way to register custom
per-extension checks to override support detection for cases like that
one.
Now that we have a way to detect support for those features via API,
there is little reason to keep tempest configuration options to enable
those features. Instead, just inspect [network-feature-enabled]
api_extensions option in tempest.conf.
Now that DEFAULT_ALLOW_SORTING/DEFAULT_ALLOW_PAGINATION constants are
used in a single place only (in allow_sorting/allow_pagination
definitions), removed them and replaced with a literal.
Added first in-tree API tests for /extensions entry point.
DocImpact Update API documentation to cover new extensions.
APIImpact Document the new extensions.
Related-Bug: #1566514
Change-Id: I0aaaa037a8ad52060a68dd75c0a1accc6add238e
diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py
index 84d91df..9ee1ba4 100644
--- a/neutron/tests/tempest/api/base.py
+++ b/neutron/tests/tempest/api/base.py
@@ -471,7 +471,7 @@
def _require_sorting(f):
@functools.wraps(f)
def inner(self, *args, **kwargs):
- if not CONF.neutron_plugin_options.validate_sorting:
+ if not test.is_extension_enabled("sorting", "network"):
self.skipTest('Sorting feature is required')
return f(self, *args, **kwargs)
return inner
@@ -480,7 +480,7 @@
def _require_pagination(f):
@functools.wraps(f)
def inner(self, *args, **kwargs):
- if not CONF.neutron_plugin_options.validate_pagination:
+ if not test.is_extension_enabled("pagination", "network"):
self.skipTest('Pagination feature is required')
return f(self, *args, **kwargs)
return inner
diff --git a/neutron/tests/tempest/api/test_extensions.py b/neutron/tests/tempest/api/test_extensions.py
new file mode 100644
index 0000000..1defb33
--- /dev/null
+++ b/neutron/tests/tempest/api/test_extensions.py
@@ -0,0 +1,39 @@
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+from tempest import test
+
+from neutron.tests.tempest.api import base
+from neutron.tests.tempest import config
+
+CONF = config.CONF
+
+
+class ExtensionsTest(base.BaseNetworkTest):
+
+ def _test_list_extensions_includes(self, ext):
+ body = self.client.list_extensions()
+ extensions = {ext_['alias'] for ext_ in body['extensions']}
+ self.assertNotEmpty(extensions, "Extension list returned is empty")
+ ext_enabled = test.is_extension_enabled(ext, "network")
+ if ext_enabled:
+ self.assertIn(ext, extensions)
+ else:
+ self.assertNotIn(ext, extensions)
+
+ @test.idempotent_id('262420b7-a4bb-4a3e-b4b5-e73bad18df8c')
+ def test_list_extensions_sorting(self):
+ self._test_list_extensions_includes('sorting')
+
+ @test.idempotent_id('19db409e-a23f-445d-8bc8-ca3d64c84706')
+ def test_list_extensions_pagination(self):
+ self._test_list_extensions_includes('pagination')
diff --git a/neutron/tests/tempest/config.py b/neutron/tests/tempest/config.py
index bad1000..f50fa39 100644
--- a/neutron/tests/tempest/config.py
+++ b/neutron/tests/tempest/config.py
@@ -12,7 +12,6 @@
from oslo_config import cfg
-from neutron import api
from tempest import config
@@ -23,13 +22,7 @@
cfg.BoolOpt('specify_floating_ip_address_available',
default=True,
help='Allow passing an IP Address of the floating ip when '
- 'creating the floating ip'),
- cfg.BoolOpt('validate_pagination',
- default=api.DEFAULT_ALLOW_PAGINATION,
- help='Validate pagination'),
- cfg.BoolOpt('validate_sorting',
- default=api.DEFAULT_ALLOW_SORTING,
- help='Validate sorting')]
+ 'creating the floating ip')]
# TODO(amuller): Redo configuration options registration as part of the planned
# transition to the Tempest plugin architecture
diff --git a/neutron/tests/tempest/services/network/json/network_client.py b/neutron/tests/tempest/services/network/json/network_client.py
index 12ba685..9c8cb05 100644
--- a/neutron/tests/tempest/services/network/json/network_client.py
+++ b/neutron/tests/tempest/services/network/json/network_client.py
@@ -791,3 +791,12 @@
self.expected_success(201, resp.status)
body = jsonutils.loads(body)
return service_client.ResponseBody(resp, body)
+
+ def list_extensions(self, **filters):
+ uri = self.get_uri("extensions")
+ if filters:
+ uri = '?'.join([uri, urlparse.urlencode(filters)])
+ resp, body = self.get(uri)
+ body = {'extensions': self.deserialize_list(body)}
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)