2018-10-19 18:14:29 +01:00
|
|
|
#!/bin/bash
|
2018-09-11 05:52:14 +01:00
|
|
|
set -ueo pipefail
|
2018-08-14 17:58:16 +01:00
|
|
|
go install -v storj.io/storj/cmd/captplanet
|
|
|
|
|
2018-09-25 19:23:21 +01:00
|
|
|
captplanet setup --overwrite
|
2018-11-20 23:08:52 +00:00
|
|
|
sed -i~ 's/interval:.*/interval: 1s/g' $HOME/.storj/capt/config.yaml
|
2018-10-12 11:58:32 +01:00
|
|
|
|
|
|
|
# run captplanet for 5 seconds to reproduce kademlia problems. See V3-526
|
|
|
|
captplanet run &
|
|
|
|
CAPT_PID=$!
|
|
|
|
sleep 5
|
|
|
|
kill -9 $CAPT_PID
|
|
|
|
|
2018-08-14 17:58:16 +01:00
|
|
|
captplanet run &
|
|
|
|
CAPT_PID=$!
|
|
|
|
|
2018-10-19 18:14:29 +01:00
|
|
|
#setup tmpdir for testfiles and cleanup
|
|
|
|
TMP_DIR=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
CMP_DIR=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
mkdir -p $TMP_DIR
|
|
|
|
mkdir -p $CMP_DIR
|
|
|
|
|
2018-08-14 17:58:16 +01:00
|
|
|
aws configure set aws_access_key_id insecure-dev-access-key
|
|
|
|
aws configure set aws_secret_access_key insecure-dev-secret-key
|
|
|
|
aws configure set default.region us-east-1
|
|
|
|
|
2018-10-19 18:14:29 +01:00
|
|
|
head -c 1024 </dev/urandom > $TMP_DIR/small-upload-testfile # create 1mb file of random bytes (inline)
|
|
|
|
head -c 5120 </dev/urandom > $TMP_DIR/big-upload-testfile # create 5mb file of random bytes (remote)
|
|
|
|
head -c 5 </dev/urandom > $TMP_DIR/multipart-upload-testfile # create 5kb file of random bytes (remote)
|
2018-08-14 17:58:16 +01:00
|
|
|
|
2018-08-16 15:32:28 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ mb s3://bucket
|
2018-09-21 20:44:45 +01:00
|
|
|
|
|
|
|
aws configure set default.s3.multipart_threshold 1TB
|
2018-10-19 18:14:29 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp $TMP_DIR/small-upload-testfile s3://bucket/small-testfile
|
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp $TMP_DIR/big-upload-testfile s3://bucket/big-testfile
|
2018-09-21 20:44:45 +01:00
|
|
|
|
2018-11-01 16:46:14 +00:00
|
|
|
# Wait 5 seconds to trigger any error related to one of the different intervals
|
|
|
|
sleep 5
|
|
|
|
|
2018-09-21 20:44:45 +01:00
|
|
|
aws configure set default.s3.multipart_threshold 4KB
|
2018-10-19 18:14:29 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp $TMP_DIR/multipart-upload-testfile s3://bucket/multipart-testfile
|
2018-09-21 20:44:45 +01:00
|
|
|
|
2018-08-14 17:58:16 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ ls s3://bucket
|
2018-10-19 18:14:29 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp s3://bucket/small-testfile $CMP_DIR/small-download-testfile
|
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp s3://bucket/big-testfile $CMP_DIR/big-download-testfile
|
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp s3://bucket/multipart-testfile $CMP_DIR/multipart-download-testfile
|
2018-09-25 19:23:21 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ rb s3://bucket --force
|
2018-08-14 17:58:16 +01:00
|
|
|
|
2018-10-19 18:14:29 +01:00
|
|
|
if cmp $TMP_DIR/small-upload-testfile $CMP_DIR/small-download-testfile
|
2018-08-14 17:58:16 +01:00
|
|
|
then
|
|
|
|
echo "Downloaded file matches uploaded file";
|
|
|
|
else
|
|
|
|
echo "Downloaded file does not match uploaded file";
|
|
|
|
kill -9 $CAPT_PID
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2018-10-19 18:14:29 +01:00
|
|
|
if cmp $TMP_DIR/big-upload-testfile $CMP_DIR/big-download-testfile
|
2018-08-14 17:58:16 +01:00
|
|
|
then
|
|
|
|
echo "Downloaded file matches uploaded file";
|
|
|
|
else
|
|
|
|
echo "Downloaded file does not match uploaded file";
|
|
|
|
kill -9 $CAPT_PID
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2018-10-19 18:14:29 +01:00
|
|
|
if cmp $TMP_DIR/multipart-upload-testfile $CMP_DIR/multipart-download-testfile
|
2018-09-21 20:44:45 +01:00
|
|
|
then
|
|
|
|
echo "Downloaded file matches uploaded file";
|
|
|
|
else
|
|
|
|
echo "Downloaded file does not match uploaded file";
|
|
|
|
kill -9 $CAPT_PID
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
2018-09-25 19:23:21 +01:00
|
|
|
kill -9 $CAPT_PID
|
|
|
|
|
|
|
|
captplanet setup --listen-host ::1 --overwrite
|
2018-11-20 23:08:52 +00:00
|
|
|
sed -i~ 's/interval:.*/interval: 1s/g' $HOME/.storj/capt/config.yaml
|
2018-09-25 19:23:21 +01:00
|
|
|
captplanet run &
|
|
|
|
CAPT_PID=$!
|
|
|
|
|
|
|
|
aws s3 --endpoint=http://localhost:7777/ mb s3://bucket
|
2018-10-19 18:14:29 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp $TMP_DIR/big-upload-testfile s3://bucket/big-testfile
|
|
|
|
aws s3 --endpoint=http://localhost:7777/ cp s3://bucket/big-testfile $CMP_DIR/big-download-testfile-ipv6
|
2018-09-25 19:23:21 +01:00
|
|
|
aws s3 --endpoint=http://localhost:7777/ rb s3://bucket --force
|
|
|
|
|
2018-10-19 18:14:29 +01:00
|
|
|
if cmp $TMP_DIR/big-upload-testfile $CMP_DIR/big-download-testfile-ipv6
|
2018-09-25 19:23:21 +01:00
|
|
|
then
|
|
|
|
echo "Downloaded ipv6 file matches uploaded file";
|
|
|
|
else
|
|
|
|
echo "Downloaded ipv6 file does not match uploaded file";
|
|
|
|
kill -9 $CAPT_PID
|
|
|
|
exit 1;
|
|
|
|
fi
|
2018-09-21 20:44:45 +01:00
|
|
|
|
2018-08-14 17:58:16 +01:00
|
|
|
kill -9 $CAPT_PID
|
|
|
|
|
2018-10-19 18:14:29 +01:00
|
|
|
rm -rf $TMP_DIR
|