示例#1
0
    def test_extract_action_type(self):
        LOG.debug('Test extract action type')

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={DSProps.SYNC_MODE: SyncMode.SNAPSHOT})

        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = HostTransformer(self.transformers)

        # Test action
        action = host_transformer._extract_action_type(hosts_events[0])

        # Test assertion
        self.assertEqual(EventAction.UPDATE_ENTITY, action)

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = HostTransformer(self.transformers)

        # Test action
        action = host_transformer._extract_action_type(hosts_events[0])

        # Test assertions
        self.assertEqual(EventAction.CREATE_ENTITY, action)
示例#2
0
    def test_extract_event_action(self):
        LOG.debug('Test extract event action')

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT})

        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = self.transformers[NOVA_HOST_DATASOURCE]

        # Test action
        action = host_transformer._extract_graph_action(hosts_events[0])

        # Test assertion
        self.assertEqual(GraphAction.UPDATE_ENTITY, action)

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={DSProps.DATASOURCE_ACTION:
                       DatasourceAction.INIT_SNAPSHOT})
        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = self.transformers[NOVA_HOST_DATASOURCE]

        # Test action
        action = host_transformer._extract_graph_action(hosts_events[0])

        # Test assertions
        self.assertEqual(GraphAction.CREATE_ENTITY, action)
    def test_extract_event_action(self):
        LOG.debug('Test extract event action')

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={DSProps.DATASOURCE_ACTION: DatasourceAction.SNAPSHOT})

        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = self.transformers[NOVA_HOST_DATASOURCE]

        # Test action
        action = host_transformer._extract_graph_action(hosts_events[0])

        # Test assertion
        self.assertEqual(GraphAction.UPDATE_ENTITY, action)

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={DSProps.DATASOURCE_ACTION:
                       DatasourceAction.INIT_SNAPSHOT})
        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = self.transformers[NOVA_HOST_DATASOURCE]

        # Test action
        action = host_transformer._extract_graph_action(hosts_events[0])

        # Test assertions
        self.assertEqual(GraphAction.CREATE_ENTITY, action)
示例#4
0
    def test_snapshot_transform(self):
        LOG.debug('Nova host transformer test: transform entity event')

        # Test setup
        spec_list = mock_sync.simple_host_generators(zone_num=2,
                                                     host_num=4,
                                                     snapshot_events=5)

        host_events = mock_sync.generate_random_events_list(spec_list)

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

            # Test assertions
            self._validate_vertex_props(wrapper.vertex, event)

            neighbors = wrapper.neighbors
            self.assertThat(neighbors, matchers.HasLength(1))
            self._validate_zone_neighbor(neighbors[0], event)

            if DatasourceAction.SNAPSHOT == event[DSProps.DATASOURCE_ACTION]:
                self.assertEqual(GraphAction.UPDATE_ENTITY, wrapper.action)
            else:
                self.assertEqual(GraphAction.CREATE_ENTITY, wrapper.action)
示例#5
0
    def test_snapshot_transform(self):
        LOG.debug('Nova host transformer test: transform entity event')

        # Test setup
        spec_list = mock_sync.simple_host_generators(zone_num=2,
                                                     host_num=4,
                                                     snapshot_events=5)

        host_events = mock_sync.generate_random_events_list(spec_list)

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

            # Test assertions
            self._validate_vertex_props(wrapper.vertex, event)

            neighbors = wrapper.neighbors
            self.assertEqual(1, len(neighbors))
            self._validate_zone_neighbor(neighbors[0], event)

            if SyncMode.SNAPSHOT == event[DSProps.SYNC_MODE]:
                self.assertEqual(EventAction.UPDATE_ENTITY, wrapper.action)
            else:
                self.assertEqual(EventAction.CREATE_ENTITY, wrapper.action)
示例#6
0
 def _create_mock_events():
     gen_list = mock_sync.simple_zone_generators(
         2,
         4,
         snapshot_events=2,
         snap_vals={
             DatasourceProperties.DATASOURCE_ACTION:
             DatasourceAction.INIT_SNAPSHOT
         })
     gen_list += mock_sync.simple_host_generators(
         2,
         4,
         4,
         snap_vals={
             DatasourceProperties.DATASOURCE_ACTION:
             DatasourceAction.INIT_SNAPSHOT
         })
     gen_list += mock_sync.simple_instance_generators(
         4,
         15,
         15,
         snap_vals={
             DatasourceProperties.DATASOURCE_ACTION:
             DatasourceAction.INIT_SNAPSHOT
         })
     return mock_sync.generate_sequential_events_list(gen_list)
示例#7
0
 def _create_mock_events():
     gen_list = mock_sync.simple_zone_generators(
         2, 4, snapshot_events=2, snap_vals={'sync_mode': 'init_snapshot'})
     gen_list += mock_sync.simple_host_generators(
         2, 4, 4, snap_vals={'sync_mode': 'init_snapshot'})
     gen_list += mock_sync.simple_instance_generators(
         4, 15, 15, snap_vals={'sync_mode': 'init_snapshot'})
     return mock_sync.generate_sequential_events_list(gen_list)
示例#8
0
文件: base.py 项目: Idandos/vitrage
 def _create_mock_events(self):
     gen_list = mock_driver.simple_zone_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         snapshot_events=self.NUM_ZONES,
         snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
     gen_list += mock_driver.simple_host_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         self.NUM_HOSTS,
         snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
     gen_list += mock_driver.simple_instance_generators(
         self.NUM_HOSTS,
         self.NUM_INSTANCES,
         self.NUM_INSTANCES,
         snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
     return mock_driver.generate_sequential_events_list(gen_list)
示例#9
0
 def _create_mock_events(self):
     gen_list = mock_sync.simple_zone_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         snapshot_events=self.NUM_ZONES,
         snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
     gen_list += mock_sync.simple_host_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         self.NUM_HOSTS,
         snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
     gen_list += mock_sync.simple_instance_generators(
         self.NUM_HOSTS,
         self.NUM_INSTANCES,
         self.NUM_INSTANCES,
         snap_vals={DSProps.SYNC_MODE: SyncMode.INIT_SNAPSHOT})
     return mock_sync.generate_sequential_events_list(gen_list)
示例#10
0
文件: base.py 项目: openstack/vitrage
 def _create_mock_events(self):
     gen_list = mock_sync.simple_zone_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         snapshot_events=self.NUM_ZONES,
         snap_vals={DSProps.DATASOURCE_ACTION:
                    DatasourceAction.INIT_SNAPSHOT})
     gen_list += mock_sync.simple_host_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         self.NUM_HOSTS,
         snap_vals={DSProps.DATASOURCE_ACTION:
                    DatasourceAction.INIT_SNAPSHOT})
     gen_list += mock_sync.simple_instance_generators(
         self.NUM_HOSTS,
         self.NUM_INSTANCES,
         self.NUM_INSTANCES,
         snap_vals={DSProps.DATASOURCE_ACTION:
                    DatasourceAction.INIT_SNAPSHOT})
     return mock_sync.generate_sequential_events_list(gen_list)
示例#11
0
文件: base.py 项目: danoffek/vitrage
 def _create_mock_events(self):
     gen_list = mock_driver.simple_zone_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         snapshot_events=self.NUM_ZONES,
         snap_vals={DSProps.DATASOURCE_ACTION:
                    DatasourceAction.INIT_SNAPSHOT})
     gen_list += mock_driver.simple_host_generators(
         self.NUM_ZONES,
         self.NUM_HOSTS,
         self.NUM_HOSTS,
         snap_vals={DSProps.DATASOURCE_ACTION:
                    DatasourceAction.INIT_SNAPSHOT})
     gen_list += mock_driver.simple_instance_generators(
         self.NUM_HOSTS,
         self.NUM_INSTANCES,
         self.NUM_INSTANCES,
         snap_vals={DSProps.DATASOURCE_ACTION:
                    DatasourceAction.INIT_SNAPSHOT})
     return mock_driver.generate_sequential_events_list(gen_list)