Add delays after s3 operations
Delays were added after: - S3 container create/delete. - S3 object create/delete. Signed-off-by: Vladimir Domnich <v.domnich@yadro.com>
This commit is contained in:
parent
46b593b02e
commit
279bb3dedd
2 changed files with 11 additions and 3 deletions
|
@ -4,6 +4,7 @@ import json
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
from data_formatters import pub_key_hex
|
from data_formatters import pub_key_hex
|
||||||
|
@ -23,10 +24,12 @@ urllib3.disable_warnings()
|
||||||
|
|
||||||
ROBOT_AUTO_KEYWORDS = False
|
ROBOT_AUTO_KEYWORDS = False
|
||||||
CREDENTIALS_CREATE_TIMEOUT = '30s'
|
CREDENTIALS_CREATE_TIMEOUT = '30s'
|
||||||
|
|
||||||
NEOFS_EXEC = os.getenv('NEOFS_EXEC', 'neofs-authmate')
|
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):
|
class VersioningStatus(Enum):
|
||||||
ENABLED = 'Enabled'
|
ENABLED = 'Enabled'
|
||||||
|
@ -94,6 +97,7 @@ def create_bucket_s3(s3_client):
|
||||||
try:
|
try:
|
||||||
s3_bucket = s3_client.create_bucket(Bucket=bucket_name)
|
s3_bucket = s3_client.create_bucket(Bucket=bucket_name)
|
||||||
log_command_execution(f'Created S3 bucket {bucket_name}', s3_bucket)
|
log_command_execution(f'Created S3 bucket {bucket_name}', s3_bucket)
|
||||||
|
sleep(S3_SYNC_WAIT_TIME)
|
||||||
return bucket_name
|
return bucket_name
|
||||||
|
|
||||||
except ClientError as err:
|
except ClientError as err:
|
||||||
|
@ -123,7 +127,7 @@ def delete_bucket_s3(s3_client, bucket: str):
|
||||||
try:
|
try:
|
||||||
response = s3_client.delete_bucket(Bucket=bucket)
|
response = s3_client.delete_bucket(Bucket=bucket)
|
||||||
log_command_execution('S3 Delete bucket result', response)
|
log_command_execution('S3 Delete bucket result', response)
|
||||||
|
sleep(S3_SYNC_WAIT_TIME)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
except ClientError as err:
|
except ClientError as err:
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import os
|
import os
|
||||||
import uuid
|
import uuid
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
from time import sleep
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import urllib3
|
import urllib3
|
||||||
|
@ -12,6 +13,7 @@ from robot.api.deco import keyword
|
||||||
|
|
||||||
from cli_helpers import log_command_execution
|
from cli_helpers import log_command_execution
|
||||||
from python_keywords.aws_cli_client import AwsCliClient
|
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
|
# 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
|
params['VersionId'] = version_id
|
||||||
response = s3_client.delete_object(**params)
|
response = s3_client.delete_object(**params)
|
||||||
log_command_execution('S3 Delete object result', response)
|
log_command_execution('S3 Delete object result', response)
|
||||||
|
sleep(S3_SYNC_WAIT_TIME)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
except ClientError as err:
|
except ClientError as err:
|
||||||
|
@ -131,6 +134,7 @@ def delete_objects_s3(s3_client, bucket: str, object_keys: list):
|
||||||
try:
|
try:
|
||||||
response = s3_client.delete_objects(Bucket=bucket, Delete=_make_objs_dict(object_keys))
|
response = s3_client.delete_objects(Bucket=bucket, Delete=_make_objs_dict(object_keys))
|
||||||
log_command_execution('S3 Delete objects result', response)
|
log_command_execution('S3 Delete objects result', response)
|
||||||
|
sleep(S3_SYNC_WAIT_TIME)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
except ClientError as err:
|
except ClientError as err:
|
||||||
|
|
Loading…
Reference in a new issue