Deprecate list_servers_on_hypervisor and search_hypervisor in v253

list_servers_on_hypervisor and search_hypervisor are deprecated starting
with microversion 2.53, so running tests using these interfaces will
get 404 error starting from microversion 2.53.

This is to limit these testcases to max_microversion = '2.52'.

For more information, please see:
https://developer.openstack.org/api-ref/compute/#list-hypervisor-servers
https://developer.openstack.org/api-ref/compute/#search-hypervisor

Change-Id: I877d3ce705f89beeed3c9d70ecba4b917e138f4c
This commit is contained in:
zhufl
2018-02-07 14:26:49 +08:00
parent 72502cd1ef
commit 021e66b31d
2 changed files with 56 additions and 40 deletions

View File

@@ -17,12 +17,12 @@ from tempest.api.compute import base
from tempest.lib import decorators
class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
class HypervisorAdminTestBase(base.BaseV2ComputeAdminTest):
"""Tests Hypervisors API that require admin privileges"""
@classmethod
def setup_clients(cls):
super(HypervisorAdminTestJSON, cls).setup_clients()
super(HypervisorAdminTestBase, cls).setup_clients()
cls.client = cls.os_admin.hypervisor_client
def _list_hypervisors(self):
@@ -30,6 +30,10 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
hypers = self.client.list_hypervisors()['hypervisors']
return hypers
class HypervisorAdminTestJSON(HypervisorAdminTestBase):
"""Tests Hypervisors API that require admin privileges"""
@decorators.idempotent_id('7f0ceacd-c64d-4e96-b8ee-d02943142cc5')
def test_get_hypervisor_list(self):
# List of hypervisor and available hypervisors hostname
@@ -53,17 +57,6 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
self.assertEqual(details['hypervisor_hostname'],
hypers[0]['hypervisor_hostname'])
@decorators.idempotent_id('e81bba3f-6215-4e39-a286-d52d2f906862')
def test_get_hypervisor_show_servers(self):
# Show instances about the specific hypervisors
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers, "No hypervisors found.")
hostname = hypers[0]['hypervisor_hostname']
hypervisors = (self.client.list_servers_on_hypervisor(hostname)
['hypervisors'])
self.assertNotEmpty(hypervisors)
@decorators.idempotent_id('797e4f28-b6e0-454d-a548-80cc77c00816')
def test_get_hypervisor_stats(self):
# Verify the stats of the all hypervisor
@@ -110,6 +103,21 @@ class HypervisorAdminTestJSON(base.BaseV2ComputeAdminTest):
has_valid_uptime,
"None of the hypervisors had a valid uptime: %s" % hypers)
class HypervisorAdminUnderV252Test(HypervisorAdminTestBase):
max_microversion = '2.52'
@decorators.idempotent_id('e81bba3f-6215-4e39-a286-d52d2f906862')
def test_get_hypervisor_show_servers(self):
# Show instances about the specific hypervisors
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers, "No hypervisors found.")
hostname = hypers[0]['hypervisor_hostname']
hypervisors = (self.client.list_servers_on_hypervisor(hostname)
['hypervisors'])
self.assertNotEmpty(hypervisors)
@decorators.idempotent_id('d7e1805b-3b14-4a3b-b6fd-50ec6d9f361f')
def test_search_hypervisor(self):
hypers = self._list_hypervisors()

View File

@@ -19,12 +19,12 @@ from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
class HypervisorAdminNegativeTestBase(base.BaseV2ComputeAdminTest):
"""Tests Hypervisors API that require admin privileges"""
@classmethod
def setup_clients(cls):
super(HypervisorAdminNegativeTestJSON, cls).setup_clients()
super(HypervisorAdminNegativeTestBase, cls).setup_clients()
cls.client = cls.os_admin.hypervisor_client
cls.non_adm_client = cls.hypervisor_client
@@ -33,6 +33,10 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
hypers = self.client.list_hypervisors()['hypervisors']
return hypers
class HypervisorAdminNegativeTestJSON(HypervisorAdminNegativeTestBase):
"""Tests Hypervisors API that require admin privileges"""
@decorators.attr(type=['negative'])
@decorators.idempotent_id('c136086a-0f67-4b2b-bc61-8482bd68989f')
def test_show_nonexistent_hypervisor(self):
@@ -54,27 +58,6 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
self.non_adm_client.show_hypervisor,
hypers[0]['id'])
@decorators.attr(type=['negative'])
@decorators.idempotent_id('2a0a3938-832e-4859-95bf-1c57c236b924')
def test_show_servers_with_non_admin_user(self):
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers)
self.assertRaises(
lib_exc.Forbidden,
self.non_adm_client.list_servers_on_hypervisor,
hypers[0]['id'])
@decorators.attr(type=['negative'])
@decorators.idempotent_id('02463d69-0ace-4d33-a4a8-93d7883a2bba')
def test_show_servers_with_nonexistent_hypervisor(self):
nonexistent_hypervisor_id = data_utils.rand_uuid()
self.assertRaises(
lib_exc.NotFound,
self.client.list_servers_on_hypervisor,
nonexistent_hypervisor_id)
@decorators.attr(type=['negative'])
@decorators.idempotent_id('e2b061bb-13f9-40d8-9d6e-d5bf17595849')
def test_get_hypervisor_stats_with_non_admin_user(self):
@@ -119,13 +102,30 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
lib_exc.Forbidden,
self.non_adm_client.list_hypervisors, detail=True)
class HypervisorAdminNegativeUnderV252Test(HypervisorAdminNegativeTestBase):
max_microversion = '2.52'
@decorators.attr(type=['negative'])
@decorators.idempotent_id('19a45cc1-1000-4055-b6d2-28e8b2ec4faa')
def test_search_nonexistent_hypervisor(self):
@decorators.idempotent_id('2a0a3938-832e-4859-95bf-1c57c236b924')
def test_show_servers_with_non_admin_user(self):
hypers = self._list_hypervisors()
self.assertNotEmpty(hypers)
self.assertRaises(
lib_exc.Forbidden,
self.non_adm_client.list_servers_on_hypervisor,
hypers[0]['id'])
@decorators.attr(type=['negative'])
@decorators.idempotent_id('02463d69-0ace-4d33-a4a8-93d7883a2bba')
def test_show_servers_with_nonexistent_hypervisor(self):
nonexistent_hypervisor_id = data_utils.rand_uuid()
self.assertRaises(
lib_exc.NotFound,
self.client.search_hypervisor,
'nonexistent_hypervisor_name')
self.client.list_servers_on_hypervisor,
nonexistent_hypervisor_id)
@decorators.attr(type=['negative'])
@decorators.idempotent_id('5b6a6c79-5dc1-4fa5-9c58-9c8085948e74')
@@ -137,3 +137,11 @@ class HypervisorAdminNegativeTestJSON(base.BaseV2ComputeAdminTest):
lib_exc.Forbidden,
self.non_adm_client.search_hypervisor,
hypers[0]['hypervisor_hostname'])
@decorators.attr(type=['negative'])
@decorators.idempotent_id('19a45cc1-1000-4055-b6d2-28e8b2ec4faa')
def test_search_nonexistent_hypervisor(self):
self.assertRaises(
lib_exc.NotFound,
self.client.search_hypervisor,
'nonexistent_hypervisor_name')