Exemplo n.º 1
0
    def test_set(self):
        data = {'s': 'value', 'b': True, 'i': 42}
        self.node_info.set_option('name', data)
        self.assertEqual(data, self.node_info.options['name'])

        new = node_cache.NodeInfo(uuid=self.uuid, started_at=3.14)
        self.assertEqual(data, new.options['name'])
Exemplo n.º 2
0
 def setUp(self):
     super(TestNodeInfoOptions, self).setUp()
     node_cache.add_node(self.uuid, bmc_address='1.2.3.4', mac=self.macs)
     self.node_info = node_cache.NodeInfo(uuid=self.uuid, started_at=3.14)
     with self.db:
         self.db.execute(
             'insert into options(uuid, name, value) '
             'values(?, ?, ?)', (self.uuid, 'foo', '"bar"'))
Exemplo n.º 3
0
        def wrapper(self, client_mock, pop_mock, process_mock, *args, **kw):
            cli = client_mock.return_value
            pop_mock.return_value = node_cache.NodeInfo(
                uuid=self.node.uuid, started_at=self.started_at)
            cli.port.create.side_effect = self.ports
            cli.node.get.return_value = self.node
            process_mock.return_value = self.fake_result_json

            return func(self, cli, pop_mock, process_mock, *args, **kw)
Exemplo n.º 4
0
 def test_get_introspection_in_progress(self, get_mock):
     get_mock.return_value = node_cache.NodeInfo(uuid='uuid',
                                                 started_at=42.0)
     res = self.app.get('/v1/introspection/uuid')
     self.assertEqual(200, res.status_code)
     self.assertEqual({
         'finished': False,
         'error': None
     }, json.loads(res.data.decode('utf-8')))
Exemplo n.º 5
0
    def test_expected_exception(self, finished_mock, client_mock, pop_mock,
                                process_mock):
        pop_mock.return_value = node_cache.NodeInfo(uuid=self.node.uuid,
                                                    started_at=self.started_at)
        process_mock.side_effect = utils.Error('boom')

        self.assertRaisesRegexp(utils.Error, 'boom', process.process,
                                self.data)

        finished_mock.assert_called_once_with(mock.ANY, error='boom')
Exemplo n.º 6
0
 def test_get_introspection_finished(self, get_mock):
     get_mock.return_value = node_cache.NodeInfo(uuid='uuid',
                                                 started_at=42.0,
                                                 finished_at=100.1,
                                                 error='boom')
     res = self.app.get('/v1/introspection/uuid')
     self.assertEqual(200, res.status_code)
     self.assertEqual({
         'finished': True,
         'error': 'boom'
     }, json.loads(res.data.decode('utf-8')))
Exemplo n.º 7
0
    def setUp(self):
        super(TestProcessNode, self).setUp()
        conf.CONF.set('discoverd', 'processing_hooks',
                      'ramdisk_error,scheduler,validate_interfaces,example')
        self.validate_attempts = 5
        self.power_off_attempts = 2
        self.data['macs'] = self.macs  # validate_interfaces hook
        self.cached_node = node_cache.NodeInfo(uuid=self.uuid,
                                               started_at=self.started_at)
        self.patch_before = [
            {
                'op': 'add',
                'path': '/properties/cpus',
                'value': '2'
            },
            {
                'op': 'add',
                'path': '/properties/memory_mb',
                'value': '1024'
            },
        ]  # scheduler hook
        self.patch_after = [
            {
                'op': 'add',
                'path': '/extra/newly_discovered',
                'value': 'true'
            },
            {
                'op': 'remove',
                'path': '/extra/on_discovery'
            },
        ]

        self.cli = mock.Mock()
        self.cli.node.validate.side_effect = self.fake_validate()
        self.cli.port.create.side_effect = self.ports
        self.cli.node.update.return_value = self.node
        # Simulate longer power off
        self.cli.node.get.side_effect = (
            [self.node] * self.power_off_attempts +
            [mock.Mock(power_state='power off')])