qos: added api sorting/pagination tests for policies
API tests were modified to support admin listing mode. This is needed
for QoS resources because the default policy file does not allow to
create policies, and we should avoid using shared policies due to races.
Related-Bug: #1566514
Depends-On: I8b553ab22846122dde22372f9901e46a5276ee8e
Change-Id: Ie3a66d2a7c05143df3da1c56c8e8a5308d4bae91
diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py
index 45e12f0..908b8df 100644
--- a/neutron/tests/tempest/api/base.py
+++ b/neutron/tests/tempest/api/base.py
@@ -325,7 +325,8 @@
return interface
@classmethod
- def create_qos_policy(cls, name, description, shared, tenant_id=None):
+ def create_qos_policy(cls, name, description=None, shared=False,
+ tenant_id=None):
"""Wrapper utility that returns a test QoS policy."""
body = cls.admin_client.create_qos_policy(
name, description, shared, tenant_id)
@@ -501,6 +502,8 @@
list_kwargs = {}
+ list_as_admin = False
+
def assertSameOrder(self, original, actual):
# gracefully handle iterators passed
original = list(original)
@@ -513,8 +516,12 @@
def plural_name(self):
return '%ss' % self.resource
+ @property
+ def list_client(self):
+ return self.admin_client if self.list_as_admin else self.client
+
def list_method(self, *args, **kwargs):
- method = getattr(self.client, 'list_%s' % self.plural_name)
+ method = getattr(self.list_client, 'list_%s' % self.plural_name)
kwargs.update(self.list_kwargs)
return method(*args, **kwargs)
@@ -617,9 +624,9 @@
uri = self.get_bare_url(prev_links['next'])
else:
sort_args.update(self.list_kwargs)
- uri = self.client.build_uri(
+ uri = self.list_client.build_uri(
self.plural_name, limit=1, **sort_args)
- prev_links, body = self.client.get_uri_with_links(
+ prev_links, body = self.list_client.get_uri_with_links(
self.plural_name, uri
)
resources_ = self._extract_resources(body)
@@ -637,7 +644,7 @@
resources2 = []
for i in range(niterations):
uri = self.get_bare_url(prev_links['previous'])
- prev_links, body = self.client.get_uri_with_links(
+ prev_links, body = self.list_client.get_uri_with_links(
self.plural_name, uri
)
resources_ = self._extract_resources(body)
@@ -676,9 +683,9 @@
uri = self.get_bare_url(prev_links['previous'])
else:
pagination_args.update(self.list_kwargs)
- uri = self.client.build_uri(
+ uri = self.list_client.build_uri(
self.plural_name, page_reverse=True, **pagination_args)
- prev_links, body = self.client.get_uri_with_links(
+ prev_links, body = self.list_client.get_uri_with_links(
self.plural_name, uri
)
resources_ = self._extract_resources(body)