replace disable/enable_service with update_service

The Nova version Watcher neede is at least 2.56
Starting with microversion 2.53 disable/enable API
is superseded by PUT /os-services/{service_id}[1]

Depends-on: If21b0df50e2f2cc2884f531cb40084e95a688026
[1]:https://docs.openstack.org/api-ref/compute/?expanded=update-compute-service-detail,disable-scheduling-for-a-compute-service-detail#update-compute-service

Change-Id: If3366db5cc49ced522e30f75e7f85b8671b947bd
This commit is contained in:
licanwei 2019-08-19 13:45:45 +08:00
parent 9f7d7812bc
commit 4d6b4b3b49
2 changed files with 26 additions and 21 deletions

View File

@ -27,6 +27,7 @@ from datetime import timedelta
from oslo_log import log from oslo_log import log
from tempest.common import waiters from tempest.common import waiters
from tempest import config from tempest import config
from tempest.lib.common import api_microversion_fixture
from tempest.lib.common.utils import data_utils from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils from tempest.lib.common.utils import test_utils
from tempest.lib import exceptions from tempest.lib import exceptions
@ -60,6 +61,11 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
cls.client = cls.mgr.io_client cls.client = cls.mgr.io_client
cls.gnocchi = cls.mgr.gn_client cls.gnocchi = cls.mgr.gn_client
def setUp(self):
super(BaseInfraOptimScenarioTest, self).setUp()
self.useFixture(api_microversion_fixture.APIMicroversionFixture(
compute_microversion=CONF.compute.min_microversion))
@classmethod @classmethod
def resource_setup(cls): def resource_setup(cls):
super(BaseInfraOptimScenarioTest, cls).resource_setup() super(BaseInfraOptimScenarioTest, cls).resource_setup()
@ -121,11 +127,13 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
] ]
initial_cn_setup = matching_cns[0] # Should return a single result initial_cn_setup = matching_cns[0] # Should return a single result
if cn_setup.get('status') != initial_cn_setup.get('status'): if cn_setup.get('status') != initial_cn_setup.get('status'):
if initial_cn_setup.get('status') == 'enabled': svr_id = cn_setup.get('id')
rollback_func = cls.mgr.services_client.enable_service status = initial_cn_setup.get('status')
else: # The Nova version Watcher neede is at least 2.56
rollback_func = cls.mgr.services_client.disable_service # Starting with microversion 2.53 disable/enable API
rollback_func(binary='nova-compute', host=cn_hostname) # is superseded by PUT /os-services/{service_id}
rollback_func = cls.mgr.services_client.update_service
rollback_func(svr_id, status=status)
@classmethod @classmethod
def wait_for(cls, condition, timeout=30): def wait_for(cls, condition, timeout=30):
@ -155,20 +163,16 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
sleep_for=5 sleep_for=5
) )
def _migrate_server_to(self, server_id, dest_host, volume_backed=False): def _migrate_server_to(self, server_id, dest_host):
kwargs = dict() # The default value of block_migration is auto and
kwargs['disk_over_commit'] = False # disk_over_commit is not valid after version 2.25
block_migration = (CONF.compute_feature_enabled. block_migration = 'auto'
block_migration_for_live_migration and
not volume_backed)
body = self.mgr.servers_client.live_migrate_server( body = self.mgr.servers_client.live_migrate_server(
server_id, host=dest_host, block_migration=block_migration, server_id, host=dest_host, block_migration=block_migration)
**kwargs)
return body return body
def _live_migrate(self, server_id, target_host, state, def _live_migrate(self, server_id, target_host, state):
volume_backed=False): self._migrate_server_to(server_id, target_host)
self._migrate_server_to(server_id, target_host, volume_backed)
waiters.wait_for_server_status(self.servers_client, server_id, state) waiters.wait_for_server_status(self.servers_client, server_id, state)
migration_list = (self.mgr.migrations_client.list_migrations() migration_list = (self.mgr.migrations_client.list_migrations()
['migrations']) ['migrations'])
@ -309,8 +313,9 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
:param instance: Instance response body :param instance: Instance response body
:param metrics: The metrics add to resource when using Gnocchi :param metrics: The metrics add to resource when using Gnocchi
""" """
flavor = self.flavors_client.show_flavor(instance['flavor']['id']) all_flavors = self.flavors_client.list_flavors()['flavors']
flavor_name = flavor['flavor']['name'] flavor_name = instance['flavor']['original_name']
flavor = [f for f in all_flavors if f['name'] == flavor_name]
if metrics == dict(): if metrics == dict():
metrics = { metrics = {
'cpu_util': { 'cpu_util': {
@ -323,7 +328,7 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest):
'host': instance.get('OS-EXT-SRV-ATTR:hypervisor_hostname'), 'host': instance.get('OS-EXT-SRV-ATTR:hypervisor_hostname'),
'display_name': instance.get('OS-EXT-SRV-ATTR:instance_name'), 'display_name': instance.get('OS-EXT-SRV-ATTR:instance_name'),
'image_ref': instance['image']['id'], 'image_ref': instance['image']['id'],
'flavor_id': instance['flavor']['id'], 'flavor_id': flavor[0]['id'],
'flavor_name': flavor_name, 'flavor_name': flavor_name,
'id': instance['id'] 'id': instance['id']
} }

View File

@ -101,10 +101,10 @@ class TestExecuteActionsViaActuator(base.BaseInfraOptimScenarioTest):
def _prerequisite_param_for_resize_action(self): def _prerequisite_param_for_resize_action(self):
created_instances = self._create_one_instance_per_host_with_statistic() created_instances = self._create_one_instance_per_host_with_statistic()
instance = created_instances[0] instance = created_instances[0]
current_flavor_id = instance['flavor']['id'] current_flavor_name = instance['flavor']['original_name']
flavors = self._get_flavors() flavors = self._get_flavors()
new_flavors = [f for f in flavors if f['id'] != current_flavor_id] new_flavors = [f for f in flavors if f['name'] != current_flavor_name]
new_flavor = new_flavors[0] new_flavor = new_flavors[0]
parameters = { parameters = {