summaryrefslogtreecommitdiff
path: root/scripts/scalability/test_controller/utils.py
diff options
context:
space:
mode:
authordrebs <drebs@riseup.net>2017-10-28 07:58:51 -0200
committerdrebs <drebs@riseup.net>2017-11-02 09:36:31 -0200
commit21584bc33fdc672a0f59436ba5d66f66439d6366 (patch)
tree8e8b58fbfc82ef9898cd8cc6f6e2960b121be3d1 /scripts/scalability/test_controller/utils.py
parente3879ac206e66437cefbe968e77f757239640681 (diff)
[benchmarks] add code for stressing the server
Diffstat (limited to 'scripts/scalability/test_controller/utils.py')
-rw-r--r--scripts/scalability/test_controller/utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/scripts/scalability/test_controller/utils.py b/scripts/scalability/test_controller/utils.py
new file mode 100644
index 00000000..ebe55571
--- /dev/null
+++ b/scripts/scalability/test_controller/utils.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python
+
+import base64
+import errno
+import os
+import random
+
+
+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 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