Merge "qos: added api sorting/pagination tests for policies"
diff --git a/neutron/tests/tempest/api/admin/test_quotas.py b/neutron/tests/tempest/api/admin/test_quotas.py
index 3bf52c5..7195693 100644
--- a/neutron/tests/tempest/api/admin/test_quotas.py
+++ b/neutron/tests/tempest/api/admin/test_quotas.py
@@ -36,7 +36,7 @@
             name=test_tenant,
             description=test_description)['tenant']
         self.addCleanup(
-            self.identity_admin_client.create_tenant, tenant['id'])
+            self.identity_admin_client.delete_tenant, tenant['id'])
         return tenant
 
     def _setup_quotas(self, project_id, **new_quotas):
diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py
index 908b8df..2d836d6 100644
--- a/neutron/tests/tempest/api/base.py
+++ b/neutron/tests/tempest/api/base.py
@@ -429,7 +429,7 @@
 
     @classmethod
     def get_unused_ip(cls, net_id, ip_version=None):
-        """Get an unused ip address in a allocaion pool of net"""
+        """Get an unused ip address in a allocation pool of net"""
         body = cls.admin_client.list_ports(network_id=net_id)
         ports = body['ports']
         used_ips = []
diff --git a/neutron/tests/tempest/api/test_auto_allocated_topology.py b/neutron/tests/tempest/api/test_auto_allocated_topology.py
index 1610c85..2c2dfc6 100644
--- a/neutron/tests/tempest/api/test_auto_allocated_topology.py
+++ b/neutron/tests/tempest/api/test_auto_allocated_topology.py
@@ -87,6 +87,8 @@
 
         network_id1 = topology['id']
         self.assertIsNotNone(network_id1)
+        network = self.client.show_network(topology['id'])['network']
+        self.assertTrue(network['admin_state_up'])
         resources_after1 = self._count_topology_resources()
         # One network, two subnets (v4 and v6) and one router
         self.assertEqual((1, self.num_subnetpools, 1), resources_after1)
diff --git a/neutron/tests/tempest/api/test_routers.py b/neutron/tests/tempest/api/test_routers.py
index 65fda89..d0a38aa 100644
--- a/neutron/tests/tempest/api/test_routers.py
+++ b/neutron/tests/tempest/api/test_routers.py
@@ -18,13 +18,14 @@
 from tempest.lib.common.utils import data_utils
 from tempest import test
 
-from neutron.tests.tempest.api import base_routers as base
+from neutron.tests.tempest.api import base
+from neutron.tests.tempest.api import base_routers
 from neutron.tests.tempest import config
 
 CONF = config.CONF
 
 
-class RoutersTest(base.BaseRouterTest):
+class RoutersTest(base_routers.BaseRouterTest):
 
     @classmethod
     @test.requires_ext(extension="router", service="network")
@@ -216,7 +217,7 @@
     _ip_version = 6
 
 
-class DvrRoutersTest(base.BaseRouterTest):
+class DvrRoutersTest(base_routers.BaseRouterTest):
 
     @classmethod
     @test.requires_ext(extension="dvr", service="network")
@@ -244,3 +245,64 @@
         self.assertTrue(show_body['router']['distributed'])
         show_body = self.client.show_router(router['id'])
         self.assertNotIn('distributed', show_body['router'])
+
+
+class RoutersSearchCriteriaTest(base.BaseSearchCriteriaTest):
+
+    resource = 'router'
+
+    @classmethod
+    @test.requires_ext(extension="router", service="network")
+    def skip_checks(cls):
+        super(RoutersSearchCriteriaTest, cls).skip_checks()
+
+    @classmethod
+    def resource_setup(cls):
+        super(RoutersSearchCriteriaTest, cls).resource_setup()
+        for name in cls.resource_names:
+            cls.create_router(router_name=name)
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('03a69efb-90a7-435b-bb5c-3add3612085a')
+    def test_list_sorts_asc(self):
+        self._test_list_sorts_asc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('95913d30-ff41-4b17-9f44-5258c651e78c')
+    def test_list_sorts_desc(self):
+        self._test_list_sorts_desc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('7f7d40b1-e165-4817-8dc5-02f8e2f0dff3')
+    def test_list_pagination(self):
+        self._test_list_pagination()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('a5b83e83-3d98-45bb-a2c7-0ee179ffd42c')
+    def test_list_pagination_with_marker(self):
+        self._test_list_pagination_with_marker()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('40804af8-c25d-45f8-b8a8-b4c70345215d')
+    def test_list_pagination_with_href_links(self):
+        self._test_list_pagination_with_href_links()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('77b9676c-d3cb-43af-a0e8-a5b8c6099e70')
+    def test_list_pagination_page_reverse_asc(self):
+        self._test_list_pagination_page_reverse_asc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('3133a2c5-1bb9-4fc7-833e-cf9a1d160255')
+    def test_list_pagination_page_reverse_desc(self):
+        self._test_list_pagination_page_reverse_desc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('8252e2f0-b3da-4738-8e25-f6f8d878a2da')
+    def test_list_pagination_page_reverse_with_href_links(self):
+        self._test_list_pagination_page_reverse_with_href_links()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('fb102124-20f8-4cb3-8c81-f16f5e41d192')
+    def test_list_no_pagination_limit_0(self):
+        self._test_list_no_pagination_limit_0()
diff --git a/neutron/tests/tempest/api/test_subnetpools_negative.py b/neutron/tests/tempest/api/test_subnetpools_negative.py
index a9a7d55..052c3cd 100644
--- a/neutron/tests/tempest/api/test_subnetpools_negative.py
+++ b/neutron/tests/tempest/api/test_subnetpools_negative.py
@@ -267,3 +267,14 @@
         self.assertRaises(lib_exc.BadRequest, self.client.update_subnetpool,
                           created_subnetpool['id'],
                           address_scope_id=address_scope['id'])
+
+    @test.attr(type='negative')
+    @test.idempotent_id('2f66dc2f-cc32-4caa-91ec-0c0cd7c46d70')
+    def test_update_subnetpool_tenant_id(self):
+        subnetpool = self._create_subnetpool()
+        self.assertRaises(
+            lib_exc.BadRequest,
+            self.admin_client.update_subnetpool,
+            subnetpool['id'],
+            tenant_id=self.admin_client.tenant_id,
+        )
diff --git a/neutron/tests/tempest/api/test_subnets.py b/neutron/tests/tempest/api/test_subnets.py
new file mode 100644
index 0000000..ba1bd61
--- /dev/null
+++ b/neutron/tests/tempest/api/test_subnets.py
@@ -0,0 +1,74 @@
+#    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
+
+
+class SubnetsSearchCriteriaTest(base.BaseSearchCriteriaTest):
+
+    resource = 'subnet'
+
+    list_kwargs = {'shared': False}
+
+    @classmethod
+    def resource_setup(cls):
+        super(SubnetsSearchCriteriaTest, cls).resource_setup()
+        net = cls.create_network(network_name='subnet-search-test-net')
+        for name in cls.resource_names:
+            cls.create_subnet(net, name=name)
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('d2d61995-5dd5-4b93-bce7-3edefdb79563')
+    def test_list_sorts_asc(self):
+        self._test_list_sorts_asc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('c3c6b0af-c4ac-4da0-b568-8d08ae550604')
+    def test_list_sorts_desc(self):
+        self._test_list_sorts_desc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('b93063b3-f713-406e-bf93-e5738e09153c')
+    def test_list_pagination(self):
+        self._test_list_pagination()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('2ddd9aa6-de28-410f-9cbc-ce752893c407')
+    def test_list_pagination_with_marker(self):
+        self._test_list_pagination_with_marker()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('351183ef-6ed9-4d71-a9f2-a5ac049bd7ea')
+    def test_list_pagination_with_href_links(self):
+        self._test_list_pagination_with_href_links()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('dfaa20ca-6d84-4f26-962f-2fee4d247cd9')
+    def test_list_pagination_page_reverse_asc(self):
+        self._test_list_pagination_page_reverse_asc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('40552213-3e12-4d6a-86f3-dda92f3de88c')
+    def test_list_pagination_page_reverse_desc(self):
+        self._test_list_pagination_page_reverse_desc()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('3cea9053-a731-4480-93ee-19b2c28a9ce4')
+    def test_list_pagination_page_reverse_with_href_links(self):
+        self._test_list_pagination_page_reverse_with_href_links()
+
+    @test.attr(type='smoke')
+    @test.idempotent_id('d851937c-9821-4b46-9d18-43e9077ecac0')
+    def test_list_no_pagination_limit_0(self):
+        self._test_list_no_pagination_limit_0()
diff --git a/neutron/tests/tempest/scenario/test_basic.py b/neutron/tests/tempest/scenario/test_basic.py
index c05e1c2..fcd856b 100644
--- a/neutron/tests/tempest/scenario/test_basic.py
+++ b/neutron/tests/tempest/scenario/test_basic.py
@@ -31,7 +31,6 @@
     # Default to ipv4.
     _ip_version = 4
 
-
     @test.idempotent_id('de07fe0a-e955-449e-b48b-8641c14cd52e')
     def test_basic_instance(self):
         network = self.create_network()