summaryrefslogtreecommitdiff
path: root/scripts/scalability/test_controller/server/blobs.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/server/blobs.py
parente3879ac206e66437cefbe968e77f757239640681 (diff)
[benchmarks] add code for stressing the server
Diffstat (limited to 'scripts/scalability/test_controller/server/blobs.py')
-rw-r--r--scripts/scalability/test_controller/server/blobs.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/scripts/scalability/test_controller/server/blobs.py b/scripts/scalability/test_controller/server/blobs.py
new file mode 100644
index 00000000..2a60018d
--- /dev/null
+++ b/scripts/scalability/test_controller/server/blobs.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+import shutil
+import os
+
+from argparse import ArgumentParser
+
+from test_controller.utils import mkdir_p, payload
+
+
+def _create_blob(path, data):
+ if not os.path.isfile(path):
+ with open(path, 'w') as f:
+ f.write(data)
+
+
+def create_blobs(target_dir, amount, size):
+ data = payload(size * 1000)
+ for i in xrange(amount):
+ basedir = os.path.join(target_dir, '%d/default/0/0/0' % i)
+ mkdir_p(basedir)
+ _create_blob(os.path.join(basedir, '0'), data)
+
+
+def delete_blobs(target_dir):
+ if not os.path.isdir(target_dir):
+ return
+ for f in os.listdir(target_dir):
+ if f.isdigit():
+ directory = os.path.join(target_dir, f)
+ shutil.rmtree(directory)
+
+
+def parse_args():
+ parser = ArgumentParser()
+ parser.add_argument(
+ 'target_dir',
+ help='The target directory where templates will be written to.')
+ parser.add_argument(
+ '--amount', default=1000, type=int,
+ help='The amount of users to create blobs to.')
+ parser.add_argument(
+ '--size', default=1000, type=int,
+ help='The size of each template in KB.')
+ return parser.parse_args()
+
+
+if __name__ == '__main__':
+ args = parse_args()
+ create_blobs(args.target_dir, args.amount, args.size * 1000)