From 279bb3dedd9a65bd4b27145e56098351579001b2 Mon Sep 17 00:00:00 2001 From: Vladimir Domnich Date: Mon, 25 Jul 2022 16:44:11 +0300 Subject: [PATCH] Add delays after s3 operations Delays were added after: - S3 container create/delete. - S3 object create/delete. Signed-off-by: Vladimir Domnich --- robot/resources/lib/python_keywords/s3_gate_bucket.py | 10 +++++++--- robot/resources/lib/python_keywords/s3_gate_object.py | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/robot/resources/lib/python_keywords/s3_gate_bucket.py b/robot/resources/lib/python_keywords/s3_gate_bucket.py index c8073a0..0f9af21 100644 --- a/robot/resources/lib/python_keywords/s3_gate_bucket.py +++ b/robot/resources/lib/python_keywords/s3_gate_bucket.py @@ -4,6 +4,7 @@ import json import os import uuid from enum import Enum +from time import sleep import boto3 from data_formatters import pub_key_hex @@ -23,10 +24,12 @@ urllib3.disable_warnings() ROBOT_AUTO_KEYWORDS = False CREDENTIALS_CREATE_TIMEOUT = '30s' - NEOFS_EXEC = os.getenv('NEOFS_EXEC', 'neofs-authmate') -ASSETS_DIR = os.getenv('ASSETS_DIR', 'TemporaryDir/') +# Artificial delay that we add after object deletion and container creation +# Delay is added because sometimes immediately after deletion object still appears +# to be existing (probably because tombstone object takes some time to replicate) +S3_SYNC_WAIT_TIME = 5 class VersioningStatus(Enum): ENABLED = 'Enabled' @@ -94,6 +97,7 @@ def create_bucket_s3(s3_client): try: s3_bucket = s3_client.create_bucket(Bucket=bucket_name) log_command_execution(f'Created S3 bucket {bucket_name}', s3_bucket) + sleep(S3_SYNC_WAIT_TIME) return bucket_name except ClientError as err: @@ -123,7 +127,7 @@ def delete_bucket_s3(s3_client, bucket: str): try: response = s3_client.delete_bucket(Bucket=bucket) log_command_execution('S3 Delete bucket result', response) - + sleep(S3_SYNC_WAIT_TIME) return response except ClientError as err: diff --git a/robot/resources/lib/python_keywords/s3_gate_object.py b/robot/resources/lib/python_keywords/s3_gate_object.py index 93b499b..b878407 100644 --- a/robot/resources/lib/python_keywords/s3_gate_object.py +++ b/robot/resources/lib/python_keywords/s3_gate_object.py @@ -3,6 +3,7 @@ import os import uuid from enum import Enum +from time import sleep from typing import Optional import urllib3 @@ -12,6 +13,7 @@ from robot.api.deco import keyword from cli_helpers import log_command_execution from python_keywords.aws_cli_client import AwsCliClient +from python_keywords.s3_gate_bucket import S3_SYNC_WAIT_TIME ########################################################## # Disabling warnings on self-signed certificate which the @@ -119,6 +121,7 @@ def delete_object_s3(s3_client, bucket, object_key, version_id: str = None): params['VersionId'] = version_id response = s3_client.delete_object(**params) log_command_execution('S3 Delete object result', response) + sleep(S3_SYNC_WAIT_TIME) return response except ClientError as err: @@ -131,6 +134,7 @@ def delete_objects_s3(s3_client, bucket: str, object_keys: list): try: response = s3_client.delete_objects(Bucket=bucket, Delete=_make_objs_dict(object_keys)) log_command_execution('S3 Delete objects result', response) + sleep(S3_SYNC_WAIT_TIME) return response except ClientError as err: