diff options
Diffstat (limited to 'client-responsiveness/scripts/create_payload.py')
-rwxr-xr-x | client-responsiveness/scripts/create_payload.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/client-responsiveness/scripts/create_payload.py b/client-responsiveness/scripts/create_payload.py new file mode 100755 index 0000000..d051661 --- /dev/null +++ b/client-responsiveness/scripts/create_payload.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +""" +Create a payload file in disk to use during tests. Reads the name of the file +and the intended size of the payload from the "defaults.conf" file: + + PAYLOAD = /path/to/payload/file + PAYLOAD_SIZE = 500 # in Kb +""" + +import os +from ConfigParser import ConfigParser + +parser = ConfigParser() +parser.read('defaults.conf') + +PAYLOAD = parser.get('sync', 'payload') +PAYLOAD_SIZE = int(parser.get('sync', 'payload_size')) * 1024 + +if os.path.isfile(PAYLOAD): + os.unlink(PAYLOAD) + +content = 'a' * 1024 + +with open(PAYLOAD, 'w') as f: + length = 0 + while length < PAYLOAD_SIZE: + f.write(content) + length += len(content) |