summaryrefslogtreecommitdiff
path: root/testing/tests/perf/conftest.py
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2016-08-29 00:05:45 -0300
committerVictor Shyba <victor.shyba@gmail.com>2016-08-29 12:26:24 -0300
commitd86831e4cd3e77f340618168528e62cf4dafb5d7 (patch)
treed5491c9ec432729d41c177d9753c80e7598046e2 /testing/tests/perf/conftest.py
parent49d4013819733966c05178254725e6a89f1909fe (diff)
[test] randomize payload
We were using 'x'*size as payload, but on real usage the payload will be random. This commit randomizes the payload using a predefined seed, so the random payload will be the same across benchmarks. Using random payloads also improves accuracy of compression or encoding impacts and we will be evaluating those changes for resouce usage issues. Also note that base64 is used on payload. That was needed for utf8 safety, but overhead was removed to leave payloads as defined by benchmarks. Base64 was chosen also due its popular usage on MIME encoding, which is used on mail attachments (our current scenario).
Diffstat (limited to 'testing/tests/perf/conftest.py')
-rw-r--r--testing/tests/perf/conftest.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/testing/tests/perf/conftest.py b/testing/tests/perf/conftest.py
index 9abd0c54..3681025f 100644
--- a/testing/tests/perf/conftest.py
+++ b/testing/tests/perf/conftest.py
@@ -2,6 +2,8 @@ import json
import os
import pytest
import requests
+import random
+import base64
import signal
import time
@@ -43,6 +45,16 @@ DEFAULT_CERTKEY = 'soledad_certkey.pem'
DEFAULT_TOKEN = 'an-auth-token'
+@pytest.fixture()
+def payload():
+ def generate(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
+ return generate
+
+
#
# soledad_dbs fixture: provides all databases needed by soledad server in a per
# module scope (same databases for all tests in this module).