def test_agregator(phout, expected_rps): generator = PhantomMock(phout) aggregator = TankAggregator(generator) listener = ListenerMock(expected_rps) aggregator.add_result_listener(listener) aggregator.start_test(poll_period=0) while not generator.reader.closed: aggregator.is_test_finished() aggregator.end_test(1) assert abs(listener.avg - expected_rps) < 0.1 * expected_rps
def test_agregator(phout, expected_rps): generator = PhantomMock(os.path.join(PATH, phout)) aggregator = TankAggregator(generator) listener = ListenerMock(expected_rps) aggregator.add_result_listener(listener) aggregator.start_test(poll_period=0) generator.finished.set() while not aggregator.is_aggr_finished(): aggregator.is_test_finished() aggregator.end_test(1) assert abs(listener.avg - expected_rps) < 0.1 * expected_rps
def job(self): if not self._job: # monitoring plugin monitorings = [plugin for plugin in self.plugins.values() if isinstance(plugin, MonitoringPlugin)] # generator plugin try: gen = self.get_plugin_of_type(GeneratorPlugin) except KeyError: logger.warning("Load generator not found") gen = GeneratorPlugin(self, {}, 'generator dummy') # aggregator aggregator = TankAggregator(gen) self._job = Job(monitoring_plugins=monitorings, generator_plugin=gen, aggregator=aggregator, tank=socket.getfqdn()) return self._job
def job(self): if not self._job: # monitoring plugin try: mon = self.get_plugin_of_type(TelegrafPlugin) except KeyError: logger.debug("Telegraf plugin not found:", exc_info=True) mon = None # generator plugin try: gen = self.get_plugin_of_type(GeneratorPlugin) except KeyError: logger.warning("Load generator not found") gen = GeneratorPlugin() # aggregator aggregator = TankAggregator(gen) self._job = Job(monitoring_plugin=mon, generator_plugin=gen, aggregator=aggregator, tank=socket.getfqdn()) return self._job