Clean cluster status definition in cluster module
This patch cleans cluster status definition in cluster module. This definition is now maintained in consts module. Change-Id: Idb6b421e5da2992524a711f69ddc9f380a1cd974
This commit is contained in:
parent
87ac1770cb
commit
e567237c44
|
@ -191,7 +191,7 @@ class ClusterAction(base.Action):
|
|||
|
||||
if not res:
|
||||
reason = _('Cluster creation failed.')
|
||||
self.cluster.set_status(self.context, self.cluster.ERROR, reason)
|
||||
self.cluster.set_status(self.context, consts.CS_ERROR, reason)
|
||||
return self.RES_ERROR, reason
|
||||
|
||||
result, reason = self._create_nodes(self.cluster.desired_capacity)
|
||||
|
@ -272,7 +272,7 @@ class ClusterAction(base.Action):
|
|||
res = self.cluster.do_update(self.context)
|
||||
if not res:
|
||||
reason = _('Cluster update failed.')
|
||||
self.cluster.set_status(self.context, self.cluster.ERROR, reason)
|
||||
self.cluster.set_status(self.context, consts.CS_ERROR, reason)
|
||||
return self.RES_ERROR, reason
|
||||
|
||||
name = self.inputs.get('name')
|
||||
|
@ -344,7 +344,7 @@ class ClusterAction(base.Action):
|
|||
:returns: A tuple containing the result and the corresponding reason.
|
||||
"""
|
||||
reason = _('Deletion in progress.')
|
||||
self.cluster.set_status(self.context, self.cluster.DELETING, reason)
|
||||
self.cluster.set_status(self.context, consts.CS_DELETING, reason)
|
||||
node_ids = [node.id for node in self.cluster.nodes]
|
||||
|
||||
# For cluster delete, we delete the nodes
|
||||
|
@ -682,7 +682,7 @@ class ClusterAction(base.Action):
|
|||
kwargs['min_size'] = min_size
|
||||
if max_size is not None:
|
||||
kwargs['max_size'] = max_size
|
||||
self.cluster.set_status(self.context, self.cluster.RESIZING,
|
||||
self.cluster.set_status(self.context, consts.CS_RESIZING,
|
||||
_('Cluster resize started.'), **kwargs)
|
||||
|
||||
@profiler.trace('ClusterAction.do_resize', hide_args=False)
|
||||
|
@ -759,7 +759,7 @@ class ClusterAction(base.Action):
|
|||
if result:
|
||||
return self.RES_ERROR, result
|
||||
|
||||
self.cluster.set_status(self.context, self.cluster.RESIZING,
|
||||
self.cluster.set_status(self.context, consts.CS_RESIZING,
|
||||
_('Cluster scale out started.'),
|
||||
desired_capacity=new_size)
|
||||
|
||||
|
@ -811,7 +811,7 @@ class ClusterAction(base.Action):
|
|||
if result:
|
||||
return self.RES_ERROR, result
|
||||
|
||||
self.cluster.set_status(self.context, self.cluster.RESIZING,
|
||||
self.cluster.set_status(self.context, consts.CS_RESIZING,
|
||||
_('Cluster scale in started.'),
|
||||
desired_capacity=new_size)
|
||||
|
||||
|
|
|
@ -39,14 +39,6 @@ class Cluster(object):
|
|||
executed.
|
||||
"""
|
||||
|
||||
STATUSES = (
|
||||
INIT, ACTIVE, CREATING, UPDATING, RESIZING, DELETING,
|
||||
CHECKING, RECOVERING, CRITICAL, ERROR, WARNING,
|
||||
) = (
|
||||
'INIT', 'ACTIVE', 'CREATING', 'UPDATING', 'RESIZING', 'DELETING',
|
||||
'CHECKING', 'RECOVERING', 'CRITICAL', 'ERROR', 'WARNING',
|
||||
)
|
||||
|
||||
def __init__(self, name, desired_capacity, profile_id,
|
||||
context=None, **kwargs):
|
||||
'''Initialize a cluster object.
|
||||
|
@ -76,7 +68,7 @@ class Cluster(object):
|
|||
self.timeout = (kwargs.get('timeout') or
|
||||
cfg.CONF.default_action_timeout)
|
||||
|
||||
self.status = kwargs.get('status', self.INIT)
|
||||
self.status = kwargs.get('status', consts.CS_INIT)
|
||||
self.status_reason = kwargs.get('status_reason', 'Initializing')
|
||||
self.data = kwargs.get('data', {})
|
||||
self.metadata = kwargs.get('metadata') or {}
|
||||
|
@ -247,11 +239,11 @@ class Cluster(object):
|
|||
|
||||
values = {}
|
||||
now = timeutils.utcnow(True)
|
||||
if status == self.ACTIVE and self.status == self.CREATING:
|
||||
if status == consts.CS_ACTIVE and self.status == consts.CS_CREATING:
|
||||
self.created_at = now
|
||||
values['created_at'] = now
|
||||
elif (status == self.ACTIVE and
|
||||
self.status in (self.UPDATING, self.RESIZING)):
|
||||
elif (status == consts.CS_ACTIVE and
|
||||
self.status in (consts.CS_UPDATING, consts.CS_RESIZING)):
|
||||
self.updated_at = now
|
||||
values['updated_at'] = now
|
||||
|
||||
|
@ -288,11 +280,11 @@ class Cluster(object):
|
|||
|
||||
Set cluster status to CREATING.
|
||||
'''
|
||||
if self.status != self.INIT:
|
||||
if self.status != consts.CS_INIT:
|
||||
LOG.error(_LE('Cluster is in status "%s"'), self.status)
|
||||
return False
|
||||
|
||||
self.set_status(context, self.CREATING, _('Creation in progress'))
|
||||
self.set_status(context, consts.CS_CREATING, _('Creation in progress'))
|
||||
return True
|
||||
|
||||
def do_delete(self, context, **kwargs):
|
||||
|
@ -306,7 +298,7 @@ class Cluster(object):
|
|||
|
||||
This method is intended to be called only from an action.
|
||||
'''
|
||||
self.set_status(context, self.UPDATING, _('Update in progress'))
|
||||
self.set_status(context, consts.CS_UPDATING, _('Update in progress'))
|
||||
return True
|
||||
|
||||
def do_check(self, context, **kwargs):
|
||||
|
@ -314,7 +306,7 @@ class Cluster(object):
|
|||
|
||||
Set cluster status to CHECKING.
|
||||
"""
|
||||
self.set_status(context, self.CHECKING, _('Check in progress'))
|
||||
self.set_status(context, consts.CS_CHECKING, _('Check in progress'))
|
||||
return True
|
||||
|
||||
def do_recover(self, context, **kwargs):
|
||||
|
@ -322,7 +314,8 @@ class Cluster(object):
|
|||
|
||||
Set cluster status to RECOVERING.
|
||||
'''
|
||||
self.set_status(context, self.RECOVERING, _('Recovery in progress'))
|
||||
self.set_status(context, consts.CS_RECOVERING,
|
||||
_('Recovery in progress'))
|
||||
return True
|
||||
|
||||
def attach_policy(self, ctx, policy_id, values):
|
||||
|
@ -547,21 +540,21 @@ class Cluster(object):
|
|||
|
||||
values = params or {}
|
||||
if active_count < min_size:
|
||||
status = self.ERROR
|
||||
status = consts.CS_ERROR
|
||||
reason = _("%(o)s: number of active nodes is below min_size "
|
||||
"(%(n)d).") % {'o': operation, 'n': min_size}
|
||||
elif active_count < desired:
|
||||
status = self.WARNING
|
||||
status = consts.CS_WARNING
|
||||
reason = _("%(o)s: number of active nodes is below "
|
||||
"desired_capacity "
|
||||
"(%(n)d).") % {'o': operation, 'n': desired}
|
||||
elif max_size < 0 or active_count <= max_size:
|
||||
status = self.ACTIVE
|
||||
status = consts.CS_ACTIVE
|
||||
reason = _("%(o)s: number of active nodes is above "
|
||||
"desired_capacity "
|
||||
"(%(n)d).") % {'o': operation, 'n': desired}
|
||||
else:
|
||||
status = self.WARNING
|
||||
status = consts.CS_WARNING
|
||||
reason = _("%(o)s: number of active nodes is above max_size "
|
||||
"(%(n)d).") % {'o': operation, 'n': max_size}
|
||||
|
||||
|
|
|
@ -897,7 +897,7 @@ class EngineService(service.Service):
|
|||
"""
|
||||
db_cluster = self.cluster_find(ctx, req.identity)
|
||||
cluster = cluster_mod.Cluster.load(ctx, dbcluster=db_cluster)
|
||||
if cluster.status == cluster.ERROR:
|
||||
if cluster.status == consts.CS_ERROR:
|
||||
msg = _('Updating a cluster in error state')
|
||||
LOG.error(msg)
|
||||
raise exception.FeatureNotSupported(feature=msg)
|
||||
|
@ -963,10 +963,10 @@ class EngineService(service.Service):
|
|||
# 'cluster' below is a DB object.
|
||||
cluster = self.cluster_find(context, identity)
|
||||
|
||||
if cluster.status in [cluster_mod.Cluster.CREATING,
|
||||
cluster_mod.Cluster.UPDATING,
|
||||
cluster_mod.Cluster.DELETING,
|
||||
cluster_mod.Cluster.RECOVERING]:
|
||||
if cluster.status in [consts.CS_CREATING,
|
||||
consts.CS_UPDATING,
|
||||
consts.CS_DELETING,
|
||||
consts.CS_RECOVERING]:
|
||||
raise exception.ActionInProgress(type='cluster', id=identity,
|
||||
status=cluster.status)
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
import mock
|
||||
|
||||
from senlin.common import consts
|
||||
from senlin.common import scaleutils
|
||||
from senlin.engine.actions import base as ab
|
||||
from senlin.engine.actions import cluster_action as ca
|
||||
|
@ -312,7 +313,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
action.context, action.CLUSTER_CREATE, created_at=mock.ANY)
|
||||
|
||||
def test_do_create_failed_create_cluster(self, mock_load):
|
||||
cluster = mock.Mock(id='FAKE_CLUSTER', ERROR='ERROR')
|
||||
cluster = mock.Mock(id='FAKE_CLUSTER')
|
||||
cluster.do_create.return_value = False
|
||||
mock_load.return_value = cluster
|
||||
action = ca.ClusterAction(cluster.id, 'CLUSTER_ACTION', self.ctx)
|
||||
|
@ -326,7 +327,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
action.context, 'ERROR', 'Cluster creation failed.')
|
||||
|
||||
def test_do_create_failed_create_nodes(self, mock_load):
|
||||
cluster = mock.Mock(id='FAKE_ID', ERROR='ERROR')
|
||||
cluster = mock.Mock(id='FAKE_ID',)
|
||||
cluster.do_create.return_value = True
|
||||
mock_load.return_value = cluster
|
||||
action = ca.ClusterAction(cluster.id, 'CLUSTER_ACTION', self.ctx)
|
||||
|
@ -1716,7 +1717,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
action._update_cluster_size(15)
|
||||
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster resize started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster resize started.',
|
||||
desired_capacity=15, min_size=1, max_size=20)
|
||||
|
||||
def test__update_cluster_size_minimum(self, mock_load):
|
||||
|
@ -1728,7 +1729,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
action._update_cluster_size(15)
|
||||
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster resize started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster resize started.',
|
||||
desired_capacity=15)
|
||||
|
||||
@mock.patch.object(no.Node, 'count_by_cluster')
|
||||
|
@ -1962,7 +1963,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
mock_count.assert_called_once_with(action.context, 'CID')
|
||||
mock_create.assert_called_once_with(1)
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale out started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster scale out started.',
|
||||
desired_capacity=6)
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
action.context, action.CLUSTER_SCALE_OUT)
|
||||
|
@ -1989,7 +1990,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
mock_count.assert_called_once_with(action.context, 'CID')
|
||||
mock_create.assert_called_once_with(3)
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale out started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster scale out started.',
|
||||
desired_capacity=10)
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
action.context, action.CLUSTER_SCALE_OUT)
|
||||
|
@ -2017,7 +2018,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
mock_count.assert_called_once_with(action.context, 'CID')
|
||||
mock_create.assert_called_once_with(2)
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale out started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster scale out started.',
|
||||
desired_capacity=10)
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
action.context, action.CLUSTER_SCALE_OUT)
|
||||
|
@ -2095,7 +2096,8 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
self.assertEqual('Too hot to work!', res_msg)
|
||||
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale out started.',
|
||||
action.context, consts.CS_RESIZING,
|
||||
'Cluster scale out started.',
|
||||
desired_capacity=6)
|
||||
cluster.set_status.reset_mock()
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
|
@ -2141,7 +2143,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
mock_delete.assert_called_once_with(mock.ANY)
|
||||
mock_select.assert_called_once_with(cluster.nodes, 1)
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale in started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster scale in started.',
|
||||
desired_capacity=9)
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
action.context, action.CLUSTER_SCALE_IN)
|
||||
|
@ -2179,7 +2181,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
self.assertIn('NODE_ID_3', mock_delete.call_args[0][0])
|
||||
self.assertIn('NODE_ID_4', mock_delete.call_args[0][0])
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale in started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster scale in started.',
|
||||
desired_capacity=3)
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
action.context, action.CLUSTER_SCALE_IN)
|
||||
|
@ -2209,7 +2211,7 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
mock_delete.assert_called_once_with(mock.ANY)
|
||||
mock_select.assert_called_once_with(cluster.nodes, 3)
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale in started.',
|
||||
action.context, consts.CS_RESIZING, 'Cluster scale in started.',
|
||||
desired_capacity=8)
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
action.context, action.CLUSTER_SCALE_IN)
|
||||
|
@ -2285,7 +2287,8 @@ class ClusterActionTest(base.SenlinTestCase):
|
|||
self.assertEqual(result, res_code)
|
||||
self.assertEqual('Too cold to work!', res_msg)
|
||||
cluster.set_status.assert_called_once_with(
|
||||
action.context, cluster.RESIZING, 'Cluster scale in started.',
|
||||
action.context, consts.CS_RESIZING,
|
||||
'Cluster scale in started.',
|
||||
desired_capacity=3)
|
||||
cluster.eval_status.assert_called_once_with(
|
||||
action.context, action.CLUSTER_SCALE_IN)
|
||||
|
|
|
@ -190,8 +190,8 @@ class ClusterTest(base.SenlinTestCase):
|
|||
|
||||
@mock.patch.object(service.EngineService, 'cluster_find')
|
||||
def test_node_delete_improper_status(self, mock_find):
|
||||
for bad_status in [cm.Cluster.CREATING, cm.Cluster.UPDATING,
|
||||
cm.Cluster.DELETING, cm.Cluster.RECOVERING]:
|
||||
for bad_status in [consts.CS_CREATING, consts.CS_UPDATING,
|
||||
consts.CS_DELETING, consts.CS_RECOVERING]:
|
||||
fake_cluster = mock.Mock(id='12345678AB', status=bad_status)
|
||||
mock_find.return_value = fake_cluster
|
||||
ex = self.assertRaises(rpc.ExpectedException,
|
||||
|
@ -1111,7 +1111,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
def test_cluster_update2_cluster_bad_status(self, mock_find, mock_load):
|
||||
x_obj = mock.Mock()
|
||||
mock_find.return_value = x_obj
|
||||
x_cluster = mock.Mock(status='ERROR', ERROR='ERROR')
|
||||
x_cluster = mock.Mock(status='ERROR')
|
||||
mock_load.return_value = x_cluster
|
||||
req = {'identity': 'CLUSTER', 'name': 'new-name'}
|
||||
self._prepare_request(req)
|
||||
|
@ -1134,7 +1134,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
mock_profile):
|
||||
x_obj = mock.Mock()
|
||||
mock_find.return_value = x_obj
|
||||
mock_load.return_value = mock.Mock(status='ACTIVE', ERROR='ERROR',
|
||||
mock_load.return_value = mock.Mock(status='ACTIVE',
|
||||
profile_id='OLD_ID')
|
||||
mock_profile.side_effect = [
|
||||
mock.Mock(type='FAKE_TYPE', id='OLD_ID'),
|
||||
|
@ -1164,7 +1164,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
mock_profile):
|
||||
x_obj = mock.Mock()
|
||||
mock_find.return_value = x_obj
|
||||
mock_load.return_value = mock.Mock(status='ACTIVE', ERROR='ERROR',
|
||||
mock_load.return_value = mock.Mock(status='ACTIVE',
|
||||
profile_id='OLD_ID')
|
||||
mock_profile.side_effect = [
|
||||
mock.Mock(type='FAKE_TYPE', id='OLD_ID'),
|
||||
|
@ -1267,7 +1267,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
def test_cluster_update2_no_property_updated(self, mock_find, mock_load):
|
||||
x_obj = mock.Mock()
|
||||
mock_find.return_value = x_obj
|
||||
mock_load.return_value = mock.Mock(status='ACTIVE', ERROR='ERROR',
|
||||
mock_load.return_value = mock.Mock(status='ACTIVE',
|
||||
profile_id='OLD_ID')
|
||||
req = orco.ClusterUpdateRequest(identity='CLUSTER')
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ from oslo_config import cfg
|
|||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from senlin.common import consts
|
||||
from senlin.common import exception
|
||||
from senlin.engine import cluster as cm
|
||||
from senlin.engine import cluster_policy as cpm
|
||||
|
@ -304,9 +305,9 @@ class TestCluster(base.SenlinTestCase):
|
|||
cluster = cm.Cluster('test-cluster', 0, PROFILE_ID,
|
||||
id=CLUSTER_ID, status='CREATING')
|
||||
|
||||
cluster.set_status(self.context, cluster.ACTIVE, 'Cluster created')
|
||||
cluster.set_status(self.context, consts.CS_ACTIVE, 'Cluster created')
|
||||
|
||||
self.assertEqual(cluster.ACTIVE, cluster.status)
|
||||
self.assertEqual(consts.CS_ACTIVE, cluster.status)
|
||||
self.assertEqual('Cluster created', cluster.status_reason)
|
||||
self.assertIsNotNone(cluster.created_at)
|
||||
self.assertIsNone(cluster.updated_at)
|
||||
|
@ -315,7 +316,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
self.context, CLUSTER_ID,
|
||||
{
|
||||
'created_at': mock.ANY,
|
||||
'status': cluster.ACTIVE,
|
||||
'status': consts.CS_ACTIVE,
|
||||
'status_reason': 'Cluster created'
|
||||
}
|
||||
)
|
||||
|
@ -325,9 +326,9 @@ class TestCluster(base.SenlinTestCase):
|
|||
cluster = cm.Cluster('test-cluster', 0, PROFILE_ID,
|
||||
id=CLUSTER_ID, status='UPDATING')
|
||||
|
||||
cluster.set_status(self.context, cluster.ACTIVE, 'Cluster updated')
|
||||
cluster.set_status(self.context, consts.CS_ACTIVE, 'Cluster updated')
|
||||
|
||||
self.assertEqual(cluster.ACTIVE, cluster.status)
|
||||
self.assertEqual(consts.CS_ACTIVE, cluster.status)
|
||||
self.assertEqual('Cluster updated', cluster.status_reason)
|
||||
self.assertIsNotNone(cluster.updated_at)
|
||||
|
||||
|
@ -336,9 +337,9 @@ class TestCluster(base.SenlinTestCase):
|
|||
cluster = cm.Cluster('test-cluster', 0, PROFILE_ID,
|
||||
id=CLUSTER_ID, status='RESIZING')
|
||||
|
||||
cluster.set_status(self.context, cluster.ACTIVE, 'Cluster resized')
|
||||
cluster.set_status(self.context, consts.CS_ACTIVE, 'Cluster resized')
|
||||
|
||||
self.assertEqual(cluster.ACTIVE, cluster.status)
|
||||
self.assertEqual(consts.CS_ACTIVE, cluster.status)
|
||||
self.assertEqual('Cluster resized', cluster.status_reason)
|
||||
self.assertIsNotNone(cluster.updated_at)
|
||||
|
||||
|
@ -352,10 +353,10 @@ class TestCluster(base.SenlinTestCase):
|
|||
status='UPDATING')
|
||||
|
||||
new_profile_id = 'a64f0b03-4b77-49d5-89e0-7bcc77c4ce67'
|
||||
cluster.set_status(self.context, cluster.ACTIVE, 'Cluster updated',
|
||||
cluster.set_status(self.context, consts.CS_ACTIVE, 'Cluster updated',
|
||||
profile_id=new_profile_id)
|
||||
|
||||
self.assertEqual(cluster.ACTIVE, cluster.status)
|
||||
self.assertEqual(consts.CS_ACTIVE, cluster.status)
|
||||
self.assertEqual('Cluster updated', cluster.status_reason)
|
||||
self.assertIsNotNone(cluster.updated_at)
|
||||
self.assertEqual(x_profile, cluster.rt['profile'])
|
||||
|
@ -365,7 +366,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{
|
||||
'status': cluster.ACTIVE,
|
||||
'status': consts.CS_ACTIVE,
|
||||
'status_reason': 'Cluster updated',
|
||||
'profile_id': new_profile_id,
|
||||
'updated_at': mock.ANY,
|
||||
|
@ -378,12 +379,12 @@ class TestCluster(base.SenlinTestCase):
|
|||
status='UPDATING',
|
||||
status_reason='Update in progress')
|
||||
|
||||
cluster.set_status(self.context, cluster.WARNING)
|
||||
cluster.set_status(self.context, consts.CS_WARNING)
|
||||
|
||||
self.assertEqual(cluster.WARNING, cluster.status)
|
||||
self.assertEqual(consts.CS_WARNING, cluster.status)
|
||||
self.assertEqual('Update in progress', cluster.status_reason)
|
||||
mock_update.assert_called_once_with(self.context, CLUSTER_ID,
|
||||
{'status': cluster.WARNING})
|
||||
{'status': consts.CS_WARNING})
|
||||
|
||||
@mock.patch.object(co.Cluster, 'update')
|
||||
def test_update_dependents(self, mock_update):
|
||||
|
@ -402,11 +403,11 @@ class TestCluster(base.SenlinTestCase):
|
|||
|
||||
self.assertTrue(res)
|
||||
mock_status.assert_called_once_with(
|
||||
self.context, cluster.CREATING, 'Creation in progress')
|
||||
self.context, consts.CS_CREATING, 'Creation in progress')
|
||||
|
||||
def test_do_create_wrong_status(self):
|
||||
cluster = cm.Cluster('test-cluster', 0, PROFILE_ID)
|
||||
cluster.status = cluster.ACTIVE
|
||||
cluster.status = consts.CS_ACTIVE
|
||||
|
||||
res = cluster.do_create(self.context)
|
||||
|
||||
|
@ -430,7 +431,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
|
||||
res = cluster.do_update(self.context)
|
||||
|
||||
mock_status.assert_called_once_with(self.context, cluster.UPDATING,
|
||||
mock_status.assert_called_once_with(self.context, consts.CS_UPDATING,
|
||||
'Update in progress')
|
||||
self.assertTrue(res)
|
||||
|
||||
|
@ -440,7 +441,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
|
||||
res = cluster.do_check(self.context)
|
||||
|
||||
mock_status.assert_called_once_with(self.context, cluster.CHECKING,
|
||||
mock_status.assert_called_once_with(self.context, consts.CS_CHECKING,
|
||||
'Check in progress')
|
||||
self.assertTrue(res)
|
||||
|
||||
|
@ -450,7 +451,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
|
||||
res = cluster.do_recover(self.context)
|
||||
|
||||
mock_status.assert_called_once_with(self.context, cluster.RECOVERING,
|
||||
mock_status.assert_called_once_with(self.context, consts.CS_RECOVERING,
|
||||
'Recovery in progress')
|
||||
self.assertTrue(res)
|
||||
|
||||
|
@ -856,7 +857,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_load.assert_called_once_with(self.context, cluster_id=CLUSTER_ID)
|
||||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'status': cluster.ERROR,
|
||||
{'status': consts.CS_ERROR,
|
||||
'status_reason': 'TEST: number of active nodes is below '
|
||||
'min_size (2).'})
|
||||
|
||||
|
@ -875,7 +876,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_load.assert_called_once_with(self.context, cluster_id=CLUSTER_ID)
|
||||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'status': cluster.WARNING,
|
||||
{'status': consts.CS_WARNING,
|
||||
'status_reason': 'TEST: number of active nodes is below '
|
||||
'desired_capacity (5).'})
|
||||
|
||||
|
@ -894,7 +895,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_load.assert_called_once_with(self.context, cluster_id=CLUSTER_ID)
|
||||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'status': cluster.ACTIVE,
|
||||
{'status': consts.CS_ACTIVE,
|
||||
'status_reason': 'TEST: number of active nodes is above '
|
||||
'desired_capacity (2).'})
|
||||
|
||||
|
@ -913,7 +914,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_load.assert_called_once_with(self.context, cluster_id=CLUSTER_ID)
|
||||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'status': cluster.WARNING,
|
||||
{'status': consts.CS_WARNING,
|
||||
'status_reason': 'TEST: number of active nodes is above '
|
||||
'max_size (2).'})
|
||||
|
||||
|
@ -932,7 +933,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'desired_capacity': 2,
|
||||
'status': cluster.WARNING,
|
||||
'status': consts.CS_WARNING,
|
||||
'status_reason': 'TEST: number of active nodes is below '
|
||||
'desired_capacity (2).'})
|
||||
|
||||
|
@ -951,7 +952,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'desired_capacity': 0,
|
||||
'status': cluster.ACTIVE,
|
||||
'status': consts.CS_ACTIVE,
|
||||
'status_reason': 'TEST: number of active nodes is above '
|
||||
'desired_capacity (0).'})
|
||||
|
||||
|
@ -971,7 +972,7 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'min_size': 2,
|
||||
'status': cluster.ERROR,
|
||||
'status': consts.CS_ERROR,
|
||||
'status_reason': 'TEST: number of active nodes is below '
|
||||
'min_size (2).'})
|
||||
|
||||
|
@ -991,6 +992,6 @@ class TestCluster(base.SenlinTestCase):
|
|||
mock_update.assert_called_once_with(
|
||||
self.context, CLUSTER_ID,
|
||||
{'max_size': 6,
|
||||
'status': cluster.ACTIVE,
|
||||
'status': consts.CS_ACTIVE,
|
||||
'status_reason': 'TEST: number of active nodes is above '
|
||||
'desired_capacity (2).'})
|
||||
|
|
Loading…
Reference in New Issue