From 87e50d37f1dc1d8818cb7ecbe0ee0ac6c37746f8 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 14 May 2020 10:55:59 +0300 Subject: [PATCH] Small fixes: island reset added to telemetry performance test, fixed a bug on report generation test --- envs/monkey_zoo/blackbox/test_blackbox.py | 3 +-- .../blackbox/tests/performance/endpoint_performance_test.py | 3 --- .../blackbox/tests/performance/performance_test_workflow.py | 2 ++ .../tests/performance/report_generation_from_telemetries.py | 5 +++-- .../blackbox/tests/performance/telemetry_performance_test.py | 5 ++++- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/envs/monkey_zoo/blackbox/test_blackbox.py b/envs/monkey_zoo/blackbox/test_blackbox.py index 870b81868..88f5c12a8 100644 --- a/envs/monkey_zoo/blackbox/test_blackbox.py +++ b/envs/monkey_zoo/blackbox/test_blackbox.py @@ -166,5 +166,4 @@ class TestMonkeyBlackbox(object): MapGenerationFromTelemetryTest(island_client, quick_performance_tests).run() def test_telem_performance(self, island_client, quick_performance_tests): - if not quick_performance_tests: - TelemetryPerformanceTest(island_client).test_telemetry_performance() + TelemetryPerformanceTest(island_client, quick_performance_tests).test_telemetry_performance() diff --git a/envs/monkey_zoo/blackbox/tests/performance/endpoint_performance_test.py b/envs/monkey_zoo/blackbox/tests/performance/endpoint_performance_test.py index 798f490af..b4f8f35c8 100644 --- a/envs/monkey_zoo/blackbox/tests/performance/endpoint_performance_test.py +++ b/envs/monkey_zoo/blackbox/tests/performance/endpoint_performance_test.py @@ -17,9 +17,6 @@ class EndpointPerformanceTest(BasicTest): self.island_client = island_client def run(self) -> bool: - if not self.island_client.is_all_monkeys_dead(): - raise RuntimeError("Can't test report times since not all Monkeys have died.") - # Collect timings for all pages self.island_client.clear_caches() endpoint_timings = {} diff --git a/envs/monkey_zoo/blackbox/tests/performance/performance_test_workflow.py b/envs/monkey_zoo/blackbox/tests/performance/performance_test_workflow.py index cdb4f08ac..4e708ed9d 100644 --- a/envs/monkey_zoo/blackbox/tests/performance/performance_test_workflow.py +++ b/envs/monkey_zoo/blackbox/tests/performance/performance_test_workflow.py @@ -23,6 +23,8 @@ class PerformanceTestWorkflow(BasicTest): self.island_client.kill_all_monkeys() self.exploitation_test.wait_until_monkeys_die() self.exploitation_test.wait_for_monkey_process_to_finish() + if not self.island_client.is_all_monkeys_dead(): + raise RuntimeError("Can't test report times since not all Monkeys have died.") performance_test = EndpointPerformanceTest(self.name, self.performance_config, self.island_client) try: if not self.island_client.is_all_monkeys_dead(): diff --git a/envs/monkey_zoo/blackbox/tests/performance/report_generation_from_telemetries.py b/envs/monkey_zoo/blackbox/tests/performance/report_generation_from_telemetries.py index a08bbda70..abc2b35c2 100644 --- a/envs/monkey_zoo/blackbox/tests/performance/report_generation_from_telemetries.py +++ b/envs/monkey_zoo/blackbox/tests/performance/report_generation_from_telemetries.py @@ -21,7 +21,7 @@ class ReportGenerationFromTelemetryTest(PerformanceTest): TEST_NAME = "Map generation from fake telemetries test" - def __init__(self, island_client, break_on_timeout=False): + def __init__(self, island_client, quick_performance_test, break_on_timeout=False): self.island_client = island_client performance_config = PerformanceTestConfig(max_allowed_single_page_time=MAX_ALLOWED_SINGLE_PAGE_TIME, max_allowed_total_time=MAX_ALLOWED_TOTAL_TIME, @@ -29,7 +29,8 @@ class ReportGenerationFromTelemetryTest(PerformanceTest): break_on_timeout=break_on_timeout) self.performance_test_workflow = TelemetryPerformanceTestWorkflow(ReportGenerationFromTelemetryTest.TEST_NAME, self.island_client, - performance_config) + performance_config, + quick_performance_test) def run(self): self.performance_test_workflow.run() diff --git a/envs/monkey_zoo/blackbox/tests/performance/telemetry_performance_test.py b/envs/monkey_zoo/blackbox/tests/performance/telemetry_performance_test.py index 4de77e41a..699876cce 100644 --- a/envs/monkey_zoo/blackbox/tests/performance/telemetry_performance_test.py +++ b/envs/monkey_zoo/blackbox/tests/performance/telemetry_performance_test.py @@ -18,8 +18,9 @@ MAX_ALLOWED_TOTAL_TIME = timedelta(seconds=60) class TelemetryPerformanceTest: - def __init__(self, island_client: MonkeyIslandClient): + def __init__(self, island_client: MonkeyIslandClient, quick_performance_test: bool): self.island_client = island_client + self.quick_performance_test = quick_performance_test def test_telemetry_performance(self): LOGGER.info("Starting telemetry performance test.") @@ -36,6 +37,8 @@ class TelemetryPerformanceTest: telemetry_parse_times[telemetry_endpoint] = self.get_telemetry_time(telemetry) test_config = PerformanceTestConfig(MAX_ALLOWED_SINGLE_TELEM_PARSE_TIME, MAX_ALLOWED_TOTAL_TIME) PerformanceAnalyzer(test_config, telemetry_parse_times).analyze_test_results() + if not self.quick_performance_test: + self.island_client.reset_env() def get_telemetry_time(self, telemetry): content = telemetry['content']