mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-03 19:47:40 +00:00
Functional test for multipart endpoints
This commit is contained in:
@@ -143,109 +143,6 @@ fi
|
||||
|
||||
# Advanced testing via S3API
|
||||
if [ -z "$SKIP_AWS" ]; then
|
||||
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 1 --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) == 1 ]
|
||||
[ $(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 3 --body /tmp/garage.3.rnd | jq .ETag)
|
||||
ETAG3=$(aws s3api upload-part --bucket eprouvette --key list-parts --upload-id $UPLOAD_ID --part-number 2 --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": 1
|
||||
},
|
||||
{
|
||||
"ETag": $ETAG3,
|
||||
"PartNumber": 2
|
||||
},
|
||||
{
|
||||
"ETag": $ETAG2,
|
||||
"PartNumber": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
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 \
|
||||
--bucket eprouvette --key test_multipart \
|
||||
--upload-id $UPLOAD_ID --part-number 1 \
|
||||
--body /tmp/garage.2.rnd | jq .ETag)
|
||||
PART2=$(aws s3api upload-part-copy \
|
||||
--bucket eprouvette --key test_multipart \
|
||||
--upload-id $UPLOAD_ID --part-number 2 \
|
||||
--copy-source "/eprouvette/copy_part_source" \
|
||||
--copy-source-range "bytes=500-5000500" \
|
||||
| jq .CopyPartResult.ETag)
|
||||
PART3=$(aws s3api upload-part \
|
||||
--bucket eprouvette --key test_multipart \
|
||||
--upload-id $UPLOAD_ID --part-number 3 \
|
||||
--body /tmp/garage.3.rnd | jq .ETag)
|
||||
cat >/tmp/garage.multipart_struct <<EOF
|
||||
{
|
||||
"Parts": [
|
||||
{
|
||||
"ETag": $PART1,
|
||||
"PartNumber": 1
|
||||
},
|
||||
{
|
||||
"ETag": $PART2,
|
||||
"PartNumber": 2
|
||||
},
|
||||
{
|
||||
"ETag": $PART3,
|
||||
"PartNumber": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
EOF
|
||||
aws s3api complete-multipart-upload \
|
||||
--bucket eprouvette --key test_multipart --upload-id $UPLOAD_ID \
|
||||
--multipart-upload file:///tmp/garage.multipart_struct
|
||||
|
||||
aws s3 cp "s3://eprouvette/test_multipart" /tmp/garage.test_multipart
|
||||
cat /tmp/garage.2.rnd <(tail -c +501 /tmp/garage.3.rnd | head -c 5000001) /tmp/garage.3.rnd > /tmp/garage.test_multipart_reference
|
||||
diff /tmp/garage.test_multipart /tmp/garage.test_multipart_reference >/tmp/garage.test_multipart_diff 2>&1
|
||||
|
||||
aws s3 rm "s3://eprouvette/copy_part_source"
|
||||
aws s3 rm "s3://eprouvette/test_multipart"
|
||||
|
||||
rm /tmp/garage.multipart_struct
|
||||
rm /tmp/garage.test_multipart
|
||||
rm /tmp/garage.test_multipart_reference
|
||||
rm /tmp/garage.test_multipart_diff
|
||||
|
||||
|
||||
echo "Test CORS endpoints"
|
||||
garage -c /tmp/config.1.toml bucket website --allow eprouvette
|
||||
aws s3api put-object --bucket eprouvette --key index.html
|
||||
|
||||
Reference in New Issue
Block a user