コード例 #1
0
    def test_cinder_volume_validity(self):
        # Setup
        processor = self._create_processor_with_graph(self.conf)
        self.assertEqual(self._num_total_expected_vertices(),
                         len(processor.entity_graph))

        spec_list = mock_driver.simple_volume_generators(volume_num=1,
                                                         instance_num=1,
                                                         snapshot_events=1)
        static_events = mock_driver.generate_random_events_list(spec_list)
        cinder_volume_event = static_events[0]
        cinder_volume_event['attachments'][0]['server_id'] = \
            self._find_entity_id_by_type(processor.entity_graph,
                                         NOVA_INSTANCE_DATASOURCE)

        # Action
        processor.process_event(cinder_volume_event)

        # Test assertions
        self.assertEqual(self._num_total_expected_vertices() + 1,
                         len(processor.entity_graph))

        cinder_vertices = processor.entity_graph.get_vertices(
            vertex_attr_filter={
                VProps.VITRAGE_CATEGORY: EntityCategory.RESOURCE,
                VProps.VITRAGE_TYPE: CINDER_VOLUME_DATASOURCE
            })
        self.assertEqual(1, len(cinder_vertices))

        cinder_neighbors = processor.entity_graph.neighbors(
            cinder_vertices[0].vertex_id)
        self.assertEqual(1, len(cinder_neighbors))

        self.assertEqual(NOVA_INSTANCE_DATASOURCE,
                         cinder_neighbors[0][VProps.VITRAGE_TYPE])
コード例 #2
0
    def test_update_transform(self):
        LOG.debug('Cinder Volume transformer test: transform entity event '
                  'update')

        # Test setup
        spec_list = mock_sync.simple_volume_generators(volume_num=3,
                                                       instance_num=7,
                                                       update_events=7)
        static_events = mock_sync.generate_random_events_list(spec_list)

        for event in static_events:
            # Test action
            wrapper = self.transformers[CINDER_VOLUME_DATASOURCE].transform(
                event)

            # Test assertions
            vertex = wrapper.vertex
            self._validate_volume_vertex_props(vertex, event)

            neighbors = wrapper.neighbors
            self.assertEqual(1, len(neighbors))
            self._validate_neighbors(neighbors, vertex.vertex_id, event)
コード例 #3
0
    def test_update_transform(self):
        LOG.debug('Cinder Volume transformer test: transform entity event '
                  'update')

        # Test setup
        spec_list = mock_sync.simple_volume_generators(volume_num=3,
                                                       instance_num=7,
                                                       update_events=7)
        static_events = mock_sync.generate_random_events_list(spec_list)

        for event in static_events:
            # Test action
            wrapper = self.transformers[CINDER_VOLUME_DATASOURCE].transform(
                event)

            # Test assertions
            vertex = wrapper.vertex
            self._validate_volume_vertex_props(vertex, event)

            neighbors = wrapper.neighbors
            self.assertThat(neighbors, matchers.HasLength(1))
            self._validate_neighbors(neighbors, vertex.vertex_id, event)
コード例 #4
0
    def test_cinder_volume_validity(self):
        # Setup
        processor = self._create_processor_with_graph(self.conf)
        self.assertEqual(self._num_total_expected_vertices(),
                         len(processor.entity_graph))

        spec_list = mock_driver.simple_volume_generators(
            volume_num=1,
            instance_num=1,
            snapshot_events=1)
        static_events = mock_driver.generate_random_events_list(spec_list)
        cinder_volume_event = static_events[0]
        cinder_volume_event['attachments'][0]['server_id'] = \
            self._find_entity_id_by_type(processor.entity_graph,
                                         NOVA_INSTANCE_DATASOURCE)

        # Action
        processor.process_event(cinder_volume_event)

        # Test assertions
        self.assertEqual(self._num_total_expected_vertices() + 1,
                         len(processor.entity_graph))

        cinder_vertices = processor.entity_graph.get_vertices(
            vertex_attr_filter={
                VProps.CATEGORY: EntityCategory.RESOURCE,
                VProps.TYPE: CINDER_VOLUME_DATASOURCE
            })
        self.assertEqual(1, len(cinder_vertices))

        cinder_neighbors = processor.entity_graph.neighbors(
            cinder_vertices[0].vertex_id)
        self.assertEqual(1, len(cinder_neighbors))

        self.assertEqual(NOVA_INSTANCE_DATASOURCE,
                         cinder_neighbors[0][VProps.TYPE])