Example #1
0
    def test_node_update(self):
        node = shared.create_node(self.ctx, self.cluster, self.profile)
        new_attributes = {
            'name': 'new node name',
            'status': 'bad status',
            'role': 'a new role',
        }
        db_api.node_update(self.ctx, node.id, new_attributes)

        node = db_api.node_get(self.ctx, node.id)
        self.assertEqual('new node name', node.name)
        self.assertEqual('bad status', node.status)
        self.assertEqual('a new role', node.role)
Example #2
0
    def test_node_update(self):
        node = shared.create_node(self.ctx, self.cluster, self.profile)
        new_attributes = {
            'name': 'new node name',
            'status': 'bad status',
            'role': 'a new role',
        }
        db_api.node_update(self.ctx, node.id, new_attributes)

        node = db_api.node_get(self.ctx, node.id)
        self.assertEqual('new node name', node.name)
        self.assertEqual('bad status', node.status)
        self.assertEqual('a new role', node.role)
Example #3
0
    def test_node_update_cluster_status_updated(self):
        cluster = db_api.cluster_get(self.ctx, self.cluster.id)
        self.assertEqual('INIT', cluster.status)

        node = shared.create_node(self.ctx, self.cluster, self.profile)

        new_attributes = {
            'name': 'new_name',
            'status': 'ERROR',
            'status_reason': 'Something is wrong',
        }

        db_api.node_update(self.ctx, node.id, new_attributes)

        node = db_api.node_get(self.ctx, node.id)
        self.assertEqual('new_name', node.name)
        self.assertEqual('ERROR', node.status)
        self.assertEqual('Something is wrong', node.status_reason)

        cluster = db_api.cluster_get(self.ctx, self.cluster.id)
        self.assertEqual('WARNING', cluster.status)
        reason = 'Node new_name: Something is wrong'
        self.assertEqual(reason, cluster.status_reason)
Example #4
0
    def test_node_update_cluster_status_updated(self):
        cluster = db_api.cluster_get(self.ctx, self.cluster.id)
        self.assertEqual('INIT', cluster.status)

        node = shared.create_node(self.ctx, self.cluster, self.profile)

        new_attributes = {
            'name': 'new_name',
            'status': 'ERROR',
            'status_reason': 'Something is wrong',
        }

        db_api.node_update(self.ctx, node.id, new_attributes)

        node = db_api.node_get(self.ctx, node.id)
        self.assertEqual('new_name', node.name)
        self.assertEqual('ERROR', node.status)
        self.assertEqual('Something is wrong', node.status_reason)

        cluster = db_api.cluster_get(self.ctx, self.cluster.id)
        self.assertEqual('WARNING', cluster.status)
        reason = 'Node new_name: Something is wrong'
        self.assertEqual(reason, cluster.status_reason)
    def test_pre_op_with_bad_nodes(self):
        node_id = self.nodes[0]
        db_api.node_update(self.context, node_id, {'status': 'ERROR'})

        action = mock.Mock()
        action.context = self.context
        action.action = consts.CLUSTER_SCALE_IN
        action.inputs = {}
        adjustment = self.spec['properties']['adjustment']
        adjustment['type'] = consts.EXACT_CAPACITY
        adjustment['number'] = 1
        policy = sp.ScalingPolicy('test-policy', self.spec)

        policy.pre_op(self.cluster['id'], action)
        pd = {
            'deletion': {
                'count': 2,
            },
            'reason': 'Scaling request validated.',
            'status': policy_base.CHECK_OK,
        }
        action.data.update.assert_called_with(pd)
        action.store.assert_called_with(self.context)
    def test_pre_op_with_bad_nodes(self):
        node_id = self.nodes[0]
        db_api.node_update(self.context, node_id, {'status': 'ERROR'})

        action = mock.Mock()
        action.context = self.context
        action.action = consts.CLUSTER_SCALE_IN
        action.inputs = {}
        adjustment = self.spec['properties']['adjustment']
        adjustment['type'] = consts.EXACT_CAPACITY
        adjustment['number'] = 1
        policy = sp.ScalingPolicy('test-policy', self.spec)

        policy.pre_op(self.cluster['id'], action)
        pd = {
            'deletion': {
                'count': 2,
            },
            'reason': 'Scaling request validated.',
            'status': policy_base.CHECK_OK,
        }
        action.data.update.assert_called_with(pd)
        action.store.assert_called_with(self.context)