Ejemplo n.º 1
0
    def test_update_power_states(self, mock_time, mock_exists, mock_put,
                                 mock_get, mock_event, mock_see):
        m = cleaner.Monitor('cleaner')
        m._update_power_states()

        result = [(c[1][0], c[1][1], c[1][2], {
            'uuid': c[1][3]['uuid'],
            'power_state': c[1][3]['power_state'],
        }) for c in mock_put.mock_calls]

        self.assertEqual([('instance', None, 'running', {
            'uuid': 'running',
            'power_state': 'on',
        }),
                          ('instance', None, 'shutoff', {
                              'uuid': 'shutoff',
                              'power_state': 'off',
                          }),
                          ('instance', None, 'crashed', {
                              'uuid': 'crashed',
                              'power_state': 'crashed',
                          }),
                          ('instance', None, 'crashed', {
                              'uuid': 'crashed',
                              'power_state': 'crashed',
                          }),
                          ('instance', None, 'paused', {
                              'uuid': 'paused',
                              'power_state': 'paused',
                          }),
                          ('instance', None, 'suspended', {
                              'uuid': 'suspended',
                              'power_state': 'paused',
                          }),
                          ('instance', None, 'foo', {
                              'uuid': 'foo',
                              'power_state': 'off',
                          }),
                          ('instance', None, 'bar', {
                              'uuid': 'bar',
                              'power_state': 'off',
                          }),
                          ('instance', None, 'nofiles', {
                              'uuid': 'nofiles',
                              'power_state': '',
                          })], result)
Ejemplo n.º 2
0
    def test_update_power_states(self, mock_time, mock_exists, mock_put,
                                 mock_get_instance, mock_event, mock_see,
                                 mock_lock, mock_etcd_get, mock_error,
                                 mock_state_value, mock_state):
        mock_state_value.return_value = 'created'

        m = cleaner.Monitor('cleaner')
        m._update_power_states()

        result = []
        for c in mock_put.mock_calls:
            if type(c[1][3]) is dict and 'placement_attempts' in c[1][3]:
                continue
            if type(c[1][3]) is State:
                val = c[1][3]
            else:
                val = {'power_state': c[1][3]['power_state']}
            result.append((c[1][0], c[1][1], c[1][2], val))

        self.assertEqual([('attribute/instance', 'running', 'power_state', {
            'power_state': 'on'
        }),
                          ('attribute/instance', 'shutoff', 'power_state', {
                              'power_state': 'off'
                          }),
                          ('attribute/instance', 'crashed', 'power_state', {
                              'power_state': 'crashed'
                          }),
                          ('attribute/instance', 'paused', 'power_state', {
                              'power_state': 'paused'
                          }),
                          ('attribute/instance', 'suspended', 'power_state', {
                              'power_state': 'paused'
                          }),
                          ('attribute/instance', 'foo', 'power_state', {
                              'power_state': 'off'
                          }),
                          ('attribute/instance', 'bar', 'power_state', {
                              'power_state': 'off'
                          })], result)
Ejemplo n.º 3
0
    def test_update_power_states(self, mock_time, mock_exists, mock_put,
                                 mock_get, mock_event, mock_see):
        m = cleaner.Monitor('cleaner')
        m._update_power_states()

        self.assertEqual([
            mock.call(
                'instance', None, 'running', {
                    'uuid': 'running',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'on',
                    'power_state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'shutoff', {
                    'uuid': 'shutoff',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'off',
                    'power_state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'crashed', {
                    'uuid': 'crashed',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'crashed',
                    'power_state_updated': 7,
                    'state': 'error',
                    'state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'crashed', {
                    'uuid': 'crashed',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'crashed',
                    'power_state_updated': 7,
                    'state': 'error',
                    'state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'paused', {
                    'uuid': 'paused',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'paused',
                    'power_state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'suspended', {
                    'uuid': 'suspended',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'paused',
                    'power_state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'foo', {
                    'uuid': 'foo',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'off',
                    'power_state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'bar', {
                    'uuid': 'bar',
                    'node': 'abigcomputer',
                    'power_state_previous': 'unknown',
                    'power_state': 'off',
                    'power_state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                }),
            mock.call(
                'instance', None, 'nofiles', {
                    'uuid': 'nofiles',
                    'node': 'abigcomputer',
                    'state': 'error',
                    'state_updated': 7,
                    'video': {
                        'memory': 16384,
                        'model': 'cirrus'
                    },
                    'error_message': None,
                })
        ], mock_put.mock_calls)