def test_report_transactions_as_failed(self): self.configure({ "execution": [{ "test-mode": "apiritif", "iterations": 1, "scenario": { "default-address": "http://httpbin.org", "requests": [{ "label": "failure by 404", "url": "/status/404", }] } }] }) self.obj.engine.aggregator = FunctionalAggregator() self.obj.prepare() try: self.obj.startup() while not self.obj.check(): time.sleep(self.obj.engine.check_interval) finally: self.obj.shutdown() self.obj.post_process() self.assertNotEquals(self.obj.process, None) reader = LoadSamplesReader(os.path.join(self.obj.engine.artifacts_dir, "apiritif.0.ldjson"), self.obj.log) samples = list(reader._read(last_pass=True)) self.assertEqual(len(samples), 1) tstmp, label, concur, rtm, cnn, ltc, rcd, error, trname, byte_count = samples[0] self.assertIsNotNone(error)
def test_report_transactions_as_failed(self): self.configure({ "execution": [{ "test-mode": "apiritif", "iterations": 1, "scenario": { "default-address": "http://httpbin.org", "requests": [{ "label": "failure by 404", "url": "/status/404", }] } }] }) self.obj.engine.aggregator = FunctionalAggregator() self.obj.prepare() try: self.obj.startup() while not self.obj.check(): time.sleep(self.obj.engine.check_interval) finally: self.obj.shutdown() self.obj.post_process() self.assertNotEquals(self.obj.process, None) reader = LoadSamplesReader( os.path.join(self.obj.engine.artifacts_dir, "apiritif.0.ldjson"), self.obj.log) samples = list(reader._read(last_pass=True)) self.assertEqual(len(samples), 1) tstmp, label, concur, rtm, cnn, ltc, rcd, error, trname, byte_count = samples[ 0] self.assertIsNotNone(error)
def test_report_transactions_as_failed(self): self.configure({ "execution": [{ "test-mode": "apiritif", "scenario": { "default-address": "http://httpbin.org", "requests": [{ "label": "failure by 404", "url": "/status/404", }] } }] }) self.obj.prepare() try: self.obj.startup() while not self.obj.check(): time.sleep(self.obj.engine.check_interval) finally: self.obj.shutdown() self.obj.post_process() self.assertNotEquals(self.obj.process, None) with open(self.obj.report_file) as fds: self.obj.log.debug("Report: %s", fds.read()) reader = LoadSamplesReader(self.obj.report_file, self.obj.log) samples = list(reader._read(last_pass=True)) self.assertEqual(len(samples), 1) tstmp, label, concur, rtm, cnn, ltc, rcd, error, trname, byte_count = samples[ 0] self.assertIsNotNone(error)
def test_report_reader(self): reader = LoadSamplesReader(RESOURCES_DIR + "selenium/report.ldjson", ROOT_LOGGER) items = list(reader._read(last_pass=True)) self.assertEqual(4, len(items)) self.assertEqual(items[0][1], 'testFailure') self.assertEqual(items[0][6], '400') self.assertEqual(items[1][1], 'testBroken') self.assertEqual(items[1][6], '500') self.assertEqual(items[2][1], 'testSuccess') self.assertEqual(items[2][6], '200') self.assertEqual(items[3][1], 'testUnexp') self.assertEqual(items[3][6], 'UNKNOWN')
def test_report_reader(self): reader = LoadSamplesReader(RESOURCES_DIR + "selenium/report.ldjson", ROOT_LOGGER) items = list(reader._read(last_pass=True)) self.assertEqual(4, len(items)) self.assertEqual(items[0][1], 'testFailure') self.assertEqual(items[0][6], '400') self.assertEqual(items[1][1], 'testBroken') self.assertEqual(items[1][6], '500') self.assertEqual(items[2][1], 'testSuccess') self.assertEqual(items[2][6], '200') self.assertEqual(items[3][1], 'testUnexp') self.assertEqual(items[3][6], 'UNKNOWN')
def test_report_reader(self): reader = LoadSamplesReader(__dir__() + "/../../resources/selenium/report.ldjson", logging.getLogger(), None) items = list(reader._read()) self.assertEqual(4, len(items)) self.assertEqual(items[0][1], 'testFailure') self.assertEqual(items[0][6], '400') self.assertEqual(items[1][1], 'testBroken') self.assertEqual(items[1][6], '500') self.assertEqual(items[2][1], 'testSuccess') self.assertEqual(items[2][6], '200') self.assertEqual(items[3][1], 'testUnexp') self.assertEqual(items[3][6], 'UNKNOWN')
def reporting_setup(self, prefix=None, suffix=None): if not self.reported: self.log.debug("Skipping reporting setup for executor %s", self) return if "report-file" in self.execution: self.report_file = self.execution.get("report-file") else: if not prefix: prefix = self.__class__.__name__ if suffix is None: suffix = '.dat' self.report_file = self.engine.create_artifact(prefix, suffix) self.report_file = self.report_file.replace(os.path.sep, '/') if not self.register_reader: self.log.debug("Skipping reader setup for executor %s", self) return if self.engine.is_functional_mode(): self.reader = FuncSamplesReader(self.report_file, self.engine, self.log) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(self.reader) else: self.reader = LoadSamplesReader(self.report_file, self.log) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(self.reader)
def startup(self): """ run python tests """ executable = self.settings.get("interpreter", sys.executable) if "report-file" in self.execution: report_file = self.execution.get("report-file") else: report_file = self.engine.create_artifact("report", ".ldjson") if self.engine.is_functional_mode(): self.reader = FuncSamplesReader(report_file, self.engine, self.log, []) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(self.reader) else: self.reader = LoadSamplesReader(report_file, self.log, []) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(self.reader) nose_command_line = [ executable, self.plugin_path, '--report-file', report_file ] load = self.get_load() if load.iterations: nose_command_line += ['-i', str(load.iterations)] if load.hold: nose_command_line += ['-d', str(load.hold)] nose_command_line += [self._script] self._start_subprocess(nose_command_line)
def reporting_setup(self, prefix=None, suffix=None, translation_table=None): if not self.reported: return if translation_table is None: translation_table = {} if "report-file" in self.execution: self.report_file = self.execution.get("report-file") else: if not prefix: prefix = self.__class__.__name__ if suffix is None: suffix = '.dat' self.report_file = self.engine.create_artifact(prefix, suffix) self.report_file = self.report_file.replace(os.path.sep, '/') if self.engine.is_functional_mode(): self.reader = FuncSamplesReader(self.report_file, self.engine, self.log, translation_table) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(self.reader) else: self.reader = LoadSamplesReader(self.report_file, self.log, translation_table) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(self.reader)
def _register_reader(self, report_file): if self.engine.is_functional_mode(): reader = FuncSamplesReader(report_file, self.engine, self.log, self.generated_methods) if isinstance(self.engine.aggregator, FunctionalAggregator): self.engine.aggregator.add_underling(reader) else: reader = LoadSamplesReader(report_file, self.log, self.generated_methods) if isinstance(self.engine.aggregator, ConsolidatingAggregator): self.engine.aggregator.add_underling(reader) return reader
def create_load_reader(self, report_file): return LoadSamplesReader(report_file, self.log)