2019-08-07 00:03:14 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -ueo pipefail
|
|
|
|
|
2020-04-01 19:00:45 +01:00
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
|
2019-08-07 00:03:14 +01:00
|
|
|
: "${STORJ_NETWORK_DIR?Environment variable STORJ_NETWORK_DIR needs to be set}"
|
|
|
|
|
|
|
|
BUCKET=bucket-123
|
|
|
|
TEST_FILES_DIR="$STORJ_NETWORK_DIR/testfiles"
|
|
|
|
BRANCH_DST_DIR=${BRANCH_DIR:-$STORJ_NETWORK_DIR/branch}
|
|
|
|
RELEASE_DST_DIR=${RELEASE_DIR:-$STORJ_NETWORK_DIR/release}
|
|
|
|
|
|
|
|
setup(){
|
|
|
|
mkdir -p "$TEST_FILES_DIR" "$BRANCH_DST_DIR" "$RELEASE_DST_DIR"
|
|
|
|
random_bytes_file () {
|
|
|
|
size=$1
|
|
|
|
output=$2
|
2019-09-19 00:18:14 +01:00
|
|
|
head -c $size </dev/urandom > $output
|
2019-08-07 00:03:14 +01:00
|
|
|
}
|
2019-11-06 13:53:38 +00:00
|
|
|
random_bytes_file "2KiB" "$TEST_FILES_DIR/small-upload-testfile" # create 2kb file of random bytes (inline)
|
|
|
|
random_bytes_file "5MiB" "$TEST_FILES_DIR/big-upload-testfile" # create 5mb file of random bytes (remote)
|
2020-03-19 21:37:00 +00:00
|
|
|
random_bytes_file "64MiB" "$TEST_FILES_DIR/multisegment-upload-testfile" # create 65mb file of random bytes (remote)
|
2019-08-07 00:03:14 +01:00
|
|
|
|
2019-09-09 20:13:38 +01:00
|
|
|
echo "setup test successfully"
|
2019-08-07 00:03:14 +01:00
|
|
|
}
|
|
|
|
|
2020-04-01 19:00:45 +01:00
|
|
|
# override configured access with access where address is node ID + satellite addess
|
|
|
|
export STORJ_ACCESS=$(go run "$SCRIPTDIR"/update-access.go $SATELLITE_0_DIR $GATEWAY_0_ACCESS)
|
|
|
|
|
2019-08-07 00:03:14 +01:00
|
|
|
if [[ "$1" == "upload" ]]; then
|
|
|
|
setup
|
|
|
|
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" mb "sj://$BUCKET/"
|
|
|
|
|
2019-09-19 00:18:14 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "$TEST_FILES_DIR/small-upload-testfile" "sj://$BUCKET/"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "$TEST_FILES_DIR/big-upload-testfile" "sj://$BUCKET/"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "$TEST_FILES_DIR/multisegment-upload-testfile" "sj://$BUCKET/"
|
2019-08-07 00:03:14 +01:00
|
|
|
|
2019-09-19 00:18:14 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "sj://$BUCKET/small-upload-testfile" "$RELEASE_DST_DIR"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "sj://$BUCKET/big-upload-testfile" "$RELEASE_DST_DIR"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "sj://$BUCKET/multisegment-upload-testfile" "$RELEASE_DST_DIR"
|
2019-08-07 00:03:14 +01:00
|
|
|
|
|
|
|
if cmp "$TEST_FILES_DIR/small-upload-testfile" "$RELEASE_DST_DIR/small-upload-testfile"
|
|
|
|
then
|
|
|
|
echo "upload test on release tag: small upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "upload test on release tag: small upload testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if cmp "$TEST_FILES_DIR/big-upload-testfile" "$RELEASE_DST_DIR/big-upload-testfile"
|
|
|
|
then
|
|
|
|
echo "upload test on release tag: big upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "upload test on release tag: big upload testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-09-19 00:18:14 +01:00
|
|
|
|
|
|
|
if cmp "$TEST_FILES_DIR/multisegment-upload-testfile" "$RELEASE_DST_DIR/multisegment-upload-testfile"
|
|
|
|
then
|
|
|
|
echo "upload test on release tag: multisegment upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "upload test on release tag: multisegment upload testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm "$RELEASE_DST_DIR/small-upload-testfile"
|
|
|
|
rm "$RELEASE_DST_DIR/big-upload-testfile"
|
|
|
|
rm "$RELEASE_DST_DIR/multisegment-upload-testfile"
|
2019-08-07 00:03:14 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$1" == "download" ]]; then
|
2019-09-19 00:18:14 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "sj://$BUCKET/small-upload-testfile" "$BRANCH_DST_DIR"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "sj://$BUCKET/big-upload-testfile" "$BRANCH_DST_DIR"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" cp --progress=false "sj://$BUCKET/multisegment-upload-testfile" "$BRANCH_DST_DIR"
|
2019-08-07 00:03:14 +01:00
|
|
|
|
|
|
|
if cmp "$TEST_FILES_DIR/small-upload-testfile" "$BRANCH_DST_DIR/small-upload-testfile"
|
|
|
|
then
|
|
|
|
echo "download test on current branch: small upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "download test on current branch: small upload testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if cmp "$TEST_FILES_DIR/big-upload-testfile" "$BRANCH_DST_DIR/big-upload-testfile"
|
|
|
|
then
|
|
|
|
echo "download test on current branch: big upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "download test on current branch: big upload testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-09-19 00:18:14 +01:00
|
|
|
|
|
|
|
if cmp "$TEST_FILES_DIR/multisegment-upload-testfile" "$BRANCH_DST_DIR/multisegment-upload-testfile"
|
|
|
|
then
|
|
|
|
echo "download test on current branch: multisegment upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "download test on current branch: multisegment upload testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm "$BRANCH_DST_DIR/small-upload-testfile"
|
|
|
|
rm "$BRANCH_DST_DIR/big-upload-testfile"
|
|
|
|
rm "$BRANCH_DST_DIR/multisegment-upload-testfile"
|
2019-09-09 20:13:38 +01:00
|
|
|
fi
|
2019-08-07 00:03:14 +01:00
|
|
|
|
2019-09-09 20:13:38 +01:00
|
|
|
if [[ "$1" == "cleanup" ]]; then
|
2019-08-07 00:03:14 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" rm "sj://$BUCKET/small-upload-testfile"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" rm "sj://$BUCKET/big-upload-testfile"
|
2019-09-19 00:18:14 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" rm "sj://$BUCKET/multisegment-upload-testfile"
|
2019-08-07 00:03:14 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" rb "sj://$BUCKET"
|
|
|
|
fi
|