diff options
author | drebs <drebs@riseup.net> | 2017-09-17 12:08:25 -0300 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2017-09-17 15:50:55 -0300 |
commit | cfff46ff9becdbe5cf48816870e625ed253ecc57 (patch) | |
tree | 8d239e4499f559d86ed17ea3632008303b25d485 /testing/tests/benchmarks/test_sqlite_blobs_backend.py | |
parent | f29abe28bd778838626d12fcabe3980a8ce4fa8c (diff) |
[refactor] move tests to root of repository
Tests entrypoint was in a testing/ subfolder in the root of the
repository. This was made mainly because we had some common files for
tests and we didn't want to ship them (files in testing/test_soledad,
which is itself a python package. This sometimes causes errors when
loading tests (it seems setuptools is confused with having one python
package in a subdirectory of another).
This commit moves the tests entrypoint to the root of the repository.
Closes: #8952
Diffstat (limited to 'testing/tests/benchmarks/test_sqlite_blobs_backend.py')
-rw-r--r-- | testing/tests/benchmarks/test_sqlite_blobs_backend.py | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/testing/tests/benchmarks/test_sqlite_blobs_backend.py b/testing/tests/benchmarks/test_sqlite_blobs_backend.py deleted file mode 100644 index e02cacad..00000000 --- a/testing/tests/benchmarks/test_sqlite_blobs_backend.py +++ /dev/null @@ -1,82 +0,0 @@ -import pytest -import os - -from uuid import uuid4 -from io import BytesIO - -from twisted.internet.defer import gatherResults -from twisted.internet.defer import DeferredSemaphore - -from leap.soledad.client._db.blobs import SQLiteBlobBackend - - -semaphore = DeferredSemaphore(2) - - -# -# put -# - -def put(backend, amount, data): - deferreds = [] - for _ in xrange(amount): - blob_id = uuid4().hex - fd = BytesIO(data) - size = len(data) - d = semaphore.run(backend.put, blob_id, fd, size) - deferreds.append(d) - return gatherResults(deferreds) - - -def create_put_test(amount, size): - - @pytest.inlineCallbacks - @pytest.mark.sqlite_blobs_backend_put - def test(txbenchmark, payload, tmpdir): - dbpath = os.path.join(tmpdir.strpath, 'blobs.db') - backend = SQLiteBlobBackend(dbpath, key='123') - data = payload(size) - yield txbenchmark(put, backend, amount, data) - - return test - - -test_sqlite_blobs_backend_put_1_10000k = create_put_test(1, 10000 * 1000) -test_sqlite_blobs_backend_put_10_1000k = create_put_test(10, 1000 * 1000) -test_sqlite_blobs_backend_put_100_100k = create_put_test(100, 100 * 1000) -test_sqlite_blobs_backend_put_1000_10k = create_put_test(1000, 10 * 1000) - - -# -# put -# - -@pytest.inlineCallbacks -def get(backend): - local = yield backend.list() - deferreds = [] - for blob_id in local: - d = backend.get(blob_id) - deferreds.append(d) - yield gatherResults(deferreds) - - -def create_get_test(amount, size): - - @pytest.inlineCallbacks - @pytest.mark.sqlite_blobs_backend_get - def test(txbenchmark, payload, tmpdir): - dbpath = os.path.join(tmpdir.strpath, 'blobs.db') - backend = SQLiteBlobBackend(dbpath, key='123') - data = payload(size) - - yield put(backend, amount, data) - yield txbenchmark(get, backend) - - return test - - -test_sqlite_blobs_backend_get_1_10000k = create_get_test(1, 10000 * 1000) -test_sqlite_blobs_backend_get_10_1000k = create_get_test(10, 1000 * 1000) -test_sqlite_blobs_backend_get_100_100k = create_get_test(100, 100 * 1000) -test_sqlite_blobs_backend_get_1000_10k = create_get_test(1000, 10 * 1000) |