From 5af57250f2b1cd174fa75c559bac6ea179c43d09 Mon Sep 17 00:00:00 2001 From: drebs Date: Tue, 28 Feb 2017 10:22:06 -0300 Subject: [test] bugfix: actually use an empty local db in download benchmarks We were previously not using an empty local db for download benchmark tests, so there was actually nothing to sync. This commit fixes that by adding a way to force an empty local db on soledad client instantiation. --- testing/tests/benchmarks/test_sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'testing/tests/benchmarks') diff --git a/testing/tests/benchmarks/test_sync.py b/testing/tests/benchmarks/test_sync.py index 1501d74b..ee2e2960 100644 --- a/testing/tests/benchmarks/test_sync.py +++ b/testing/tests/benchmarks/test_sync.py @@ -41,7 +41,7 @@ def create_download(downloads, size): # ensures we are dealing with properly encrypted docs def setup(): - return soledad_client() + return soledad_client(force_fresh_db=True) def sync(clean_client): return clean_client.sync() -- cgit v1.2.3 From 6deadf8adeb8c6b4a98e2d69e2bf3b1447a6b4ca Mon Sep 17 00:00:00 2001 From: drebs Date: Wed, 1 Mar 2017 13:39:04 -0300 Subject: [test] mark benchmark tests using their group names --- testing/tests/benchmarks/conftest.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'testing/tests/benchmarks') diff --git a/testing/tests/benchmarks/conftest.py b/testing/tests/benchmarks/conftest.py index a9cc3464..1b99d96e 100644 --- a/testing/tests/benchmarks/conftest.py +++ b/testing/tests/benchmarks/conftest.py @@ -12,12 +12,30 @@ from leap.common.events import server server.ensure_server() +# +# pytest customizations +# + def pytest_addoption(parser): parser.addoption( "--num-docs", type="int", default=100, help="the number of documents to use in performance tests") +# mark benchmark tests using their group names (thanks ionelmc! :) +def pytest_collection_modifyitems(items): + for item in items: + bench = item.get_marker("benchmark") + if bench and bench.kwargs.get('group'): + group = bench.kwargs['group'] + marker = getattr(pytest.mark, 'benchmark_' + group) + item.add_marker(marker) + + +# +# benchmark fixtures +# + @pytest.fixture() def payload(): def generate(size): -- cgit v1.2.3 From 32c6d2eae998ceec302995e52c70a0636ca1e463 Mon Sep 17 00:00:00 2001 From: drebs Date: Thu, 2 Mar 2017 15:47:04 -0300 Subject: [test] add comments explaining behaviour of upload/download benchmark --- testing/tests/benchmarks/test_sync.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'testing/tests/benchmarks') diff --git a/testing/tests/benchmarks/test_sync.py b/testing/tests/benchmarks/test_sync.py index ee2e2960..fcfab998 100644 --- a/testing/tests/benchmarks/test_sync.py +++ b/testing/tests/benchmarks/test_sync.py @@ -11,6 +11,12 @@ def load_up(client, amount, payload): yield gatherResults(deferreds) +# Each test created with this function will: +# +# - get a fresh client. +# - iterate: +# - setup: create N docs of a certain size +# - benchmark: sync() -- uploads N docs. def create_upload(uploads, size): @pytest.inlineCallbacks @pytest.mark.benchmark(group="test_upload") @@ -29,6 +35,14 @@ test_upload_100_100k = create_upload(100, 100 * 1000) test_upload_1000_10k = create_upload(1000, 10 * 1000) +# Each test created with this function will: +# +# - get a fresh client. +# - create N docs of a certain size +# - sync (uploads those docs) +# - iterate: +# - setup: get a fresh client with empty local db +# - benchmark: sync() -- downloads N docs. def create_download(downloads, size): @pytest.inlineCallbacks @pytest.mark.benchmark(group="test_download") -- cgit v1.2.3