From 62d7b78131ee3d98e1b54d7d5741a883f76c3366 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Sun, 25 Jun 2023 13:12:19 +0300 Subject: [PATCH] [#73] preset: Allow to sleep before putting objects For large networks block propagation may take some time. If we do not wait enough, putting objects can fail for some containers. Signed-off-by: Evgenii Stratonikov --- scenarios/preset/preset_grpc.py | 7 +++++++ scenarios/preset/preset_s3.py | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/scenarios/preset/preset_grpc.py b/scenarios/preset/preset_grpc.py index 16b2544..a7b0b08 100755 --- a/scenarios/preset/preset_grpc.py +++ b/scenarios/preset/preset_grpc.py @@ -5,6 +5,7 @@ import json import random import sys import tempfile +import time from argparse import Namespace from concurrent.futures import ProcessPoolExecutor @@ -32,6 +33,8 @@ parser.add_argument('--endpoint', help='Node address') parser.add_argument('--update', help='Save existed containers') parser.add_argument('--ignore-errors', help='Ignore preset errors') parser.add_argument('--workers', help='Count of workers in preset. Max = 50, Default = 50', default=50) +parser.add_argument('--sleep', help='Time to sleep between container creation and object PUT (in seconds), ' + 'Default = 8', default=8) args: Namespace = parser.parse_args() print(args) @@ -74,6 +77,10 @@ def main(): if not ignore_errors: sys.exit(ERROR_WRONG_CONTAINERS_COUNT) + if args.sleep != 0: + print(f"Sleep for {args.sleep} seconds") + time.sleep(args.sleep) + print(f"Upload objects to each container: {args.preload_obj} ") payload_file = tempfile.NamedTemporaryFile() random_payload(payload_file, args.size) diff --git a/scenarios/preset/preset_s3.py b/scenarios/preset/preset_s3.py index f49c929..174e62c 100755 --- a/scenarios/preset/preset_s3.py +++ b/scenarios/preset/preset_s3.py @@ -4,6 +4,7 @@ import argparse import json import sys import tempfile +import time from concurrent.futures import ProcessPoolExecutor from helpers.cmd import random_payload @@ -22,6 +23,8 @@ parser.add_argument('--location', help='AWS location. Will be empty, if has not parser.add_argument('--versioning', help='True/False, False by default.') parser.add_argument('--ignore-errors', help='Ignore preset errors') parser.add_argument('--workers', help='Count of workers in preset. Max = 50, Default = 50', default=50) +parser.add_argument('--sleep', help='Time to sleep between container creation and object PUT (in seconds), ' + 'Default = 8', default=8) args = parser.parse_args() print(args) @@ -65,6 +68,10 @@ def main(): if not ignore_errors: sys.exit(ERROR_WRONG_CONTAINERS_COUNT) + if args.sleep != 0: + print(f"Sleep for {args.sleep} seconds") + time.sleep(args.sleep) + print(f"Upload objects to each bucket: {objects_per_bucket} ") payload_file = tempfile.NamedTemporaryFile() random_payload(payload_file, args.size)