diff options
author | drebs <drebs@riseup.net> | 2017-10-28 07:58:51 -0200 |
---|---|---|
committer | drebs <drebs@riseup.net> | 2017-11-02 09:36:31 -0200 |
commit | 21584bc33fdc672a0f59436ba5d66f66439d6366 (patch) | |
tree | 8e8b58fbfc82ef9898cd8cc6f6e2960b121be3d1 /scripts/scalability/test_controller/client/templates.py | |
parent | e3879ac206e66437cefbe968e77f757239640681 (diff) |
[benchmarks] add code for stressing the server
Diffstat (limited to 'scripts/scalability/test_controller/client/templates.py')
-rwxr-xr-x | scripts/scalability/test_controller/client/templates.py | 22 |
1 files changed, 2 insertions, 20 deletions
diff --git a/scripts/scalability/test_controller/client/templates.py b/scripts/scalability/test_controller/client/templates.py index dcf51fe1..434eda67 100755 --- a/scripts/scalability/test_controller/client/templates.py +++ b/scripts/scalability/test_controller/client/templates.py @@ -1,10 +1,7 @@ #!/usr/bin/env python -import base64 -import errno import mock import os -import random from argparse import ArgumentParser from io import BytesIO @@ -14,6 +11,8 @@ from twisted.internet import reactor, defer from leap.soledad.client._db.blobs import BlobManager +from test_controller.utils import mkdir_p, payload + DEFAULT_TARGET_DIR = './blob-templates' @@ -33,28 +32,11 @@ def _get_encrypt_function(user, path): return manager._encrypt_and_upload -def payload(size): - random.seed(1337) # same seed to avoid different bench results - payload_bytes = bytearray(random.getrandbits(8) for _ in xrange(size)) - # encode as base64 to avoid ascii encode/decode errors - return base64.b64encode(payload_bytes)[:size] # remove b64 overhead - - def _encrypt(path, data): encrypt = _get_encrypt_function('user-0', path) return encrypt('blob', BytesIO(data)) -def mkdir_p(path): - try: - os.makedirs(path) - except OSError as exc: # Python >2.5 - if exc.errno == errno.EEXIST and os.path.isdir(path): - pass - else: - raise - - def create_blob_templates(target_dir, amount, size): mkdir_p(target_dir) data = payload(size) |