From 585d6b2461869594210639548549aa6be336e752 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Sat, 20 Aug 2016 01:27:47 -0300 Subject: [test] adds test for SoledadCrypto 10k, 100k, 500k, 1m, 10m and 50m for encryption and decryption of a whole document. --- testing/tests/perf/test_crypto.py | 48 +++++++++++++++++++++++++++++++++++ testing/tests/perf/test_encdecpool.py | 18 ++++++------- 2 files changed, 57 insertions(+), 9 deletions(-) create mode 100644 testing/tests/perf/test_crypto.py diff --git a/testing/tests/perf/test_crypto.py b/testing/tests/perf/test_crypto.py new file mode 100644 index 00000000..84c89a0d --- /dev/null +++ b/testing/tests/perf/test_crypto.py @@ -0,0 +1,48 @@ +import pytest +import json +from uuid import uuid4 +from leap.soledad.common.document import SoledadDocument + + +def create_doc_encryption(size): + @pytest.mark.benchmark(group="test_crypto_encrypt_doc") + def test_doc_encryption(soledad_client, benchmark): + crypto = soledad_client()._crypto + + DOC_CONTENT = {'payload': 'x'*size} + doc = SoledadDocument( + doc_id=uuid4().hex, rev='rev', + json=json.dumps(DOC_CONTENT)) + + benchmark(crypto.encrypt_doc, doc) + return test_doc_encryption + + +def create_doc_decryption(size): + @pytest.mark.benchmark(group="test_crypto_decrypt_doc") + def test_doc_decryption(soledad_client, benchmark): + crypto = soledad_client()._crypto + + DOC_CONTENT = {'payload': 'x'*size} + doc = SoledadDocument( + doc_id=uuid4().hex, rev='rev', + json=json.dumps(DOC_CONTENT)) + encrypted_doc = crypto.encrypt_doc(doc) + doc.set_json(encrypted_doc) + + benchmark(crypto.decrypt_doc, doc) + return test_doc_decryption + + +test_encrypt_doc_10k = create_doc_encryption(10*1000) +test_encrypt_doc_100k = create_doc_encryption(100*1000) +test_encrypt_doc_500k = create_doc_encryption(500*1000) +test_encrypt_doc_1M = create_doc_encryption(1000*1000) +test_encrypt_doc_10M = create_doc_encryption(10*1000*1000) +test_encrypt_doc_50M = create_doc_encryption(50*1000*1000) +test_decrypt_doc_10k = create_doc_decryption(10*1000) +test_decrypt_doc_100k = create_doc_decryption(100*1000) +test_decrypt_doc_500k = create_doc_decryption(500*1000) +test_decrypt_doc_1M = create_doc_decryption(1000*1000) +test_decrypt_doc_10M = create_doc_decryption(10*1000*1000) +test_decrypt_doc_50M = create_doc_decryption(50*1000*1000) diff --git a/testing/tests/perf/test_encdecpool.py b/testing/tests/perf/test_encdecpool.py index dbbbea89..abc58e35 100644 --- a/testing/tests/perf/test_encdecpool.py +++ b/testing/tests/perf/test_encdecpool.py @@ -35,10 +35,10 @@ def create_encrypt(amount, size): yield txbenchmark_with_setup(setup, put_and_wait) return test -test_encrypt_1000_10k = create_encrypt(1000, 10*1000) -# test_encrypt_1000_500k = create_encrypt(1000, 500*1000) -# test_encrypt_1000_1M = create_encrypt(1000, 1000*1000) -# test_encrypt_1000_10M = create_encrypt(1000, 10*1000*1000) +test_encdecpool_encrypt_1000_10k = create_encrypt(1000, 10*1000) +# test_encdecpool_encrypt_1000_500k = create_encrypt(1000, 500*1000) +# test_encdecpool_encrypt_1000_1M = create_encrypt(1000, 1000*1000) +# test_encdecpool_encrypt_1000_10M = create_encrypt(1000, 10*1000*1000) def create_decrypt(amount, size): @@ -76,9 +76,9 @@ def create_decrypt(amount, size): yield txbenchmark_with_setup(setup, put_and_wait) return test -test_decrypt_1000_10k = create_decrypt(1000, 10*1000) -test_decrypt_1000_100k = create_decrypt(1000, 10*1000) +test_encdecpool_decrypt_1000_10k = create_decrypt(1000, 10*1000) +test_encdecpool_decrypt_1000_100k = create_decrypt(1000, 10*1000) # memory issues ahead -# test_decrypt_1000_500k = create_decrypt(1000, 500*1000) -# test_decrypt_1000_1M = create_decrypt(1000, 1000*1000) -# test_decrypt_1000_10M = create_decrypt(1000, 10*1000*1000) +# test_encdecpool_decrypt_1000_500k = create_decrypt(1000, 500*1000) +# test_encdecpool_decrypt_1000_1M = create_decrypt(1000, 1000*1000) +# test_encdecpool_decrypt_1000_10M = create_decrypt(1000, 10*1000*1000) -- cgit v1.2.3