[#57] preset: Use temporary file for payload
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
da01f4bc2a
commit
2e918c57d5
3 changed files with 11 additions and 10 deletions
|
@ -19,10 +19,9 @@ def execute_cmd(cmd_line):
|
|||
return output, success
|
||||
|
||||
|
||||
def random_payload(payload_filepath, size):
|
||||
with open('%s' % payload_filepath, 'w+b') as fout:
|
||||
fout.write(os.urandom(1024 * int(size)))
|
||||
|
||||
def random_payload(file, size):
|
||||
file.write(os.urandom(1024 * int(size)))
|
||||
file.flush()
|
||||
|
||||
class ProgressBar:
|
||||
@staticmethod
|
||||
|
|
|
@ -4,6 +4,7 @@ import argparse
|
|||
import json
|
||||
import random
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
from argparse import Namespace
|
||||
from concurrent.futures import ProcessPoolExecutor
|
||||
|
@ -39,7 +40,6 @@ print(args)
|
|||
def main():
|
||||
container_list = []
|
||||
objects_list = []
|
||||
payload_filepath = '/tmp/data_file'
|
||||
|
||||
endpoints = args.endpoint.split(',')
|
||||
|
||||
|
@ -71,13 +71,14 @@ def main():
|
|||
sys.exit(ERROR_NO_CONTAINERS)
|
||||
|
||||
print(f"Upload objects to each container: {args.preload_obj} ")
|
||||
random_payload(payload_filepath, args.size)
|
||||
payload_file = tempfile.NamedTemporaryFile()
|
||||
random_payload(payload_file, args.size)
|
||||
print(" > Create random payload: Completed")
|
||||
|
||||
for container in container_list:
|
||||
print(f" > Upload objects for container {container}")
|
||||
with ProcessPoolExecutor(max_workers=min(MAX_WORKERS, workers)) as executor:
|
||||
objects_runs = {executor.submit(upload_object, container, payload_filepath,
|
||||
objects_runs = {executor.submit(upload_object, container, payload_file.name,
|
||||
endpoints[random.randrange(len(endpoints))], wallet, wallet_config): _ for _ in range(int(args.preload_obj))}
|
||||
|
||||
for run in objects_runs:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import argparse
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
from concurrent.futures import ProcessPoolExecutor
|
||||
|
||||
from helpers.cmd import random_payload
|
||||
|
@ -32,7 +33,6 @@ MAX_WORKERS = 50
|
|||
def main():
|
||||
bucket_list = []
|
||||
objects_list = []
|
||||
payload_filepath = '/tmp/data_file'
|
||||
ignore_errors = True if args.ignore_errors else False
|
||||
|
||||
workers = int(args.workers)
|
||||
|
@ -62,13 +62,14 @@ def main():
|
|||
sys.exit(ERROR_NO_BUCKETS)
|
||||
|
||||
print(f"Upload objects to each bucket: {args.preload_obj} ")
|
||||
random_payload(payload_filepath, args.size)
|
||||
payload_file = tempfile.NamedTemporaryFile()
|
||||
random_payload(payload_file, args.size)
|
||||
print(" > Create random payload: Completed")
|
||||
|
||||
for bucket in bucket_list:
|
||||
print(f" > Upload objects for bucket {bucket}")
|
||||
with ProcessPoolExecutor(max_workers=min(MAX_WORKERS, workers)) as executor:
|
||||
objects_runs = {executor.submit(upload_object, bucket, payload_filepath,
|
||||
objects_runs = {executor.submit(upload_object, bucket, payload_file.name,
|
||||
args.endpoint): _ for _ in range(int(args.preload_obj))}
|
||||
|
||||
for run in objects_runs:
|
||||
|
|
Loading…
Reference in a new issue