2019-05-24 17:51:27 +01:00
|
|
|
#!/usr/bin/env bash
|
2019-01-08 15:24:15 +00:00
|
|
|
set -ueo pipefail
|
|
|
|
|
|
|
|
#setup tmpdir for testfiles and cleanup
|
|
|
|
TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
cleanup(){
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
SRC_DIR=$TMPDIR/source
|
2019-02-13 21:44:36 +00:00
|
|
|
DST_DIR=$TMPDIR/dst
|
2019-03-20 14:58:07 +00:00
|
|
|
mkdir -p "$SRC_DIR" "$DST_DIR"
|
2019-01-08 15:24:15 +00:00
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
aws configure set aws_access_key_id "$GATEWAY_0_ACCESS_KEY"
|
|
|
|
aws configure set aws_secret_access_key "$GATEWAY_0_SECRET_KEY"
|
2019-01-08 15:24:15 +00:00
|
|
|
aws configure set default.region us-east-1
|
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
random_bytes_file () {
|
|
|
|
size=$1
|
|
|
|
output=$2
|
|
|
|
dd if=/dev/urandom of="$output" count=1 bs="$size" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
random_bytes_file 1x1024x1024 "$SRC_DIR/small-upload-testfile" # create 1mb file of random bytes (inline)
|
|
|
|
random_bytes_file 5x1024x1024 "$SRC_DIR/big-upload-testfile" # create 5mb file of random bytes (remote)
|
|
|
|
random_bytes_file 5x1024 "$SRC_DIR/multipart-upload-testfile" # create 5kb file of random bytes (remote)
|
2019-01-08 15:24:15 +00:00
|
|
|
|
|
|
|
echo "Creating Bucket"
|
2019-03-20 14:58:07 +00:00
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" mb s3://bucket
|
2019-01-08 15:24:15 +00:00
|
|
|
|
|
|
|
echo "Uploading Files"
|
|
|
|
aws configure set default.s3.multipart_threshold 1TB
|
2019-03-20 14:58:07 +00:00
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" cp "$SRC_DIR/small-upload-testfile" s3://bucket/small-testfile
|
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" cp "$SRC_DIR/big-upload-testfile" s3://bucket/big-testfile
|
2019-01-08 15:24:15 +00:00
|
|
|
|
|
|
|
# Wait 5 seconds to trigger any error related to one of the different intervals
|
|
|
|
sleep 5
|
|
|
|
|
|
|
|
echo "Uploading Multipart File"
|
|
|
|
aws configure set default.s3.multipart_threshold 4KB
|
2019-03-20 14:58:07 +00:00
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" cp "$SRC_DIR/multipart-upload-testfile" s3://bucket/multipart-testfile
|
2019-01-08 15:24:15 +00:00
|
|
|
|
|
|
|
echo "Downloading Files"
|
2019-03-20 14:58:07 +00:00
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" ls s3://bucket
|
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" cp s3://bucket/small-testfile "$DST_DIR/small-download-testfile"
|
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" cp s3://bucket/big-testfile "$DST_DIR/big-download-testfile"
|
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" cp s3://bucket/multipart-testfile "$DST_DIR/multipart-download-testfile"
|
|
|
|
aws s3 --endpoint="http://$GATEWAY_0_ADDR" rb s3://bucket --force
|
2019-01-08 15:24:15 +00:00
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
if cmp "$SRC_DIR/small-upload-testfile" "$DST_DIR/small-download-testfile"
|
2019-01-08 15:24:15 +00:00
|
|
|
then
|
2019-03-20 14:58:07 +00:00
|
|
|
echo "small-upload-testfile file matches uploaded file";
|
2019-01-08 15:24:15 +00:00
|
|
|
else
|
2019-03-20 14:58:07 +00:00
|
|
|
echo "small-upload-testfile file does not match uploaded file";
|
2019-01-08 15:24:15 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
if cmp "$SRC_DIR/big-upload-testfile" "$DST_DIR/big-download-testfile"
|
2019-01-08 15:24:15 +00:00
|
|
|
then
|
2019-03-20 14:58:07 +00:00
|
|
|
echo "big-upload-testfile file matches uploaded file";
|
2019-01-08 15:24:15 +00:00
|
|
|
else
|
2019-03-20 14:58:07 +00:00
|
|
|
echo "big-upload-testfile file does not match uploaded file";
|
2019-01-08 15:24:15 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
if cmp "$SRC_DIR/multipart-upload-testfile" "$DST_DIR/multipart-download-testfile"
|
2019-01-08 15:24:15 +00:00
|
|
|
then
|
2019-03-20 14:58:07 +00:00
|
|
|
echo "multipart-upload-testfile file matches uploaded file";
|
2019-01-08 15:24:15 +00:00
|
|
|
else
|
2019-03-20 14:58:07 +00:00
|
|
|
echo "multipart-upload-testfile file does not match uploaded file";
|
|
|
|
fi
|