From 21584bc33fdc672a0f59436ba5d66f66439d6366 Mon Sep 17 00:00:00 2001 From: drebs Date: Sat, 28 Oct 2017 07:58:51 -0200 Subject: [benchmarks] add code for stressing the server --- scripts/scalability/test_controller/utils.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 scripts/scalability/test_controller/utils.py (limited to 'scripts/scalability/test_controller/utils.py') 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 -- cgit v1.2.3