Example #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')
Example #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)
Example #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})
Example #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})
Example #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))
Example #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])
Example #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]))
Example #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)
Example #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())
Example #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))
Example #11
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))
Example #12
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)
Example #13
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)
Example #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')
Example #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])
Example #16
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']))
Example #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))
Example #18
0
 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')
Example #19
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)
Example #20
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)
Example #21
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)
Example #22
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')
Example #23
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')
Example #24
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])
Example #25
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)
Example #26
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)
Example #27
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)
Example #28
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)
Example #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])
Example #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})