From 89dd40d77fbd602a415e5ae673d4166e1b432428 Mon Sep 17 00:00:00 2001 From: drebs Date: Sat, 9 Sep 2017 15:31:49 -0300 Subject: [test] selectivelly start events server on benchmarks Soledad's events server might be a pain for tests because if it is not properly initialized and shut down there might be parts of the server missing or leftover in the reactor after tests are run. With the recent changes to the way tests are invocated, there's the need to further isolate events server startup for benchmarks, otherwise it will conflict with other tests. This commit moves the events server setup to inside the pytest_collection_modifyitems() hook, where we can check if the benchmark subdir was selected and properly start the events server if needed. --- testing/tests/benchmarks/conftest.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'testing') diff --git a/testing/tests/benchmarks/conftest.py b/testing/tests/benchmarks/conftest.py index 377fc606..80eccb08 100644 --- a/testing/tests/benchmarks/conftest.py +++ b/testing/tests/benchmarks/conftest.py @@ -9,19 +9,12 @@ import time from twisted.internet import threads, reactor -# we have to manually setup the events server in order to be able to signal -# events. This is usually done by the enclosing application using soledad -# client (i.e. bitmask client). -from leap.common.events import server -server.ensure_server() - - # # pytest customizations # # mark benchmark tests using their group names (thanks ionelmc! :) -def pytest_collection_modifyitems(items): +def pytest_collection_modifyitems(items, config): for item in items: bench = item.get_marker("benchmark") if bench and bench.kwargs.get('group'): @@ -29,6 +22,14 @@ def pytest_collection_modifyitems(items): marker = getattr(pytest.mark, 'benchmark_' + group) item.add_marker(marker) + subdir = config.getoption('subdir') + if subdir == 'benchmarks': + # we have to manually setup the events server in order to be able to + # signal events. This is usually done by the enclosing application + # using soledad client (i.e. bitmask client). + from leap.common.events import server + server.ensure_server() + # # benchmark fixtures -- cgit v1.2.3