From 94f0e7c135798af4dcb023f846b6b0b4adb3b2da Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 20 Jan 2022 16:38:28 +0100 Subject: [PATCH] Test ListParts endpoint with awscli --- .../src/reference_manual/s3_compatibility.md | 2 +- script/test-smoke.sh | 53 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/doc/book/src/reference_manual/s3_compatibility.md b/doc/book/src/reference_manual/s3_compatibility.md index 5c2e6315..4c4c6457 100644 --- a/doc/book/src/reference_manual/s3_compatibility.md +++ b/doc/book/src/reference_manual/s3_compatibility.md @@ -44,7 +44,7 @@ All APIs that are not mentionned are not implemented and will return a 501 Not I | ListObjects | Implemented, bugs? (see below) | | ListObjectsV2 | Implemented | | ListMultipartUpload | Implemented | -| ListParts | Missing | +| ListParts | Implemented | | PutObject | Implemented | | PutBucketWebsite | Partially implemented (see below)| | UploadPart | Implemented | diff --git a/script/test-smoke.sh b/script/test-smoke.sh index 91bf90ab..0adf322a 100755 --- a/script/test-smoke.sh +++ b/script/test-smoke.sh @@ -252,7 +252,58 @@ if [ -z "$SKIP_AWS" ]; then echo "Deleted ${key}:${uid}" done - # Test for UploadPartCopy + echo "Test for ListParts" + UPLOAD_ID=$(aws s3api create-multipart-upload --bucket eprouvette --key list-parts | jq -r .UploadId) + aws s3api list-parts --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID >$CMDOUT + [ $(jq '.Parts | length' $CMDOUT) == 0 ] + [ $(jq -r '.StorageClass' $CMDOUT) == 'STANDARD' ] # check that the result is not empty + ETAG1=$(aws s3api upload-part --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID --part-number 10 --body /tmp/garage.2.rnd | jq .ETag) + aws s3api list-parts --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID >$CMDOUT + [ $(jq '.Parts | length' $CMDOUT) == 1 ] + [ $(jq '.Parts[0].PartNumber' $CMDOUT) == 10 ] + [ $(jq '.Parts[0].Size' $CMDOUT) == 5242880 ] + [ $(jq '.Parts[0].ETag' $CMDOUT) == $ETAG1 ] + + ETAG2=$(aws s3api upload-part --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID --part-number 9999 --body /tmp/garage.3.rnd | jq .ETag) + ETAG3=$(aws s3api upload-part --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID --part-number 30 --body /tmp/garage.2.rnd | jq .ETag) + aws s3api list-parts --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID >$CMDOUT + [ $(jq '.Parts | length' $CMDOUT) == 3 ] + [ $(jq '.Parts[1].ETag' $CMDOUT) == $ETAG3 ] + + aws s3api list-parts --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID --page-size 1 >$CMDOUT + [ $(jq '.Parts | length' $CMDOUT) == 3 ] + [ $(jq '.Parts[1].ETag' $CMDOUT) == $ETAG3 ] + + cat >/tmp/garage.multipart_struct <$CMDOUT + aws s3 rm "s3://eprouvette/list-parts" + + + # @FIXME We do not write tests with --starting-token due to a bug with awscli + # See here: https://github.com/aws/aws-cli/issues/6666 + + echo "Test for UploadPartCopy" aws s3 cp "/tmp/garage.3.rnd" "s3://eprouvette/copy_part_source" UPLOAD_ID=$(aws s3api create-multipart-upload --bucket eprouvette --key test_multipart | jq -r .UploadId) PART1=$(aws s3api upload-part \