summaryrefslogtreecommitdiff
path: root/testing/tests/perf/test_crypto.py
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2016-08-20 01:27:47 -0300
committerVictor Shyba <victor.shyba@gmail.com>2016-08-22 12:36:16 -0300
commit585d6b2461869594210639548549aa6be336e752 (patch)
tree009b19ad70caaae193abe59550eba3d6eb36774b /testing/tests/perf/test_crypto.py
parent062d781b734db60d0ae317eaf5b86c7d75abacd9 (diff)
[test] adds test for SoledadCrypto
10k, 100k, 500k, 1m, 10m and 50m for encryption and decryption of a whole document.
Diffstat (limited to 'testing/tests/perf/test_crypto.py')
-rw-r--r--testing/tests/perf/test_crypto.py48
1 files changed, 48 insertions, 0 deletions
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)