Beispiel #1
0
    def test_event_count_all_by_cluster_diff_project(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)
        cluster2 = shared.create_cluster(self.ctx, self.profile)
        self.create_event(self.ctx, entity=cluster1)
        self.create_event(self.ctx, entity=cluster2)

        new_ctx = utils.dummy_context(project='a-different-project')
        res = db_api.event_count_by_cluster(new_ctx, cluster1.id)
        self.assertEqual(0, res)
        res = db_api.event_count_by_cluster(new_ctx, cluster1.id,
                                            project_safe=False)
        self.assertEqual(1, res)
Beispiel #2
0
    def test_event_count_all_by_cluster_diff_project(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)
        cluster2 = shared.create_cluster(self.ctx, self.profile)
        self.create_event(self.ctx, entity=cluster1)
        self.create_event(self.ctx, entity=cluster2)

        new_ctx = utils.dummy_context(project='a-different-project')
        res = db_api.event_count_by_cluster(new_ctx, cluster1.id)
        self.assertEqual(0, res)
        res = db_api.event_count_by_cluster(new_ctx, cluster1.id,
                                            project_safe=False)
        self.assertEqual(1, res)
Beispiel #3
0
    def test_event_count_all_by_cluster_admin_context(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)
        self.create_event(self.ctx, entity=cluster1)

        admin_ctx = utils.dummy_context(project='a-different-project',
                                        is_admin=True)

        res = db_api.event_count_by_cluster(admin_ctx, cluster1.id,
                                            project_safe=True)
        self.assertEqual(0, res)
        res = db_api.event_count_by_cluster(admin_ctx, cluster1.id,
                                            project_safe=False)
        self.assertEqual(1, res)
Beispiel #4
0
    def test_event_count_all_by_cluster_admin_context(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)
        self.create_event(self.ctx, entity=cluster1)

        admin_ctx = utils.dummy_context(project='a-different-project',
                                        is_admin=True)

        res = db_api.event_count_by_cluster(admin_ctx, cluster1.id,
                                            project_safe=True)
        self.assertEqual(1, res)
Beispiel #5
0
    def test_event_count_all_by_cluster(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)
        cluster2 = shared.create_cluster(self.ctx, self.profile)
        node1_1 = shared.create_node(self.ctx, cluster1, self.profile)
        node_orphan = shared.create_node(self.ctx, None, self.profile)

        self.create_event(self.ctx, entity=cluster1)
        self.create_event(self.ctx, entity=cluster1)

        self.assertEqual(2, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))

        # No change if event is not related to a cluster
        self.create_event(self.ctx, entity=self.profile)

        self.assertEqual(2, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))

        # Node level events account to cluster
        self.create_event(self.ctx, entity=node1_1)
        self.assertEqual(3, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))

        # Node level events account to cluster, but not for orphan nodes
        self.create_event(self.ctx, entity=node_orphan)
        self.assertEqual(3, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))
        # Another cluster
        self.create_event(self.ctx, entity=cluster2)
        self.assertEqual(3, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(1, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))
Beispiel #6
0
    def test_event_count_all_by_cluster(self):
        cluster1 = shared.create_cluster(self.ctx, self.profile)
        cluster2 = shared.create_cluster(self.ctx, self.profile)
        node1_1 = shared.create_node(self.ctx, cluster1, self.profile)
        node_orphan = shared.create_node(self.ctx, None, self.profile)

        self.create_event(self.ctx, entity=cluster1)
        self.create_event(self.ctx, entity=cluster1)

        self.assertEqual(2, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))

        # No change if event is not related to a cluster
        self.create_event(self.ctx, entity=self.profile)

        self.assertEqual(2, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))

        # Node level events account to cluster
        self.create_event(self.ctx, entity=node1_1)
        self.assertEqual(3, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))

        # Node level events account to cluster, but not for orphan nodes
        self.create_event(self.ctx, entity=node_orphan)
        self.assertEqual(3, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(0, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))
        # Another cluster
        self.create_event(self.ctx, entity=cluster2)
        self.assertEqual(3, db_api.event_count_by_cluster(self.ctx,
                                                          cluster1.id))
        self.assertEqual(1, db_api.event_count_by_cluster(self.ctx,
                                                          cluster2.id))