Added a new test case for cluster_add_nodes
Nodes that are already owned by a cluster cannot be added to another cluster directly. Change-Id: I2b13f32d647909c4fa4b12056ff1dd25b174842d
This commit is contained in:
parent
d1ff9e350f
commit
e7d1868862
|
@ -50,6 +50,8 @@ class ClusterTest(base.SenlinTestCase):
|
|||
spec={'KEY1': 'string'}, cooldown=60, level=50)
|
||||
|
||||
def _verify_action(self, obj, action, name, target, cause, inputs=None):
|
||||
if inputs is None:
|
||||
inputs = {}
|
||||
self.assertEqual(action, obj['action'])
|
||||
self.assertEqual(name, obj['name'])
|
||||
self.assertEqual(target, obj['target'])
|
||||
|
@ -572,7 +574,7 @@ class ClusterTest(base.SenlinTestCase):
|
|||
# two calls: one for create, the other for adding nodes
|
||||
notify.assert_has_calls([expected_call] * 2)
|
||||
|
||||
def test_cluster_add_nodes_cluster_not_found(self, notify):
|
||||
def test_cluster_add_nodes_cluster_not_found(self):
|
||||
ex = self.assertRaises(rpc.ExpectedException,
|
||||
self.eng.cluster_add_nodes,
|
||||
self.ctx, 'Bogus', ['n1', 'n2'])
|
||||
|
@ -620,3 +622,36 @@ class ClusterTest(base.SenlinTestCase):
|
|||
msg = _("Nodes are not ACTIVE: %s") % nodes
|
||||
self.assertEqual(_("The request is malformed: %(msg)s") % {'msg': msg},
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
@mock.patch.object(dispatcher, 'notify')
|
||||
def test_cluster_add_nodes_node_already_owned(self, notify):
|
||||
c1 = self.eng.cluster_create(self.ctx, 'c-1', 0, self.profile['id'])
|
||||
cid1 = c1['id']
|
||||
c2 = self.eng.cluster_create(self.ctx, 'c-2', 0, self.profile['id'])
|
||||
cid2 = c2['id']
|
||||
nodes1 = self._prepare_nodes(self.ctx, count=1, cluster_id=cid1)
|
||||
nodes2 = self._prepare_nodes(self.ctx, count=1, cluster_id=cid2)
|
||||
|
||||
ex = self.assertRaises(rpc.ExpectedException,
|
||||
self.eng.cluster_add_nodes,
|
||||
self.ctx, cid1, nodes1)
|
||||
|
||||
# adding from the same cluster is not allowed
|
||||
self.assertEqual(exception.SenlinBadRequest, ex.exc_info[0])
|
||||
msg = _("Nodes %s owned by other cluster, need to delete them from "
|
||||
"those clusters first.") % nodes1
|
||||
self.assertEqual(_("The request is malformed: %(msg)s") % {'msg': msg},
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
ex = self.assertRaises(rpc.ExpectedException,
|
||||
self.eng.cluster_add_nodes,
|
||||
self.ctx, cid1, nodes2)
|
||||
|
||||
# adding from a different cluster is not allowed either
|
||||
self.assertEqual(exception.SenlinBadRequest, ex.exc_info[0])
|
||||
msg = _("Nodes %s owned by other cluster, need to delete them from "
|
||||
"those clusters first.") % nodes2
|
||||
self.assertEqual(_("The request is malformed: %(msg)s") % {'msg': msg},
|
||||
six.text_type(ex.exc_info[1]))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue