Add a test for filtering list servers for a specific tenant
Includes testing the odd specified behavior where 'all_tenants' is also
required when using 'tenant_id'.
Change-Id: Ie67ad0ec6193b8ab3eeb1c8464193ab6036c1bda
diff --git a/tempest/api/compute/admin/test_servers.py b/tempest/api/compute/admin/test_servers.py
index e3477f1..5210077 100644
--- a/tempest/api/compute/admin/test_servers.py
+++ b/tempest/api/compute/admin/test_servers.py
@@ -79,6 +79,24 @@
self.assertIn(self.s2_name, servers_name)
@test.attr(type='gate')
+ def test_list_servers_by_admin_with_specified_tenant(self):
+ # In nova v2, tenant_id is ignored unless all_tenants is specified
+
+ # List the primary tenant but get nothing due to odd specified behavior
+ tenant_id = self.non_admin_client.tenant_id
+ params = {'tenant_id': tenant_id}
+ resp, body = self.client.list_servers_with_detail(params)
+ servers = body['servers']
+ self.assertEqual([], servers)
+
+ # List the admin tenant which has no servers
+ admin_tenant_id = self.client.tenant_id
+ params = {'all_tenants': '', 'tenant_id': admin_tenant_id}
+ resp, body = self.client.list_servers_with_detail(params)
+ servers = body['servers']
+ self.assertEqual([], servers)
+
+ @test.attr(type='gate')
def test_list_servers_filter_by_exist_host(self):
# Filter the list of servers by existent host
name = data_utils.rand_name('server')