2020-04-09 23:23:01 +08:00
|
|
|
from datetime import timedelta
|
|
|
|
|
|
|
|
from envs.monkey_zoo.blackbox.tests.exploitation import ExploitationTest
|
|
|
|
from envs.monkey_zoo.blackbox.tests.performance.performance_test_config import PerformanceTestConfig
|
|
|
|
from envs.monkey_zoo.blackbox.tests.performance.performance_test import PerformanceTest
|
2020-04-10 19:32:39 +08:00
|
|
|
from envs.monkey_zoo.blackbox.tests.performance.performance_test_workflow import PerformanceTestWorkflow
|
2020-04-09 23:23:01 +08:00
|
|
|
|
|
|
|
MAX_ALLOWED_SINGLE_PAGE_TIME = timedelta(seconds=2)
|
|
|
|
MAX_ALLOWED_TOTAL_TIME = timedelta(seconds=5)
|
|
|
|
|
2020-04-10 19:32:39 +08:00
|
|
|
MAP_RESOURCES = [
|
|
|
|
"api/map",
|
2020-04-09 23:23:01 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
|
2020-04-10 19:32:39 +08:00
|
|
|
class MapGenerationTest(PerformanceTest):
|
2020-04-09 23:23:01 +08:00
|
|
|
|
2020-04-10 19:32:39 +08:00
|
|
|
TEST_NAME = "Map generation performance test"
|
|
|
|
|
|
|
|
def __init__(self, island_client, config_parser, analyzers,
|
|
|
|
timeout, log_handler, break_on_timeout):
|
2020-04-09 23:23:01 +08:00
|
|
|
self.island_client = island_client
|
|
|
|
self.config_parser = config_parser
|
2020-04-10 19:32:39 +08:00
|
|
|
exploitation_test = ExploitationTest(MapGenerationTest.TEST_NAME, island_client,
|
|
|
|
config_parser, analyzers, timeout, log_handler)
|
|
|
|
performance_config = PerformanceTestConfig(max_allowed_single_page_time=MAX_ALLOWED_SINGLE_PAGE_TIME,
|
|
|
|
max_allowed_total_time=MAX_ALLOWED_TOTAL_TIME,
|
|
|
|
endpoints_to_test=MAP_RESOURCES,
|
|
|
|
break_on_timeout=break_on_timeout)
|
|
|
|
self.performance_test_workflow = PerformanceTestWorkflow(MapGenerationTest.TEST_NAME,
|
|
|
|
exploitation_test,
|
|
|
|
performance_config)
|
2020-04-09 23:23:01 +08:00
|
|
|
|
|
|
|
def run(self):
|
2020-04-10 19:32:39 +08:00
|
|
|
self.performance_test_workflow.run()
|