Beispiel #1
0
    def test_get_topology_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None, self.api_lock)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root=None,
                                           all_tenants=True)
        graph_topology = decompress_obj(graph_topology)

        # Test assertions
        self.assertThat(graph_topology['nodes'], matchers.HasLength(12))
Beispiel #2
0
    def test_get_topology_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root='RESOURCE:openstack.cluster',
                                           all_tenants=1)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertEqual(12, len(graph_topology['nodes']))
Beispiel #3
0
    def test_get_topology_with_all_tenants(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root='RESOURCE:openstack.cluster',
                                           all_tenants=1)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertEqual(12, len(graph_topology['nodes']))
Beispiel #4
0
    def test_get_topology_with_not_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_2', 'is_admin': False}

        # Action
        graph_topology = apis.get_topology(ctx,
                                           graph_type='graph',
                                           depth=10,
                                           query=None,
                                           root=None,
                                           all_tenants=False)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertThat(graph_topology['nodes'], matchers.HasLength(7))
        self._check_projects_entities(graph_topology['nodes'], 'project_2',
                                      False)
Beispiel #5
0
    def test_get_topology_with_admin_project(self):
        # Setup
        graph = self._create_graph()
        apis = TopologyApis(graph, None)
        ctx = {'tenant': 'project_1', 'is_admin': True}

        # Action
        graph_topology = apis.get_topology(
            ctx,
            graph_type='graph',
            depth=10,
            query=None,
            root=None,
            all_tenants=False)
        graph_topology = json.loads(graph_topology)

        # Test assertions
        self.assertEqual(8, len(graph_topology['nodes']))
        self._check_projects_entities(graph_topology['nodes'],
                                      'project_1',
                                      False)