New methods set endpoint S3 client #39

Merged
d.zayakin merged 1 commit from d.zayakin/frostfs-testlib:add-set-endpoint-s3 into master 2023-06-20 08:58:08 +00:00
3 changed files with 26 additions and 6 deletions

View file

@ -39,6 +39,10 @@ class AwsCliClient(S3ClientWrapper):
except Exception as err:
raise RuntimeError("Error while configuring AwsCliClient") from err
@reporter.step_deco("Set endpoint S3 to {s3gate_endpoint}")
def set_endpoint(self, s3gate_endpoint: str):
self.s3gate_endpoint = s3gate_endpoint
@reporter.step_deco("Create bucket S3")
def create_bucket(
self,

View file

@ -47,19 +47,31 @@ class Boto3ClientWrapper(S3ClientWrapper):
@reporter.step_deco("Configure S3 client (boto3)")
@report_error
def __init__(self, access_key_id: str, secret_access_key: str, s3gate_endpoint: str) -> None:
session = boto3.Session()
config = Config(
self.boto3_client: S3Client = None
self.session = boto3.Session()
self.config = Config(
retries={
"max_attempts": MAX_REQUEST_ATTEMPTS,
"mode": RETRY_MODE,
}
)
self.access_key_id: str = access_key_id
self.secret_access_key: str = secret_access_key
self.s3gate_endpoint: str = ""
self.set_endpoint(s3gate_endpoint)
self.boto3_client: S3Client = session.client(
@reporter.step_deco("Set endpoint S3 to {s3gate_endpoint}")
def set_endpoint(self, s3gate_endpoint: str):
if self.s3gate_endpoint == s3gate_endpoint:
return
self.s3gate_endpoint = s3gate_endpoint
self.boto3_client: S3Client = self.session.client(
service_name="s3",
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
config=config,
aws_access_key_id=self.access_key_id,
aws_secret_access_key=self.secret_access_key,
config=self.config,
endpoint_url=s3gate_endpoint,
verify=False,
)

View file

@ -34,6 +34,10 @@ class S3ClientWrapper(ABC):
def __init__(self, access_key_id: str, secret_access_key: str, s3gate_endpoint: str) -> None:
pass
@abstractmethod
def set_endpoint(self, s3gate_endpoint: str):
"""Set endpoint"""
@abstractmethod
def create_bucket(
self,