Merge "Enhance v3 list_services to test filtering by service type"
diff --git a/releasenotes/notes/add-params-to-identity-v3-list-endpoints-958a155be4e17e5b.yaml b/releasenotes/notes/add-params-to-identity-v3-list-endpoints-958a155be4e17e5b.yaml
new file mode 100644
index 0000000..46f3b49
--- /dev/null
+++ b/releasenotes/notes/add-params-to-identity-v3-list-endpoints-958a155be4e17e5b.yaml
@@ -0,0 +1,6 @@
+---
+features:
+  - |
+    The ``list_endpoints`` method of the v3 ``EndPointsClient`` class now has
+    an additional ``**params`` argument that enables passing additional
+    information in the query string of the HTTP request.
diff --git a/tempest/api/compute/flavors/test_flavors.py b/tempest/api/compute/flavors/test_flavors.py
index bf4c958..d5bb45a 100644
--- a/tempest/api/compute/flavors/test_flavors.py
+++ b/tempest/api/compute/flavors/test_flavors.py
@@ -68,7 +68,7 @@
 
         params = {'marker': flavor_id}
         flavors = self.flavors_client.list_flavors(**params)['flavors']
-        self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
+        self.assertEmpty([i for i in flavors if i['id'] == flavor_id],
                          'The list of flavors did not start after the marker.')
 
     @decorators.idempotent_id('6db2f0c0-ddee-4162-9c84-0703d3dd1107')
@@ -80,7 +80,7 @@
         params = {'marker': flavor_id}
         flavors = self.flavors_client.list_flavors(detail=True,
                                                    **params)['flavors']
-        self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]),
+        self.assertEmpty([i for i in flavors if i['id'] == flavor_id],
                          'The list of flavors did not start after the marker.')
 
     @decorators.idempotent_id('3df2743e-3034-4e57-a4cb-b6527f6eac79')
@@ -92,7 +92,7 @@
         params = {self._min_disk: flavor['disk'] + 1}
         flavors = self.flavors_client.list_flavors(detail=True,
                                                    **params)['flavors']
-        self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
+        self.assertEmpty([i for i in flavors if i['id'] == flavor_id])
 
     @decorators.idempotent_id('09fe7509-b4ee-4b34-bf8b-39532dc47292')
     def test_list_flavors_detailed_filter_by_min_ram(self):
@@ -103,7 +103,7 @@
         params = {self._min_ram: flavor['ram'] + 1}
         flavors = self.flavors_client.list_flavors(detail=True,
                                                    **params)['flavors']
-        self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
+        self.assertEmpty([i for i in flavors if i['id'] == flavor_id])
 
     @decorators.idempotent_id('10645a4d-96f5-443f-831b-730711e11dd4')
     def test_list_flavors_filter_by_min_disk(self):
@@ -113,7 +113,7 @@
 
         params = {self._min_disk: flavor['disk'] + 1}
         flavors = self.flavors_client.list_flavors(**params)['flavors']
-        self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
+        self.assertEmpty([i for i in flavors if i['id'] == flavor_id])
 
     @decorators.idempotent_id('935cf550-e7c8-4da6-8002-00f92d5edfaa')
     def test_list_flavors_filter_by_min_ram(self):
@@ -123,4 +123,4 @@
 
         params = {self._min_ram: flavor['ram'] + 1}
         flavors = self.flavors_client.list_flavors(**params)['flavors']
-        self.assertFalse(any([i for i in flavors if i['id'] == flavor_id]))
+        self.assertEmpty([i for i in flavors if i['id'] == flavor_id])
diff --git a/tempest/api/compute/images/test_list_image_filters.py b/tempest/api/compute/images/test_list_image_filters.py
index 6677aa2..acc8b3e 100644
--- a/tempest/api/compute/images/test_list_image_filters.py
+++ b/tempest/api/compute/images/test_list_image_filters.py
@@ -129,9 +129,9 @@
         params = {'status': 'ACTIVE'}
         images = self.client.list_images(**params)['images']
 
-        self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
-        self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
-        self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
+        self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])
+        self.assertNotEmpty([i for i in images if i['id'] == self.image2_id])
+        self.assertNotEmpty([i for i in images if i['id'] == self.image3_id])
 
     @decorators.idempotent_id('33163b73-79f5-4d07-a7ea-9213bcc468ff')
     def test_list_images_filter_by_name(self):
@@ -140,9 +140,9 @@
         params = {'name': self.image1['name']}
         images = self.client.list_images(**params)['images']
 
-        self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
-        self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
-        self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
+        self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])
+        self.assertEmpty([i for i in images if i['id'] == self.image2_id])
+        self.assertEmpty([i for i in images if i['id'] == self.image3_id])
 
     @decorators.idempotent_id('9f238683-c763-45aa-b848-232ec3ce3105')
     @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
@@ -152,14 +152,13 @@
         params = {'server': self.server1['id']}
         images = self.client.list_images(**params)['images']
 
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot1_id]),
-                        "Failed to find image %s in images. Got images %s" %
-                        (self.image1_id, images))
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot2_id]))
-        self.assertFalse(any([i for i in images
-                              if i['id'] == self.snapshot3_id]))
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot1_id],
+                            "Failed to find image %s in images. "
+                            "Got images %s" % (self.image1_id, images))
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot2_id])
+        self.assertEmpty([i for i in images if i['id'] == self.snapshot3_id])
 
     @decorators.idempotent_id('05a377b8-28cf-4734-a1e6-2ab5c38bf606')
     @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
@@ -173,12 +172,12 @@
             params = {'server': link['href']}
             images = self.client.list_images(**params)['images']
 
-            self.assertFalse(any([i for i in images
-                                  if i['id'] == self.snapshot1_id]))
-            self.assertFalse(any([i for i in images
-                                  if i['id'] == self.snapshot2_id]))
-            self.assertTrue(any([i for i in images
-                                 if i['id'] == self.snapshot3_id]))
+            self.assertEmpty([i for i in images
+                              if i['id'] == self.snapshot1_id])
+            self.assertEmpty([i for i in images
+                              if i['id'] == self.snapshot2_id])
+            self.assertNotEmpty([i for i in images
+                                 if i['id'] == self.snapshot3_id])
 
     @decorators.idempotent_id('e3356918-4d3e-4756-81d5-abc4524ba29f')
     @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
@@ -188,14 +187,13 @@
         params = {'type': 'snapshot'}
         images = self.client.list_images(**params)['images']
 
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot1_id]))
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot2_id]))
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot3_id]))
-        self.assertFalse(any([i for i in images
-                              if i['id'] == self.image_ref]))
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot1_id])
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot2_id])
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot3_id])
+        self.assertEmpty([i for i in images if i['id'] == self.image_ref])
 
     @decorators.idempotent_id('3a484ca9-67ba-451e-b494-7fcf28d32d62')
     def test_list_images_limit_results(self):
@@ -212,8 +210,8 @@
         # Filter by the image's created time
         params = {'changes-since': self.image3['created']}
         images = self.client.list_images(**params)['images']
-        found = any([i for i in images if i['id'] == self.image3_id])
-        self.assertTrue(found)
+        found = [i for i in images if i['id'] == self.image3_id]
+        self.assertNotEmpty(found)
 
     @decorators.idempotent_id('9b0ea018-6185-4f71-948a-a123a107988e')
     def test_list_images_with_detail_filter_by_status(self):
@@ -222,9 +220,9 @@
         params = {'status': 'ACTIVE'}
         images = self.client.list_images(detail=True, **params)['images']
 
-        self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
-        self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
-        self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))
+        self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])
+        self.assertNotEmpty([i for i in images if i['id'] == self.image2_id])
+        self.assertNotEmpty([i for i in images if i['id'] == self.image3_id])
 
     @decorators.idempotent_id('644ea267-9bd9-4f3b-af9f-dffa02396a17')
     def test_list_images_with_detail_filter_by_name(self):
@@ -233,9 +231,9 @@
         params = {'name': self.image1['name']}
         images = self.client.list_images(detail=True, **params)['images']
 
-        self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
-        self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
-        self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))
+        self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])
+        self.assertEmpty([i for i in images if i['id'] == self.image2_id])
+        self.assertEmpty([i for i in images if i['id'] == self.image3_id])
 
     @decorators.idempotent_id('ba2fa9a9-b672-47cc-b354-3b4c0600e2cb')
     def test_list_images_with_detail_limit_results(self):
@@ -257,12 +255,12 @@
             params = {'server': link['href']}
             images = self.client.list_images(detail=True, **params)['images']
 
-            self.assertFalse(any([i for i in images
-                                  if i['id'] == self.snapshot1_id]))
-            self.assertFalse(any([i for i in images
-                                  if i['id'] == self.snapshot2_id]))
-            self.assertTrue(any([i for i in images
-                                 if i['id'] == self.snapshot3_id]))
+            self.assertEmpty([i for i in images
+                              if i['id'] == self.snapshot1_id])
+            self.assertEmpty([i for i in images
+                              if i['id'] == self.snapshot2_id])
+            self.assertNotEmpty([i for i in images
+                                 if i['id'] == self.snapshot3_id])
 
     @decorators.idempotent_id('888c0cc0-7223-43c5-9db0-b125fd0a393b')
     @testtools.skipUnless(CONF.compute_feature_enabled.snapshot,
@@ -273,14 +271,13 @@
         images = self.client.list_images(detail=True, **params)['images']
         self.client.show_image(self.image_ref)
 
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot1_id]))
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot2_id]))
-        self.assertTrue(any([i for i in images
-                             if i['id'] == self.snapshot3_id]))
-        self.assertFalse(any([i for i in images
-                              if i['id'] == self.image_ref]))
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot1_id])
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot2_id])
+        self.assertNotEmpty([i for i in images
+                             if i['id'] == self.snapshot3_id])
+        self.assertEmpty([i for i in images if i['id'] == self.image_ref])
 
     @decorators.idempotent_id('7d439e18-ac2e-4827-b049-7e18004712c4')
     def test_list_images_with_detail_filter_by_changes_since(self):
@@ -290,4 +287,4 @@
         # Filter by the image's created time
         params = {'changes-since': self.image1['created']}
         images = self.client.list_images(detail=True, **params)['images']
-        self.assertTrue(any([i for i in images if i['id'] == self.image1_id]))
+        self.assertNotEmpty([i for i in images if i['id'] == self.image1_id])
diff --git a/tempest/api/compute/images/test_list_images.py b/tempest/api/compute/images/test_list_images.py
index 5d3cbf3..e2dbd72 100644
--- a/tempest/api/compute/images/test_list_images.py
+++ b/tempest/api/compute/images/test_list_images.py
@@ -44,12 +44,12 @@
     def test_list_images(self):
         # The list of all images should contain the image
         images = self.client.list_images()['images']
-        found = any([i for i in images if i['id'] == self.image_ref])
-        self.assertTrue(found)
+        found = [i for i in images if i['id'] == self.image_ref]
+        self.assertNotEmpty(found)
 
     @decorators.idempotent_id('9f94cb6b-7f10-48c5-b911-a0b84d7d4cd6')
     def test_list_images_with_detail(self):
         # Detailed list of all images should contain the expected images
         images = self.client.list_images(detail=True)['images']
-        found = any([i for i in images if i['id'] == self.image_ref])
-        self.assertTrue(found)
+        found = [i for i in images if i['id'] == self.image_ref]
+        self.assertNotEmpty(found)
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index b568f7d..124db0e 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -159,8 +159,8 @@
         # Get rules of the created Security Group
         rules = self.security_groups_client.show_security_group(
             securitygroup_id)['security_group']['rules']
-        self.assertTrue(any([i for i in rules if i['id'] == rule1_id]))
-        self.assertTrue(any([i for i in rules if i['id'] == rule2_id]))
+        self.assertNotEmpty([i for i in rules if i['id'] == rule1_id])
+        self.assertNotEmpty([i for i in rules if i['id'] == rule2_id])
 
     @decorators.idempotent_id('fc5c5acf-2091-43a6-a6ae-e42760e9ffaf')
     @test.services('network')
diff --git a/tempest/api/compute/servers/test_create_server.py b/tempest/api/compute/servers/test_create_server.py
index db42c6c..ffadd96 100644
--- a/tempest/api/compute/servers/test_create_server.py
+++ b/tempest/api/compute/servers/test_create_server.py
@@ -97,16 +97,16 @@
         # The created server should be in the list of all servers
         body = self.client.list_servers()
         servers = body['servers']
-        found = any([i for i in servers if i['id'] == self.server['id']])
-        self.assertTrue(found)
+        found = [i for i in servers if i['id'] == self.server['id']]
+        self.assertNotEmpty(found)
 
     @decorators.idempotent_id('585e934c-448e-43c4-acbf-d06a9b899997')
     def test_list_servers_with_detail(self):
         # The created server should be in the detailed list of all servers
         body = self.client.list_servers(detail=True)
         servers = body['servers']
-        found = any([i for i in servers if i['id'] == self.server['id']])
-        self.assertTrue(found)
+        found = [i for i in servers if i['id'] == self.server['id']]
+        self.assertNotEmpty(found)
 
     @decorators.idempotent_id('cbc0f52f-05aa-492b-bdc1-84b575ca294b')
     @testtools.skipUnless(CONF.validation.run_validation,
diff --git a/tempest/api/identity/admin/v2/test_roles.py b/tempest/api/identity/admin/v2/test_roles.py
index 479663c..124bb5f 100644
--- a/tempest/api/identity/admin/v2/test_roles.py
+++ b/tempest/api/identity/admin/v2/test_roles.py
@@ -54,7 +54,7 @@
         """Return a list of all roles."""
         body = self.roles_client.list_roles()['roles']
         found = [role for role in body if role in self.roles]
-        self.assertTrue(any(found))
+        self.assertNotEmpty(found)
         self.assertEqual(len(found), len(self.roles))
 
     @decorators.idempotent_id('c62d909d-6c21-48c0-ae40-0a0760e6db5e')
@@ -68,13 +68,13 @@
 
         body = self.roles_client.list_roles()['roles']
         found = [role for role in body if role['name'] == role_name]
-        self.assertTrue(any(found))
+        self.assertNotEmpty(found)
 
         body = self.roles_client.delete_role(found[0]['id'])
 
         body = self.roles_client.list_roles()['roles']
         found = [role for role in body if role['name'] == role_name]
-        self.assertFalse(any(found))
+        self.assertEmpty(found)
 
     @decorators.idempotent_id('db6870bd-a6ed-43be-a9b1-2f10a5c9994f')
     def test_get_role_by_id(self):
diff --git a/tempest/api/identity/admin/v2/test_tenants.py b/tempest/api/identity/admin/v2/test_tenants.py
index ad9b983..0f955bf 100644
--- a/tempest/api/identity/admin/v2/test_tenants.py
+++ b/tempest/api/identity/admin/v2/test_tenants.py
@@ -37,7 +37,7 @@
 
         body = self.tenants_client.list_tenants()['tenants']
         found = [tenant for tenant in body if tenant['id'] in tenant_ids]
-        self.assertFalse(any(found), 'Tenants failed to delete')
+        self.assertEmpty(found, 'Tenants failed to delete')
 
     @decorators.idempotent_id('d25e9f24-1310-4d29-b61b-d91299c21d6d')
     def test_tenant_create_with_description(self):
diff --git a/tempest/api/identity/admin/v3/test_endpoints.py b/tempest/api/identity/admin/v3/test_endpoints.py
index b1ae2aa..c9faa9a 100644
--- a/tempest/api/identity/admin/v3/test_endpoints.py
+++ b/tempest/api/identity/admin/v3/test_endpoints.py
@@ -29,56 +29,93 @@
     def resource_setup(cls):
         super(EndPointsTestJSON, cls).resource_setup()
         cls.service_ids = list()
-        s_name = data_utils.rand_name('service')
-        s_type = data_utils.rand_name('type')
-        s_description = data_utils.rand_name('description')
+
+        # Create endpoints so as to use for LIST and GET test cases
+        interfaces = ['public', 'internal']
+        cls.setup_endpoint_ids = list()
+        for i in range(2):
+            cls._create_service()
+            region = data_utils.rand_name('region')
+            url = data_utils.rand_url()
+            endpoint = cls.client.create_endpoint(
+                service_id=cls.service_ids[i], interface=interfaces[i],
+                url=url, region=region, enabled=True)['endpoint']
+            cls.setup_endpoint_ids.append(endpoint['id'])
+
+    @classmethod
+    def _create_service(cls, s_name=None, s_type=None, s_description=None):
+        if s_name is None:
+            s_name = data_utils.rand_name('service')
+        if s_type is None:
+            s_type = data_utils.rand_name('type')
+        if s_description is None:
+            s_description = data_utils.rand_name('description')
         service_data = (
             cls.services_client.create_service(name=s_name, type=s_type,
                                                description=s_description))
-        cls.service_id = service_data['service']['id']
-        cls.service_ids.append(cls.service_id)
-        # Create endpoints so as to use for LIST and GET test cases
-        cls.setup_endpoints = list()
-        for _ in range(2):
-            region = data_utils.rand_name('region')
-            url = data_utils.rand_url()
-            interface = 'public'
-            endpoint = cls.client.create_endpoint(service_id=cls.service_id,
-                                                  interface=interface,
-                                                  url=url, region=region,
-                                                  enabled=True)['endpoint']
-            cls.setup_endpoints.append(endpoint)
+        service = service_data['service']
+        cls.service_ids.append(service['id'])
+        return service
 
     @classmethod
     def resource_cleanup(cls):
-        for e in cls.setup_endpoints:
-            cls.client.delete_endpoint(e['id'])
+        for e in cls.setup_endpoint_ids:
+            cls.client.delete_endpoint(e)
         for s in cls.service_ids:
             cls.services_client.delete_service(s)
         super(EndPointsTestJSON, cls).resource_cleanup()
 
     @decorators.idempotent_id('c19ecf90-240e-4e23-9966-21cee3f6a618')
     def test_list_endpoints(self):
-        # Get a list of endpoints
+        # Get the list of all the endpoints.
         fetched_endpoints = self.client.list_endpoints()['endpoints']
-        # Asserting LIST endpoints
+        fetched_endpoint_ids = [e['id'] for e in fetched_endpoints]
+        # Check that all the created endpoints are present in
+        # "fetched_endpoints".
         missing_endpoints =\
-            [e for e in self.setup_endpoints if e not in fetched_endpoints]
-        self.assertEmpty(missing_endpoints,
+            [e for e in self.setup_endpoint_ids
+             if e not in fetched_endpoint_ids]
+        self.assertEqual(0, len(missing_endpoints),
                          "Failed to find endpoint %s in fetched list" %
                          ', '.join(str(e) for e in missing_endpoints))
 
+        # Check that filtering endpoints by service_id works.
+        fetched_endpoints_for_service = self.client.list_endpoints(
+            service_id=self.service_ids[0])['endpoints']
+        fetched_endpoints_for_alt_service = self.client.list_endpoints(
+            service_id=self.service_ids[1])['endpoints']
+
+        # Assert that both filters returned the correct result.
+        self.assertEqual(1, len(fetched_endpoints_for_service))
+        self.assertEqual(1, len(fetched_endpoints_for_alt_service))
+        self.assertEqual(set(self.setup_endpoint_ids),
+                         set([fetched_endpoints_for_service[0]['id'],
+                              fetched_endpoints_for_alt_service[0]['id']]))
+
+        # Check that filtering endpoints by interface works.
+        fetched_public_endpoints = self.client.list_endpoints(
+            interface='public')['endpoints']
+        fetched_internal_endpoints = self.client.list_endpoints(
+            interface='internal')['endpoints']
+
+        # Check that the expected endpoint_id is present per filter. [0] is
+        # public and [1] is internal.
+        self.assertIn(self.setup_endpoint_ids[0],
+                      [e['id'] for e in fetched_public_endpoints])
+        self.assertIn(self.setup_endpoint_ids[1],
+                      [e['id'] for e in fetched_internal_endpoints])
+
     @decorators.idempotent_id('0e2446d2-c1fd-461b-a729-b9e73e3e3b37')
     def test_create_list_show_delete_endpoint(self):
         region = data_utils.rand_name('region')
         url = data_utils.rand_url()
         interface = 'public'
-        endpoint = self.client.create_endpoint(service_id=self.service_id,
+        endpoint = self.client.create_endpoint(service_id=self.service_ids[0],
                                                interface=interface,
                                                url=url, region=region,
                                                enabled=True)['endpoint']
 
-        self.setup_endpoints.append(endpoint)
+        self.setup_endpoint_ids.append(endpoint['id'])
         # Asserting Create Endpoint response body
         self.assertIn('id', endpoint)
         self.assertEqual(region, endpoint['region'])
@@ -93,7 +130,7 @@
         fetched_endpoint = (
             self.client.show_endpoint(endpoint['id'])['endpoint'])
         # Asserting if the attributes of endpoint are the same
-        self.assertEqual(self.service_id, fetched_endpoint['service_id'])
+        self.assertEqual(self.service_ids[0], fetched_endpoint['service_id'])
         self.assertEqual(interface, fetched_endpoint['interface'])
         self.assertEqual(url, fetched_endpoint['url'])
         self.assertEqual(region, fetched_endpoint['region'])
@@ -101,7 +138,7 @@
 
         # Deleting the endpoint created in this method
         self.client.delete_endpoint(endpoint['id'])
-        self.setup_endpoints.remove(endpoint)
+        self.setup_endpoint_ids.remove(endpoint['id'])
 
         # Checking whether endpoint is deleted successfully
         fetched_endpoints = self.client.list_endpoints()['endpoints']
@@ -117,7 +154,7 @@
         url1 = data_utils.rand_url()
         interface1 = 'public'
         endpoint_for_update = (
-            self.client.create_endpoint(service_id=self.service_id,
+            self.client.create_endpoint(service_id=self.service_ids[0],
                                         interface=interface1,
                                         url=url1, region=region1,
                                         enabled=True)['endpoint'])
@@ -126,11 +163,8 @@
         s_name = data_utils.rand_name('service')
         s_type = data_utils.rand_name('type')
         s_description = data_utils.rand_name('description')
-        service2 = (
-            self.services_client.create_service(name=s_name, type=s_type,
-                                                description=s_description))
-        service2 = service2['service']
-        self.service_ids.append(service2['id'])
+        service2 = self._create_service(s_name=s_name, s_type=s_type,
+                                        s_description=s_description)
         # Updating endpoint with new values
         region2 = data_utils.rand_name('region')
         url2 = data_utils.rand_url()
diff --git a/tempest/lib/services/identity/v3/endpoints_client.py b/tempest/lib/services/identity/v3/endpoints_client.py
index 91592de..e24dca7 100644
--- a/tempest/lib/services/identity/v3/endpoints_client.py
+++ b/tempest/lib/services/identity/v3/endpoints_client.py
@@ -18,6 +18,7 @@
 """
 
 from oslo_serialization import jsonutils as json
+from six.moves.urllib import parse as urllib
 
 from tempest.lib.common import rest_client
 
@@ -25,9 +26,17 @@
 class EndPointsClient(rest_client.RestClient):
     api_version = "v3"
 
-    def list_endpoints(self):
-        """GET endpoints."""
-        resp, body = self.get('endpoints')
+    def list_endpoints(self, **params):
+        """List endpoints.
+
+        For a full list of available parameters, please refer to the official
+        API reference:
+        http://developer.openstack.org/api-ref/identity/v3/#list-endpoints
+        """
+        url = 'endpoints'
+        if params:
+            url += '?%s' % urllib.urlencode(params)
+        resp, body = self.get(url)
         self.expected_success(200, resp.status)
         body = json.loads(body)
         return rest_client.ResponseBody(resp, body)
diff --git a/tempest/tests/lib/services/identity/v3/test_endpoints_client.py b/tempest/tests/lib/services/identity/v3/test_endpoints_client.py
index f8c553f..ca15dd1 100644
--- a/tempest/tests/lib/services/identity/v3/test_endpoints_client.py
+++ b/tempest/tests/lib/services/identity/v3/test_endpoints_client.py
@@ -53,6 +53,8 @@
         ]
     }
 
+    FAKE_SERVICE_ID = "a4dc5060-f757-4662-b658-edd2aefbb41d"
+
     def setUp(self):
         super(TestEndpointsClient, self).setUp()
         fake_auth = fake_auth_provider.FakeAuthProvider()
@@ -72,12 +74,15 @@
             adminurl="https://compute.north.internal.com/v1",
             internalurl="https://compute.north.internal.com/v1")
 
-    def _test_list_endpoints(self, bytes_body=False):
+    def _test_list_endpoints(self, bytes_body=False, mock_args='endpoints',
+                             **params):
         self.check_service_client_function(
             self.client.list_endpoints,
             'tempest.lib.common.rest_client.RestClient.get',
             self.FAKE_LIST_ENDPOINTS,
-            bytes_body)
+            bytes_body,
+            mock_args=[mock_args],
+            **params)
 
     def test_create_endpoint_with_str_body(self):
         self._test_create_endpoint()
@@ -91,6 +96,16 @@
     def test_list_endpoints_with_bytes_body(self):
         self._test_list_endpoints(bytes_body=True)
 
+    def test_list_endpoints_with_params(self):
+        # Run the test separately for each param, to avoid assertion error
+        # resulting from randomized params order.
+        mock_args = 'endpoints?service_id=%s' % self.FAKE_SERVICE_ID
+        self._test_list_endpoints(mock_args=mock_args,
+                                  service_id=self.FAKE_SERVICE_ID)
+
+        mock_args = 'endpoints?interface=public'
+        self._test_list_endpoints(mock_args=mock_args, interface='public')
+
     def test_delete_endpoint(self):
         self.check_service_client_function(
             self.client.delete_endpoint,
diff --git a/tempest/tests/lib/services/volume/v2/test_scheduler_stats_client.py b/tempest/tests/lib/services/volume/v2/test_scheduler_stats_client.py
new file mode 100644
index 0000000..8a5f25f
--- /dev/null
+++ b/tempest/tests/lib/services/volume/v2/test_scheduler_stats_client.py
@@ -0,0 +1,83 @@
+# Copyright 2017 AT&T Corporation.
+# All Rights Reserved.
+#
+#    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.lib.services.volume.v2 import scheduler_stats_client
+from tempest.tests.lib import fake_auth_provider
+from tempest.tests.lib.services import base
+
+
+class TestSchedulerStatsClient(base.BaseServiceTest):
+    FAKE_POOLS_LIST = {
+        "pools": [
+            {
+                "name": "pool1",
+                "capabilities": {
+                    "updated": "2014-10-28T00:00:00-00:00",
+                    "total_capacity": 1024,
+                    "free_capacity": 100,
+                    "volume_backend_name": "pool1",
+                    "reserved_percentage": 0,
+                    "driver_version": "1.0.0",
+                    "storage_protocol": "iSCSI",
+                    "QoS_support": False
+                }
+            },
+            {
+                "name": "pool2",
+                "capabilities": {
+                    "updated": "2014-10-28T00:00:00-00:00",
+                    "total_capacity": 512,
+                    "free_capacity": 200,
+                    "volume_backend_name": "pool2",
+                    "reserved_percentage": 0,
+                    "driver_version": "1.0.2",
+                    "storage_protocol": "iSER",
+                    "QoS_support": True
+                }
+            }
+        ]
+    }
+
+    def setUp(self):
+        super(TestSchedulerStatsClient, self).setUp()
+        fake_auth = fake_auth_provider.FakeAuthProvider()
+        self.client = scheduler_stats_client.SchedulerStatsClient(
+            fake_auth, 'volume', 'regionOne')
+
+    def _test_list_pools(self, bytes_body=False, detail=False):
+        resp_body = []
+        if detail:
+            resp_body = self.FAKE_POOLS_LIST
+        else:
+            resp_body = {'pools': [{'name': pool['name']}
+                         for pool in self.FAKE_POOLS_LIST['pools']]}
+        self.check_service_client_function(
+            self.client.list_pools,
+            'tempest.lib.common.rest_client.RestClient.get',
+            resp_body,
+            bytes_body,
+            detail=detail)
+
+    def test_list_pools_with_str_body(self):
+        self._test_list_pools()
+
+    def test_list_pools_with_str_body_and_detail(self):
+        self._test_list_pools(detail=True)
+
+    def test_list_pools_with_bytes_body(self):
+        self._test_list_pools(bytes_body=True)
+
+    def test_list_pools_with_bytes_body_and_detail(self):
+        self._test_list_pools(bytes_body=True, detail=True)
diff --git a/tools/generate-tempest-plugins-list.py b/tools/generate-tempest-plugins-list.py
index a33962b..5e63c0d 100644
--- a/tools/generate-tempest-plugins-list.py
+++ b/tools/generate-tempest-plugins-list.py
@@ -26,12 +26,8 @@
 import json
 import re
 
-try:
-    # For Python 3.0 and later
-    import urllib
-except ImportError:
-    # Fall back to Python 2's urllib2
-    import urllib2 as urllib
+from six.moves import urllib
+
 
 url = 'https://review.openstack.org/projects/'
 
@@ -55,18 +51,18 @@
 
 def has_tempest_plugin(proj):
     try:
-        r = urllib.urlopen("https://git.openstack.org/cgit/%s/plain/setup.cfg"
-                           % proj)
-    except urllib.HTTPError as err:
+        r = urllib.request.urlopen(
+            "https://git.openstack.org/cgit/%s/plain/setup.cfg" % proj)
+    except urllib.error.HTTPError as err:
         if err.code == 404:
             return False
     p = re.compile('^tempest\.test_plugins', re.M)
-    if p.findall(r.read()):
+    if p.findall(r.read().decode('utf-8')):
         return True
     else:
         False
 
-r = urllib.urlopen(url)
+r = urllib.request.urlopen(url)
 # Gerrit prepends 4 garbage octets to the JSON, in order to counter
 # cross-site scripting attacks.  Therefore we must discard it so the
 # json library won't choke.