Exemplo n.º 1
0
    def test_node_get_by_name(self):
        shared.create_node(self.ctx, self.cluster, self.profile)
        node = db_api.node_get_by_name(self.ctx, 'test_node_name')
        self.assertIsNotNone(node)
        self.assertEqual('test_node_name', node.name)
        self.assertEqual(self.cluster.id, node.cluster_id)

        res = db_api.node_get_by_name(self.ctx, 'BogusName')
        self.assertIsNone(res)
Exemplo n.º 2
0
    def test_node_get_by_name(self):
        shared.create_node(self.ctx, self.cluster, self.profile)
        node = db_api.node_get_by_name(self.ctx, 'test_node_name')
        self.assertIsNotNone(node)
        self.assertEqual('test_node_name', node.name)
        self.assertEqual(self.cluster.id, node.cluster_id)

        res = db_api.node_get_by_name(self.ctx, 'BogusName')
        self.assertIsNone(res)
Exemplo n.º 3
0
    def test_node_get_by_name_diff_project(self):
        shared.create_node(self.ctx, self.cluster, self.profile)
        res = db_api.node_get_by_name(self.ctx, 'test_node_name')
        self.assertIsNotNone(res)

        ctx_new = utils.dummy_context(project='a_different_project')
        res = db_api.node_get_by_name(ctx_new, 'test_node_name')
        self.assertIsNone(res)
        res = db_api.node_get_by_name(ctx_new, 'test_node_name',
                                      project_safe=False)
        self.assertIsNotNone(res)
Exemplo n.º 4
0
    def test_node_get_by_name(self):
        shared.create_node(self.ctx, self.cluster, self.profile)
        node = db_api.node_get_by_name(self.ctx, 'test_node_name')
        self.assertIsNotNone(node)
        self.assertEqual('test_node_name', node.name)
        self.assertEqual(self.cluster.id, node.cluster_id)

        res = db_api.node_get_by_name(self.ctx, 'BogusName')
        self.assertIsNone(res)

        # duplicated name
        shared.create_node(self.ctx, self.cluster, self.profile)
        self.assertRaises(exception.MultipleChoices, db_api.node_get_by_name,
                          self.ctx, 'test_node_name')
Exemplo n.º 5
0
    def test_node_get_by_name_show_deleted(self):
        node_name = 'test_node_name'
        shared.create_node(self.ctx, self.cluster, self.profile,
                           name=node_name)
        node = db_api.node_get_by_name(self.ctx, node_name)
        self.assertIsNotNone(node)

        node_id = node.id
        db_api.node_delete(self.ctx, node_id)

        res = db_api.node_get_by_name(self.ctx, node_name)
        self.assertIsNone(res)

        res = db_api.node_get_by_name(self.ctx, node_name, show_deleted=False)
        self.assertIsNone(res)

        res = db_api.node_get_by_name(self.ctx, node_name, show_deleted=True)
        self.assertEqual(node_id, res.id)
Exemplo n.º 6
0
    def test_node_get_by_name_show_deleted(self):
        node_name = 'test_node_name'
        shared.create_node(self.ctx, self.cluster, self.profile,
                           name=node_name)
        node = db_api.node_get_by_name(self.ctx, node_name)
        self.assertIsNotNone(node)

        node_id = node.id
        db_api.node_delete(self.ctx, node_id)

        res = db_api.node_get_by_name(self.ctx, node_name)
        self.assertIsNone(res)

        res = db_api.node_get_by_name(self.ctx, node_name, show_deleted=False)
        self.assertIsNone(res)

        res = db_api.node_get_by_name(self.ctx, node_name, show_deleted=True)
        self.assertEqual(node_id, res.id)