forked from TrueCloudLab/frostfs-testcases
(#89) S3 Bucket and S3 Object tests
Signed-off-by: EliChin <elizaveta@nspcc.ru>
This commit is contained in:
parent
7552a742f3
commit
ced05475d2
3 changed files with 124 additions and 33 deletions
|
@ -118,6 +118,20 @@ def list_buckets_s3(s3_client):
|
||||||
|
|
||||||
return found_buckets
|
return found_buckets
|
||||||
|
|
||||||
|
@keyword('Delete bucket S3')
|
||||||
|
def delete_bucket_s3(s3_client, bucket):
|
||||||
|
response = s3_client.delete_bucket(Bucket=bucket)
|
||||||
|
logger.info(f"S3 Delete bucket result: {response}")
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@keyword('HeadBucket S3')
|
||||||
|
def headbucket(bucket, s3_client):
|
||||||
|
response = s3_client.head_bucket(Bucket=bucket)
|
||||||
|
logger.info(f"S3 HeadBucket result: {response}")
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
@keyword('Put object S3')
|
@keyword('Put object S3')
|
||||||
def put_object_s3(s3_client, bucket, filepath):
|
def put_object_s3(s3_client, bucket, filepath):
|
||||||
filename = os.path.basename(filepath)
|
filename = os.path.basename(filepath)
|
||||||
|
@ -148,8 +162,12 @@ def delete_object_s3(s3_client, bucket, object_key):
|
||||||
@keyword('Copy object S3')
|
@keyword('Copy object S3')
|
||||||
def copy_object_s3(s3_client, bucket, object_key, new_object):
|
def copy_object_s3(s3_client, bucket, object_key, new_object):
|
||||||
|
|
||||||
|
try:
|
||||||
response = s3_client.copy_object(Bucket=bucket, CopySource=bucket+"/"+object_key, Key=new_object)
|
response = s3_client.copy_object(Bucket=bucket, CopySource=bucket+"/"+object_key, Key=new_object)
|
||||||
logger.info("S3 Copy object result: %s" % response)
|
logger.info("S3 Copy object result: %s" % response)
|
||||||
|
except:
|
||||||
|
raise Exception(f"S3 object {new_object} hasn't been coppied")
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
@ -189,3 +207,4 @@ def get_via_http_gate(cid: str, oid: str):
|
||||||
shutil.copyfileobj(resp.raw, f)
|
shutil.copyfileobj(resp.raw, f)
|
||||||
del resp
|
del resp
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
71
robot/testsuites/integration/services/s3_gate_bucket.robot
Normal file
71
robot/testsuites/integration/services/s3_gate_bucket.robot
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
*** Settings ***
|
||||||
|
Variables ../../../variables/common.py
|
||||||
|
Library Collections
|
||||||
|
Library neofs.py
|
||||||
|
Library payment_neogo.py
|
||||||
|
Library gates.py
|
||||||
|
Library wallet_keywords.py
|
||||||
|
Library contract_keywords.py
|
||||||
|
|
||||||
|
Resource setup_teardown.robot
|
||||||
|
|
||||||
|
*** Variables ***
|
||||||
|
${DEPOSIT_AMOUNT} = ${5}
|
||||||
|
${WIF} = ${MAINNET_WALLET_WIF}
|
||||||
|
${DEPOSIT_TIMEOUT}= 30s
|
||||||
|
|
||||||
|
*** Test cases ***
|
||||||
|
Buckets in NeoFS S3 Gateway
|
||||||
|
[Documentation] Execute operations with bucket via S3 Gate
|
||||||
|
[Timeout] 10 min
|
||||||
|
|
||||||
|
[Setup] Setup
|
||||||
|
|
||||||
|
${WALLET} ${ADDR} = Init Wallet from WIF ${ASSETS_DIR} ${WIF}
|
||||||
|
${TX_DEPOSIT} = NeoFS Deposit ${WIF} ${DEPOSIT_AMOUNT}
|
||||||
|
Wait Until Keyword Succeeds ${DEPOSIT_TIMEOUT} ${MAINNET_BLOCK_TIME}
|
||||||
|
... Transaction accepted in block ${TX_DEPOSIT}
|
||||||
|
|
||||||
|
${FILE_S3} = Generate file of bytes ${COMPLEX_OBJ_SIZE}
|
||||||
|
${FILE_S3_NAME} = Get file name ${FILE_S3}
|
||||||
|
|
||||||
|
${CID}
|
||||||
|
... ${BUCKET}
|
||||||
|
... ${ACCESS_KEY_ID}
|
||||||
|
... ${SEC_ACCESS_KEY}
|
||||||
|
... ${OWNER_PRIV_KEY} = Init S3 Credentials ${WALLET}
|
||||||
|
|
||||||
|
${CONTEINERS_LIST} = Container List ${WIF}
|
||||||
|
List Should Contain Value ${CONTEINERS_LIST} ${CID}
|
||||||
|
|
||||||
|
${S3_CLIENT} = Config S3 client ${ACCESS_KEY_ID} ${SEC_ACCESS_KEY}
|
||||||
|
|
||||||
|
${NEW_BUCKET} = Create Bucket S3 ${S3_CLIENT}
|
||||||
|
${NEW_BUCKET_EMPTY} = Create Bucket S3 ${S3_CLIENT}
|
||||||
|
|
||||||
|
HeadBucket S3 ${BUCKET} ${S3_CLIENT}
|
||||||
|
HeadBucket S3 ${NEW_BUCKET} ${S3_CLIENT}
|
||||||
|
|
||||||
|
Put object S3 ${S3_CLIENT} ${NEW_BUCKET} ${FILE_S3}
|
||||||
|
Head object S3 ${S3_CLIENT} ${NEW_BUCKET} ${FILE_S3_NAME}
|
||||||
|
|
||||||
|
${LIST_S3_OBJECTS} = List objects S3 ${S3_CLIENT} ${NEW_BUCKET}
|
||||||
|
List Should Contain Value ${LIST_S3_OBJECTS} ${FILE_S3_NAME}
|
||||||
|
|
||||||
|
Run Keyword and Expect Error *
|
||||||
|
... Delete Bucket S3 ${S3_CLIENT} ${NEW_BUCKET}
|
||||||
|
HeadBucket S3 ${NEW_BUCKET} ${S3_CLIENT}
|
||||||
|
|
||||||
|
Delete Bucket S3 ${S3_CLIENT} ${NEW_BUCKET_EMPTY}
|
||||||
|
Tick Epoch
|
||||||
|
Run Keyword And Expect Error *
|
||||||
|
... HeadBucket S3 ${NEW_BUCKET_EMPTY} ${S3_CLIENT}
|
||||||
|
|
||||||
|
${BUCKET_LIST} = List Buckets S3 ${S3_CLIENT}
|
||||||
|
Tick Epoch
|
||||||
|
List Should Contain Value ${BUCKET_LIST} ${NEW_BUCKET}
|
||||||
|
List Should Not Contain Value ${BUCKET_LIST} ${NEW_BUCKET_EMPTY}
|
||||||
|
|
||||||
|
[Teardown] Teardown s3_gate_bucket
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
*** Settings ***
|
*** Settings ***
|
||||||
Variables ../../../variables/common.py
|
Variables ../../../variables/common.py
|
||||||
Library Collections
|
Library Collections
|
||||||
Library ../${RESOURCES}/neofs.py
|
Library neofs.py
|
||||||
Library ../${RESOURCES}/payment_neogo.py
|
Library payment_neogo.py
|
||||||
Library ../${RESOURCES}/gates.py
|
Library gates.py
|
||||||
Library ${KEYWORDS}/wallet_keywords.py
|
Library wallet_keywords.py
|
||||||
|
Library contract_keywords.py
|
||||||
Resource ../${RESOURCES}/setup_teardown.robot
|
|
||||||
|
|
||||||
|
Resource setup_teardown.robot
|
||||||
*** Variables ***
|
*** Variables ***
|
||||||
${DEPOSIT_AMOUNT} = ${5}
|
${DEPOSIT_AMOUNT} = ${5}
|
||||||
${WIF} = ${MAINNET_WALLET_WIF}
|
${WIF} = ${MAINNET_WALLET_WIF}
|
||||||
|
|
||||||
*** Test cases ***
|
*** Test cases ***
|
||||||
NeoFS S3 Gateway
|
Objects in NeoFS S3 Gateway
|
||||||
# TODO: check uploading an s3 object via neofs-cli and a neofs object via s3-gate
|
# TODO: check uploading an s3 object via neofs-cli and a neofs object via s3-gate
|
||||||
[Documentation] Execute operations via S3 Gate
|
[Documentation] Execute operations with objects via S3 Gate
|
||||||
[Timeout] 10 min
|
[Timeout] 10 min
|
||||||
|
|
||||||
[Setup] Setup
|
[Setup] Setup
|
||||||
|
@ -29,10 +29,6 @@ NeoFS S3 Gateway
|
||||||
${FILE_S3_HASH} = Get file hash ${FILE_S3}
|
${FILE_S3_HASH} = Get file hash ${FILE_S3}
|
||||||
${FILE_S3_NAME} = Get file name ${FILE_S3}
|
${FILE_S3_NAME} = Get file name ${FILE_S3}
|
||||||
|
|
||||||
${FILE_FS} = Generate file of bytes ${COMPLEX_OBJ_SIZE}
|
|
||||||
${FILE_FS_HASH} = Get file hash ${FILE_FS}
|
|
||||||
${FILE_FS_NAME} = Get file name ${FILE_FS}
|
|
||||||
|
|
||||||
${CID}
|
${CID}
|
||||||
... ${BUCKET}
|
... ${BUCKET}
|
||||||
... ${ACCESS_KEY_ID}
|
... ${ACCESS_KEY_ID}
|
||||||
|
@ -44,33 +40,38 @@ NeoFS S3 Gateway
|
||||||
|
|
||||||
${S3_CLIENT} = Config S3 client ${ACCESS_KEY_ID} ${SEC_ACCESS_KEY}
|
${S3_CLIENT} = Config S3 client ${ACCESS_KEY_ID} ${SEC_ACCESS_KEY}
|
||||||
|
|
||||||
${S3_BUCKET} = Create Bucket S3 ${S3_CLIENT}
|
|
||||||
|
|
||||||
${LIST_S3_BUCKETS} = List buckets S3 ${S3_CLIENT}
|
${NEW_BUCKET} = Create Bucket S3 ${S3_CLIENT}
|
||||||
List Should Contain Value ${LIST_S3_BUCKETS} ${BUCKET}
|
${NEW_BUCKET_2} = Create Bucket S3 ${S3_CLIENT}
|
||||||
List Should Contain Value ${LIST_S3_BUCKETS} ${S3_BUCKET}
|
|
||||||
|
|
||||||
${OID_S3} = Put object S3 ${S3_CLIENT} ${S3_BUCKET} ${FILE_S3}
|
Put object S3 ${S3_CLIENT} ${NEW_BUCKET} ${FILE_S3}
|
||||||
Head object S3 ${S3_CLIENT} ${S3_BUCKET} ${FILE_S3_NAME}
|
Head object S3 ${S3_CLIENT} ${NEW_BUCKET} ${FILE_S3_NAME}
|
||||||
|
Put object S3 ${S3_CLIENT} ${NEW_BUCKET_2} ${FILE_S3}
|
||||||
|
Head object S3 ${S3_CLIENT} ${NEW_BUCKET_2} ${FILE_S3_NAME}
|
||||||
|
|
||||||
${OID_FS} = Put object ${WIF} ${FILE_FS} ${CID} ${EMPTY} ${EMPTY}
|
${LIST_S3_OBJECTS} = List objects S3 ${S3_CLIENT} ${NEW_BUCKET}
|
||||||
Head object ${WIF} ${CID} ${OID_FS} ${EMPTY}
|
|
||||||
${LIST_S3_OBJECTS} = List objects S3 ${S3_CLIENT} ${S3_BUCKET}
|
|
||||||
List Should Contain Value ${LIST_S3_OBJECTS} ${FILE_S3_NAME}
|
List Should Contain Value ${LIST_S3_OBJECTS} ${FILE_S3_NAME}
|
||||||
|
${LIST_S3_OBJECTS_2} = List objects S3 ${S3_CLIENT} ${NEW_BUCKET_2}
|
||||||
|
List Should Contain Value ${LIST_S3_OBJECTS_2} ${FILE_S3_NAME}
|
||||||
|
|
||||||
${LIST_V2_S3_OBJECTS} = List objects S3 v2 ${S3_CLIENT} ${S3_BUCKET}
|
${LIST_V2_S3_OBJECTS} = List objects S3 v2 ${S3_CLIENT} ${NEW_BUCKET}
|
||||||
List Should Contain Value ${LIST_V2_S3_OBJECTS} ${FILE_S3_NAME}
|
|
||||||
List Should Contain Value ${LIST_V2_S3_OBJECTS} ${FILE_S3_NAME}
|
List Should Contain Value ${LIST_V2_S3_OBJECTS} ${FILE_S3_NAME}
|
||||||
|
|
||||||
Get object S3 ${S3_CLIENT} ${S3_BUCKET} ${FILE_S3_NAME} s3_obj_get_s3
|
Get object S3 ${S3_CLIENT} ${NEW_BUCKET} ${FILE_S3_NAME} s3_obj_get_s3
|
||||||
|
|
||||||
Verify file hash s3_obj_get_s3 ${FILE_S3_HASH}
|
Verify file hash s3_obj_get_s3 ${FILE_S3_HASH}
|
||||||
|
|
||||||
Copy object S3 ${S3_CLIENT} ${S3_BUCKET} ${FILE_S3_NAME} NewName
|
#TODO: Solve the issue on CopyObject #260 https://github.com/nspcc-dev/neofs-s3-gw/issues/260
|
||||||
${LIST_S3_OBJECTS} = List objects S3 ${S3_CLIENT} ${S3_BUCKET}
|
|
||||||
|
Copy object S3 ${S3_CLIENT} ${NEW_BUCKET} ${FILE_S3_NAME} NewName
|
||||||
|
${LIST_S3_OBJECTS} = List objects S3 ${S3_CLIENT} ${NEW_BUCKET}
|
||||||
List Should Contain Value ${LIST_S3_OBJECTS} NewName
|
List Should Contain Value ${LIST_S3_OBJECTS} NewName
|
||||||
|
Copy object S3 ${S3_CLIENT} ${NEW_BUCKET_2} ${FILE_S3_NAME} NewName_2
|
||||||
|
${LIST_S3_OBJECTS_2} = List objects S3 ${S3_CLIENT} ${NEW_BUCKET_2}
|
||||||
|
List Should Contain Value ${LIST_S3_OBJECTS_2} NewName_2
|
||||||
|
|
||||||
Delete object S3 ${S3_CLIENT} ${BUCKET} ${FILE_S3_NAME}
|
Delete object S3 ${S3_CLIENT} ${NEW_BUCKET} ${FILE_S3_NAME}
|
||||||
${LIST_S3_OBJECTS} = List objects S3 ${S3_CLIENT} ${S3_BUCKET}
|
${LIST_S3_OBJECTS} = List objects S3 ${S3_CLIENT} ${NEW_BUCKET}
|
||||||
List Should Not Contain Value ${LIST_S3_OBJECTS} FILE_S3_NAME
|
List Should Not Contain Value ${LIST_S3_OBJECTS} ${FILE_S3_NAME}
|
||||||
|
|
||||||
|
[Teardown] Teardown s3_gate_object
|
Loading…
Reference in a new issue