Beispiel #1
0
    def test_get_node_by_instance_wrong_uuid(self):
        utils.create_test_node(
            instance_uuid='12345678-9999-0000-aaaa-123456789012')

        self.assertRaises(exception.InstanceNotFound,
                          self.dbapi.get_node_by_instance,
                          '12345678-9999-0000-bbbb-123456789012')
Beispiel #2
0
 def test_create_node_instance_already_associated(self):
     instance = uuidutils.generate_uuid()
     utils.create_test_node(uuid=uuidutils.generate_uuid(),
                            instance_uuid=instance)
     self.assertRaises(exception.InstanceAssociated,
                       utils.create_test_node,
                       uuid=uuidutils.generate_uuid(),
                       instance_uuid=instance)
Beispiel #3
0
 def test_update_node_name_duplicate(self):
     node1 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                    name='spam')
     node2 = utils.create_test_node(uuid=uuidutils.generate_uuid())
     self.assertRaises(exception.DuplicateName,
                       self.dbapi.update_node,
                       node2.id,
                       {'name': node1.name})
Beispiel #4
0
 def test_update_node_instance_already_associated(self):
     node1 = utils.create_test_node(uuid=uuidutils.generate_uuid())
     new_i_uuid = uuidutils.generate_uuid()
     self.dbapi.update_node(node1.id, {'instance_uuid': new_i_uuid})
     node2 = utils.create_test_node(uuid=uuidutils.generate_uuid())
     self.assertRaises(exception.InstanceAssociated,
                       self.dbapi.update_node,
                       node2.id,
                       {'instance_uuid': new_i_uuid})
Beispiel #5
0
    def test_check_node_list_non_existing(self):
        node1 = utils.create_test_node(uuid=uuidutils.generate_uuid())
        node2 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       name='node_2')
        uuid = uuidutils.generate_uuid()

        exc = self.assertRaises(exception.NodeNotFound,
                                self.dbapi.check_node_list,
                                [node1.uuid, uuid, 'could-be-a-name',
                                 node2.name])
        self.assertIn(uuid, str(exc))
        self.assertIn('could-be-a-name', str(exc))
Beispiel #6
0
    def test_get_node_list_description(self):
        node1 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       description='Hello')
        node2 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       description='World!')
        res = self.dbapi.get_node_list(filters={
            'description_contains': 'Hello'})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={
            'description_contains': 'World!'})
        self.assertEqual([node2.id], [r.id for r in res])
Beispiel #7
0
    def test_get_nodeinfo_list_with_filters(self):
        node1 = utils.create_test_node(
            driver='driver-one',
            instance_uuid=uuidutils.generate_uuid(),
            reservation='fake-host',
            uuid=uuidutils.generate_uuid())
        node2 = utils.create_test_node(
            driver='driver-two',
            uuid=uuidutils.generate_uuid(),
            maintenance=True,
            resource_class='foo')
        node3 = utils.create_test_node(
            driver='driver-one',
            uuid=uuidutils.generate_uuid(),
            reservation='another-fake-host')

        res = self.dbapi.get_nodeinfo_list(filters={'driver': 'driver-one'})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r[0] for r in res]))

        res = self.dbapi.get_nodeinfo_list(filters={'driver': 'bad-driver'})
        self.assertEqual([], [r[0] for r in res])

        res = self.dbapi.get_nodeinfo_list(filters={'associated': True})
        self.assertEqual([node1.id], [r[0] for r in res])

        res = self.dbapi.get_nodeinfo_list(filters={'associated': False})
        self.assertEqual(sorted([node2.id, node3.id]),
                         sorted([r[0] for r in res]))

        res = self.dbapi.get_nodeinfo_list(filters={'reserved': True})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r[0] for r in res]))

        res = self.dbapi.get_nodeinfo_list(filters={'reserved': False})
        self.assertEqual([node2.id], [r[0] for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': True})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': False})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r.id for r in res]))

        res = self.dbapi.get_node_list(filters={'resource_class': 'foo'})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(
            filters={'reserved_by_any_of': ['fake-host',
                                            'another-fake-host']})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r.id for r in res]))
Beispiel #8
0
    def test_check_node_list(self):
        node1 = utils.create_test_node(uuid=uuidutils.generate_uuid())
        node2 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       name='node_2')
        node3 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       name='node_3')

        mapping = self.dbapi.check_node_list([node1.uuid, node2.name,
                                              node3.uuid])
        self.assertEqual({node1.uuid: node1.uuid,
                          node2.name: node2.uuid,
                          node3.uuid: node3.uuid},
                         mapping)
Beispiel #9
0
 def test_check_versions(self):
     for v in self.object_versions['Node']:
         node = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       version=v)
         node = self.dbapi.get_node_by_id(node.id)
         self.assertEqual(v, node.version)
     self.assertTrue(self.dbapi.check_versions())
Beispiel #10
0
    def test_check_node_list_impossible(self):
        node1 = utils.create_test_node(uuid=uuidutils.generate_uuid())

        exc = self.assertRaises(exception.NodeNotFound,
                                self.dbapi.check_node_list,
                                [node1.uuid, 'this/cannot/be/a/name'])
        self.assertIn('this/cannot/be/a/name', str(exc))
Beispiel #11
0
 def test_one_node(self):
     node = utils.create_test_node(version=self.node_old_ver)
     expected = (0, 0) if self.node_version_same else (1, 1)
     self.assertEqual(
         expected, self.dbapi.update_to_latest_versions(self.context, 10))
     res = self.dbapi.get_node_by_uuid(node.uuid)
     self.assertEqual(self.node_ver, res.version)
Beispiel #12
0
 def test_update_node_provision(self, mock_utcnow):
     mocked_time = datetime.datetime(2000, 1, 1, 0, 0)
     mock_utcnow.return_value = mocked_time
     node = utils.create_test_node()
     res = self.dbapi.update_node(node.id, {'provision_state': 'fake'})
     self.assertEqual(mocked_time,
                      timeutils.normalize_time(res['provision_updated_at']))
Beispiel #13
0
 def test_get_nodeinfo_list_defaults(self):
     node_id_list = []
     for i in range(1, 6):
         node = utils.create_test_node(uuid=uuidutils.generate_uuid())
         node_id_list.append(node.id)
     res = [i[0] for i in self.dbapi.get_nodeinfo_list()]
     self.assertEqual(sorted(res), sorted(node_id_list))
Beispiel #14
0
 def setUp(self):
     super(DracPowerInternalMethodsTestCase, self).setUp()
     driver_info = INFO_DICT
     self.node = db_utils.create_test_node(
         driver='fake_drac',
         driver_info=driver_info,
         instance_uuid='instance_uuid_123')
Beispiel #15
0
 def test_get_node_by_uuid(self):
     node = utils.create_test_node()
     self.dbapi.set_node_tags(node.id, ['tag1', 'tag2'])
     res = self.dbapi.get_node_by_uuid(node.uuid)
     self.assertEqual(node.id, res.id)
     self.assertEqual(node.uuid, res.uuid)
     self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
Beispiel #16
0
 def test_update_node_associate_and_disassociate(self):
     node = utils.create_test_node()
     new_i_uuid = uuidutils.generate_uuid()
     res = self.dbapi.update_node(node.id, {'instance_uuid': new_i_uuid})
     self.assertEqual(new_i_uuid, res.instance_uuid)
     res = self.dbapi.update_node(node.id, {'instance_uuid': None})
     self.assertIsNone(res.instance_uuid)
Beispiel #17
0
    def test_tags_get_destroyed_after_destroying_a_node_by_uuid(self):
        node = utils.create_test_node()

        tag = utils.create_test_node_tag(node_id=node.id)

        self.assertTrue(self.dbapi.node_tag_exists(node.id, tag.tag))
        self.dbapi.destroy_node(node.uuid)
        self.assertFalse(self.dbapi.node_tag_exists(node.id, tag.tag))
Beispiel #18
0
 def setUp(self):
     super(DracPowerTestCase, self).setUp()
     driver_info = INFO_DICT
     mgr_utils.mock_the_extension_manager(driver="fake_drac")
     self.node = db_utils.create_test_node(
         driver='fake_drac',
         driver_info=driver_info,
         instance_uuid='instance_uuid_123')
 def setUp(self):
     # This method creates a volume_connector for every test and
     # replaces a test for creating a volume_connector.
     super(DbVolumeConnectorTestCase, self).setUp()
     self.node = db_utils.create_test_node()
     self.connector = db_utils.create_test_volume_connector(
         node_id=self.node.id, type='test',
         connector_id='test-connector_id')
Beispiel #20
0
    def test_allocations_get_destroyed_after_destroying_a_node_by_uuid(self):
        node = utils.create_test_node()

        allocation = utils.create_test_allocation(node_id=node.id)

        self.dbapi.destroy_node(node.uuid)
        self.assertRaises(exception.AllocationNotFound,
                          self.dbapi.get_allocation_by_id, allocation.id)
Beispiel #21
0
 def test_get_volume_targets_by_node_id(self):
     node2 = db_utils.create_test_node(uuid=uuidutils.generate_uuid())
     target2 = db_utils.create_test_volume_target(
         uuid=uuidutils.generate_uuid(), node_id=node2.id)
     self._create_list_of_volume_targets(2)
     res = self.dbapi.get_volume_targets_by_node_id(node2.id)
     self.assertEqual(1, len(res))
     self.assertEqual(target2.uuid, res[0].uuid)
Beispiel #22
0
    def test_release_non_existent_node(self):
        node = utils.create_test_node()
        self.dbapi.destroy_node(node.id)

        self.assertRaises(exception.NodeNotFound,
                          self.dbapi.release_node, 'fake', node.id)
        self.assertRaises(exception.NodeNotFound,
                          self.dbapi.release_node, 'fake', node.uuid)
Beispiel #23
0
    def test_release_non_locked_node(self):
        node = utils.create_test_node()

        self.assertIsNone(node.reservation)
        self.assertRaises(exception.NodeNotLocked,
                          self.dbapi.release_node, 'fake', node.id)
        self.assertRaises(exception.NodeNotLocked,
                          self.dbapi.release_node, 'fake', node.uuid)
Beispiel #24
0
 def test_get_node_list(self):
     uuids = []
     for i in range(1, 6):
         node = utils.create_test_node(uuid=uuidutils.generate_uuid())
         uuids.append(six.text_type(node['uuid']))
     res = self.dbapi.get_node_list()
     res_uuids = [r.uuid for r in res]
     six.assertCountEqual(self, uuids, res_uuids)
Beispiel #25
0
    def test_get_node_by_instance(self):
        node = utils.create_test_node(
            instance_uuid='12345678-9999-0000-aaaa-123456789012')
        self.dbapi.set_node_tags(node.id, ['tag1', 'tag2'])

        res = self.dbapi.get_node_by_instance(node.instance_uuid)
        self.assertEqual(node.uuid, res.uuid)
        self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])
Beispiel #26
0
 def setUp(self):
     # This method creates a port for every test and
     # replaces a test for creating a port.
     super(DbPortTestCase, self).setUp()
     self.node = db_utils.create_test_node()
     self.portgroup = db_utils.create_test_portgroup(node_id=self.node.id)
     self.port = db_utils.create_test_port(node_id=self.node.id,
                                           portgroup_id=self.portgroup.id)
Beispiel #27
0
 def setUp(self):
     super(IRMCPowerInternalMethodsTestCase, self).setUp()
     mgr_utils.mock_the_extension_manager(driver='fake_irmc')
     driver_info = INFO_DICT
     self.node = db_utils.create_test_node(
         driver='fake_irmc',
         driver_info=driver_info,
         instance_uuid='instance_uuid_123')
Beispiel #28
0
 def test_get_not_versions_null(self):
     node = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                   version=None)
     node = self.dbapi.get_node_by_id(node.id)
     self.assertIsNone(node.version)
     res = self.dbapi.get_not_versions('Node', ['1.6'])
     self.assertThat(res, matchers.HasLength(1))
     self.assertEqual(node.uuid, res[0].uuid)
Beispiel #29
0
    def test_get_node_list_with_filters(self):
        ch1 = utils.create_test_chassis(uuid=uuidutils.generate_uuid())
        ch2 = utils.create_test_chassis(uuid=uuidutils.generate_uuid())

        node1 = utils.create_test_node(
            driver='driver-one',
            instance_uuid=uuidutils.generate_uuid(),
            reservation='fake-host',
            uuid=uuidutils.generate_uuid(),
            chassis_id=ch1['id'])
        node2 = utils.create_test_node(
            driver='driver-two',
            uuid=uuidutils.generate_uuid(),
            chassis_id=ch2['id'],
            maintenance=True)

        res = self.dbapi.get_node_list(filters={'chassis_uuid': ch1['uuid']})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'chassis_uuid': ch2['uuid']})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'driver': 'driver-one'})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'driver': 'bad-driver'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'associated': True})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'associated': False})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'reserved': True})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'reserved': False})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': True})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': False})
        self.assertEqual([node1.id], [r.id for r in res])
Beispiel #30
0
 def test_update_node_already_associated(self):
     node = utils.create_test_node()
     new_i_uuid_one = uuidutils.generate_uuid()
     self.dbapi.update_node(node.id, {'instance_uuid': new_i_uuid_one})
     new_i_uuid_two = uuidutils.generate_uuid()
     self.assertRaises(exception.NodeAssociated,
                       self.dbapi.update_node,
                       node.id,
                       {'instance_uuid': new_i_uuid_two})
Beispiel #31
0
 def test_save_after_refresh(self):
     # Ensure that it's possible to do object.save() after object.refresh()
     address = "b2:54:00:cf:2d:40"
     db_node = db_utils.create_test_node()
     db_portgroup = db_utils.create_test_portgroup(node_id=db_node.id)
     p = objects.Portgroup.get_by_uuid(self.context, db_portgroup.uuid)
     p_copy = objects.Portgroup.get_by_uuid(self.context, db_portgroup.uuid)
     p.address = address
     p.save()
     p_copy.refresh()
     p_copy.address = 'aa:bb:cc:dd:ee:ff'
     # Ensure this passes and an exception is not generated
     p_copy.save()
Beispiel #32
0
    def test_reservation_after_release(self):
        node = utils.create_test_node()
        uuid = node.uuid

        r1 = 'fake-reservation'
        r2 = 'another-reservation'

        self.dbapi.reserve_node(r1, uuid)
        self.dbapi.release_node(r1, uuid)

        # another host succeeds
        self.dbapi.reserve_node(r2, uuid)
        res = self.dbapi.get_node_by_uuid(uuid)
        self.assertEqual(r2, res.reservation)
Beispiel #33
0
    def test_get_nodeinfo_list_provision(self, mock_utcnow):
        past = datetime.datetime(2000, 1, 1, 0, 0)
        next = past + datetime.timedelta(minutes=8)
        present = past + datetime.timedelta(minutes=10)
        mock_utcnow.return_value = past

        # node with provision_updated timeout
        node1 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       provision_updated_at=past)
        # node with None in provision_updated_at
        node2 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                       provision_state=states.DEPLOYWAIT)
        # node without timeout
        utils.create_test_node(uuid=uuidutils.generate_uuid(),
                               provision_updated_at=next)

        mock_utcnow.return_value = present
        res = self.dbapi.get_nodeinfo_list(filters={'provisioned_before': 300})
        self.assertEqual([node1.id], [r[0] for r in res])

        res = self.dbapi.get_nodeinfo_list(
            filters={'provision_state': states.DEPLOYWAIT})
        self.assertEqual([node2.id], [r[0] for r in res])
Beispiel #34
0
    def test_reserve_node(self):
        node = utils.create_test_node()
        self.dbapi.set_node_tags(node.id, ['tag1', 'tag2'])
        uuid = node.uuid

        r1 = 'fake-reservation'

        # reserve the node
        res = self.dbapi.reserve_node(r1, uuid)
        self.assertItemsEqual(['tag1', 'tag2'], [tag.tag for tag in res.tags])

        # check reservation
        res = self.dbapi.get_node_by_uuid(uuid)
        self.assertEqual(r1, res.reservation)
Beispiel #35
0
    def test_reservation_of_reserved_node_fails(self):
        node = utils.create_test_node()
        uuid = node.uuid

        r1 = 'fake-reservation'
        r2 = 'another-reservation'

        # reserve the node
        self.dbapi.reserve_node(r1, uuid)

        # another host fails to reserve or release
        self.assertRaises(exception.NodeLocked, self.dbapi.reserve_node, r2,
                          uuid)
        self.assertRaises(exception.NodeLocked, self.dbapi.release_node, r2,
                          uuid)
Beispiel #36
0
    def test_get_not_versions(self):
        versions = ['1.1', '1.2', '1.3']
        node_uuids = []
        for v in versions:
            node = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                          version=v)
            node_uuids.append(node.uuid)
        self.assertEqual([], self.dbapi.get_not_versions('Node', versions))

        res = self.dbapi.get_not_versions('Node', ['2.0'])
        self.assertThat(res, matchers.HasLength(len(node_uuids)))
        res_uuids = [n.uuid for n in res]
        self.assertEqual(node_uuids, res_uuids)

        res = self.dbapi.get_not_versions('Node', versions[1:])
        self.assertThat(res, matchers.HasLength(1))
        self.assertEqual(node_uuids[0], res[0].uuid)
Beispiel #37
0
    def test_get_port_list_filter_by_node_project(self):
        lessee_node = db_utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                                lessee=self.node.owner)

        uuids = []
        for i in range(1, 3):
            port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
                                             node_id=lessee_node.id,
                                             address='52:54:00:cf:2d:4%s' % i)
            uuids.append(str(port.uuid))
        for i in range(4, 6):
            port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
                                             address='52:54:00:cf:2d:4%s' % i)
        for i in range(7, 9):
            port = db_utils.create_test_port(uuid=uuidutils.generate_uuid(),
                                             node_id=self.node.id,
                                             address='52:54:00:cf:2d:4%s' % i)
            uuids.append(str(port.uuid))
        # Also add the uuid for the port created in setUp()
        uuids.append(str(self.port.uuid))
        res = self.dbapi.get_port_list(project=self.node.owner)
        res_uuids = [r.uuid for r in res]
        self.assertCountEqual(uuids, res_uuids)
Beispiel #38
0
 def test_create_node(self):
     node = utils.create_test_node()
     self.assertEqual([], node.tags)
     self.assertEqual([], node.traits)
Beispiel #39
0
    def test_get_node_list_with_filters(self):
        ch1 = utils.create_test_chassis(uuid=uuidutils.generate_uuid())
        ch2 = utils.create_test_chassis(uuid=uuidutils.generate_uuid())

        node1 = utils.create_test_node(driver='driver-one',
                                       instance_uuid=uuidutils.generate_uuid(),
                                       reservation='fake-host',
                                       uuid=uuidutils.generate_uuid(),
                                       chassis_id=ch1['id'])
        node2 = utils.create_test_node(driver='driver-two',
                                       uuid=uuidutils.generate_uuid(),
                                       chassis_id=ch2['id'],
                                       maintenance=True,
                                       fault='boom',
                                       resource_class='foo')

        res = self.dbapi.get_node_list(filters={'chassis_uuid': ch1['uuid']})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'chassis_uuid': ch2['uuid']})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'driver': 'driver-one'})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'driver': 'bad-driver'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'associated': True})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'associated': False})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'reserved': True})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'reserved': False})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': True})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': False})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_nodeinfo_list(filters={'fault': 'boom'})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_nodeinfo_list(filters={'fault': 'moob'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'resource_class': 'foo'})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'id': node1.id})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'uuid': node1.uuid})
        self.assertEqual([node1.id], [r.id for r in res])

        # ensure unknown filters explode
        filters = {'bad_filter': 'foo'}
        self.assertRaisesRegex(ValueError,
                               'bad_filter',
                               self.dbapi.get_node_list,
                               filters=filters)

        # even with good filters present
        filters = {'bad_filter': 'foo', 'id': node1.id}
        self.assertRaisesRegex(ValueError,
                               'bad_filter',
                               self.dbapi.get_node_list,
                               filters=filters)
Beispiel #40
0
 def test_check_versions_node_no_version(self):
     node = utils.create_test_node(version=None)
     node = self.dbapi.get_node_by_id(node.id)
     self.assertIsNone(node.version)
     self.assertFalse(self.dbapi.check_versions())
Beispiel #41
0
 def test_get_not_versions_no_model(self):
     utils.create_test_node(uuid=uuidutils.generate_uuid(), version='1.4')
     self.assertRaises(exception.IronicException,
                       self.dbapi.get_not_versions, 'NotExist', ['1.6'])
Beispiel #42
0
 def test_check_versions_ignore_node(self):
     node = utils.create_test_node(version=None)
     node = self.dbapi.get_node_by_id(node.id)
     self.assertIsNone(node.version)
     self.assertTrue(self.dbapi.check_versions(ignore_models=['Node']))
Beispiel #43
0
 def test_update_node_no_provision(self):
     node = utils.create_test_node()
     res = self.dbapi.update_node(node.id, {'extra': {'foo': 'bar'}})
     self.assertIsNone(res['provision_updated_at'])
     self.assertIsNone(res['inspection_started_at'])
Beispiel #44
0
 def test_update_node_uuid(self):
     node = utils.create_test_node()
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_node, node.id, {'uuid': ''})
Beispiel #45
0
 def setUp(self):
     super(FakeHardwareTestCase, self).setUp()
     self.node = db_utils.create_test_node()
     self.task = task_manager.acquire(self.context, self.node.id)
     self.addCleanup(self.task.release_resources)
     self.driver = self.task.driver
Beispiel #46
0
 def test_get_node_by_name(self):
     node = utils.create_test_node()
     res = self.dbapi.get_node_by_name(node.name)
     self.assertEqual(node.id, res.id)
     self.assertEqual(node.uuid, res.uuid)
     self.assertEqual(node.name, res.name)
Beispiel #47
0
 def setUp(self):
     super(DbNodeTagTestCase, self).setUp()
     self.node = db_utils.create_test_node()
Beispiel #48
0
 def _create_test_data(self):
     fake_db_node = db_utils.create_test_node(chassis_id=None)
     self.format_data['node_uuid'] = fake_db_node['uuid']
Beispiel #49
0
 def setUp(self):
     # This method creates a volume_target for every test.
     super(DbVolumeTargetTestCase, self).setUp()
     self.node = db_utils.create_test_node()
     self.target = db_utils.create_test_volume_target(node_id=self.node.id)
Beispiel #50
0
 def test_create_node_with_tags(self, mock_log):
     utils.create_test_node(tags=['tag1', 'tag2'])
     self.assertTrue(mock_log.called)
Beispiel #51
0
    def test_destroy_node_by_uuid(self):
        node = utils.create_test_node()

        self.dbapi.destroy_node(node.uuid)
        self.assertRaises(exception.NodeNotFound, self.dbapi.get_node_by_uuid,
                          node.uuid)
Beispiel #52
0
 def test_create_node(self):
     utils.create_test_node()
Beispiel #53
0
 def test_create_node_already_exists(self):
     utils.create_test_node()
     self.assertRaises(exception.NodeAlreadyExists, utils.create_test_node)
Beispiel #54
0
    def test_get_node_by_instance(self):
        node = utils.create_test_node(
            instance_uuid='12345678-9999-0000-aaaa-123456789012')

        res = self.dbapi.get_node_by_instance(node.instance_uuid)
        self.assertEqual(node.uuid, res.uuid)
Beispiel #55
0
 def test_update_node_name_duplicate(self):
     node1 = utils.create_test_node(uuid=uuidutils.generate_uuid(),
                                    name='spam')
     node2 = utils.create_test_node(uuid=uuidutils.generate_uuid())
     self.assertRaises(exception.DuplicateName, self.dbapi.update_node,
                       node2.id, {'name': node1.name})
Beispiel #56
0
    def test_destroy_chassis_with_nodes(self):
        utils.create_test_node(chassis_id=self.chassis.id)

        self.assertRaises(exception.ChassisNotEmpty,
                          self.dbapi.destroy_chassis, self.chassis.id)
Beispiel #57
0
 def test_create_node_name_duplicate(self):
     node = utils.create_test_node(name='spam')
     self.assertRaises(exception.DuplicateName,
                       utils.create_test_node,
                       name=node.name)
Beispiel #58
0
    def test_get_nodeinfo_list_with_filters(self):
        node1 = utils.create_test_node(driver='driver-one',
                                       instance_uuid=uuidutils.generate_uuid(),
                                       reservation='fake-host',
                                       uuid=uuidutils.generate_uuid())
        node2 = utils.create_test_node(driver='driver-two',
                                       uuid=uuidutils.generate_uuid(),
                                       maintenance=True,
                                       resource_class='foo')
        node3 = utils.create_test_node(driver='driver-one',
                                       uuid=uuidutils.generate_uuid(),
                                       reservation='another-fake-host')

        res = self.dbapi.get_nodeinfo_list(filters={'driver': 'driver-one'})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r[0] for r in res]))

        res = self.dbapi.get_nodeinfo_list(filters={'driver': 'bad-driver'})
        self.assertEqual([], [r[0] for r in res])

        res = self.dbapi.get_nodeinfo_list(filters={'associated': True})
        self.assertEqual([node1.id], [r[0] for r in res])

        res = self.dbapi.get_nodeinfo_list(filters={'associated': False})
        self.assertEqual(sorted([node2.id, node3.id]),
                         sorted([r[0] for r in res]))

        res = self.dbapi.get_nodeinfo_list(filters={'reserved': True})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r[0] for r in res]))

        res = self.dbapi.get_nodeinfo_list(filters={'reserved': False})
        self.assertEqual([node2.id], [r[0] for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': True})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'maintenance': False})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r.id for r in res]))

        res = self.dbapi.get_node_list(filters={'resource_class': 'foo'})
        self.assertEqual([node2.id], [r.id for r in res])

        res = self.dbapi.get_node_list(
            filters={'reserved_by_any_of': ['fake-host', 'another-fake-host']})
        self.assertEqual(sorted([node1.id, node3.id]),
                         sorted([r.id for r in res]))

        res = self.dbapi.get_node_list(filters={'id': node1.id})
        self.assertEqual([node1.id], [r.id for r in res])

        res = self.dbapi.get_node_list(filters={'uuid': node1.uuid})
        self.assertEqual([node1.id], [r.id for r in res])

        # ensure unknown filters explode
        filters = {'bad_filter': 'foo'}
        self.assertRaisesRegex(ValueError,
                               'bad_filter',
                               self.dbapi.get_node_list,
                               filters=filters)

        # even with good filters present
        filters = {'bad_filter': 'foo', 'id': node1.id}
        self.assertRaisesRegex(ValueError,
                               'bad_filter',
                               self.dbapi.get_node_list,
                               filters=filters)
Beispiel #59
0
 def test_check_versions_node_old(self):
     node = utils.create_test_node(version='1.0')
     node = self.dbapi.get_node_by_id(node.id)
     self.assertEqual('1.0', node.version)
     self.assertFalse(self.dbapi.check_versions())
Beispiel #60
0
 def test_version_exists(self):
     # Node will be in latest version
     utils.create_test_node()
     self.assertEqual(
         (0, 0), self.dbapi.update_to_latest_versions(self.context, 10))