aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2022-01-20 16:38:28 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2022-01-21 10:42:35 +0100
commit94f0e7c135798af4dcb023f846b6b0b4adb3b2da (patch)
treef42713539eab7102d02f5714433c21bfd26f3b89
parent440374524bcd21cade7b68410eb2d12ba23cfaaf (diff)
downloadgarage-features/list-parts.tar.gz
garage-features/list-parts.zip
Test ListParts endpoint with awsclifeatures/list-parts
-rw-r--r--doc/book/src/reference_manual/s3_compatibility.md2
-rwxr-xr-xscript/test-smoke.sh53
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 <<EOF
+{
+ "Parts": [
+ {
+ "ETag": $ETAG1,
+ "PartNumber": 10
+ },
+ {
+ "ETag": $ETAG3,
+ "PartNumber": 30
+ },
+ {
+ "ETag": $ETAG2,
+ "PartNumber": 9999
+ }
+ ]
+}
+EOF
+ aws s3api complete-multipart-upload \
+ --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID \
+ --multipart-upload file:///tmp/garage.multipart_struct
+
+ ! aws s3api list-parts --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID >$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 \