def test_entity_loader(self):
     utils.load_converter('forwarder',
                          base_class_type=Transceiver,
                          *(),
                          **{
                              'frontend': '0',
                              'backend': '1',
                              'kind': 'forwarder',
                              'name': 'DUT'
                          })
     utils.load_converter('example_converter',
                          base_class_type=Transceiver,
                          *(),
                          **{
                              'frontend': '0',
                              'backend': '1',
                              'kind': 'example_converter',
                              'name': 'DUT'
                          })
     utils.load_receiver('example_receiver',
                         base_class_type=Receiver,
                         *(),
                         **{
                             'frontend': '0',
                             'kind': 'example_receiver',
                             'name': 'DUT'
                         })
     utils.load_producer_sim('example_producer_sim',
                             base_class_type=producer_sim.ProducerSim,
                             *(),
                             **{
                                 'backend': '0',
                                 'kind': 'example_producer_sim',
                                 'name': 'DUT'
                             })
 def test_entity_loader(self):
     utils.load_converter('forwarder', base_class_type=Transceiver, *(), **{'frontend': '0',
                                                                            'backend': '1',
                                                                            'kind': 'forwarder',
                                                                            'name': 'DUT'})
     utils.load_converter('example_converter', base_class_type=Transceiver, *(), **{'frontend': '0',
                                                                                    'backend': '1',
                                                                                    'kind': 'example_converter',
                                                                                    'name': 'DUT'})
     utils.load_receiver('example_receiver', base_class_type=Receiver, *(), **{'frontend': '0',
                                                                               'kind': 'example_receiver',
                                                                               'name': 'DUT'})
     utils.load_producer_sim('example_producer_sim', base_class_type=producer_sim.ProducerSim, *(), **{'backend': '0',
                                                                                                       'kind': 'example_producer_sim',
                                                                                                       'name': 'DUT'})
    def start(self):
        try:
            self.configuration['producer_sim']
        except KeyError:
            logging.info('No producer simulation defined in config file')
            logging.info('Close producer simulation manager')
            return
        logging.info('Starting %d producer simulations', len(self.configuration['producer_sim']))
        producer_sims, process_infos = [], []

        for (producer_sim_name, producer_sim_settings) in self.configuration['producer_sim'].items():
            producer_sim_settings['name'] = producer_sim_name
            producer_sim = utils.load_producer_sim(producer_sim_settings['kind'], base_class_type=ProducerSim, *(), **producer_sim_settings)
            producer_sim.start()
            process_infos.append((producer_sim_name, psutil.Process(producer_sim.ident)))
            producer_sims.append(producer_sim)
        try:
            while True:
                self._info_output(process_infos)
                time.sleep(1)
        except KeyboardInterrupt:
            logging.info('CRTL-C pressed, shutting down %d producer simulations', len(self.configuration['producer_sim']))
            for producer_sim in producer_sims:
                producer_sim.shutdown()

        for producer_sim in producer_sims:
            producer_sim.join()
        logging.info('Close producer simulation manager')
Exemple #4
0
    def start(self):
        try:
            self.configuration['producer_sim']
        except KeyError:
            logging.info('No producer simulation defined in config file')
            logging.info('Close producer simulation manager')
            return
        logging.info('Starting %d producer simulations',
                     len(self.configuration['producer_sim']))
        producer_sims, process_infos = [], []

        for (producer_sim_name, producer_sim_settings
             ) in self.configuration['producer_sim'].items():
            producer_sim_settings['name'] = producer_sim_name
            producer_sim = utils.load_producer_sim(
                producer_sim_settings['kind'],
                base_class_type=ProducerSim,
                *(),
                **producer_sim_settings)
            producer_sim.start()
            process_infos.append(
                (producer_sim_name, psutil.Process(producer_sim.ident)))
            producer_sims.append(producer_sim)
        try:
            while True:
                self._info_output(process_infos)
                time.sleep(1)
        except KeyboardInterrupt:
            logging.info(
                'CRTL-C pressed, shutting down %d producer simulations',
                len(self.configuration['producer_sim']))
            for producer_sim in producer_sims:
                producer_sim.shutdown()

        for producer_sim in producer_sims:
            producer_sim.join()
        logging.info('Close producer simulation manager')