2019-05-24 17:51:27 +01:00
|
|
|
#!/usr/bin/env bash
|
2019-02-13 21:44:36 +00:00
|
|
|
set -ueo pipefail
|
|
|
|
|
|
|
|
TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
|
|
|
|
cleanup(){
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
echo "cleaned up test successfully"
|
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
BUCKET=bucket-123
|
|
|
|
SRC_DIR=$TMPDIR/source
|
|
|
|
DST_DIR=$TMPDIR/dst
|
2020-01-10 15:51:28 +00:00
|
|
|
UPLINK_DIR=$TMPDIR/uplink
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
mkdir -p "$SRC_DIR" "$DST_DIR"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
random_bytes_file () {
|
|
|
|
size=$1
|
|
|
|
output=$2
|
2019-09-19 00:18:14 +01:00
|
|
|
head -c $size </dev/urandom > $output
|
2019-03-20 14:58:07 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 19:18:02 +00:00
|
|
|
random_bytes_file "2048" "$SRC_DIR/small-upload-testfile" # create 2kb file of random bytes (inline)
|
|
|
|
random_bytes_file "5242880" "$SRC_DIR/big-upload-testfile" # create 5mb file of random bytes (remote)
|
|
|
|
random_bytes_file "12582912" "$SRC_DIR/multisegment-upload-testfile" # create 2 x 6mb file of random bytes (remote)
|
|
|
|
random_bytes_file "9437184" "$SRC_DIR/diff-size-segments" # create 9mb file of random bytes (remote)
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-07-03 15:10:51 +01:00
|
|
|
UPLINK_DEBUG_ADDR=""
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2020-01-09 13:38:19 +00:00
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --debug.addr "$UPLINK_DEBUG_ADDR" mb "sj://$BUCKET/"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2020-01-09 13:38:19 +00:00
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "$SRC_DIR/small-upload-testfile" "sj://$BUCKET/"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "$SRC_DIR/big-upload-testfile" "sj://$BUCKET/"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "$SRC_DIR/multisegment-upload-testfile" "sj://$BUCKET/"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "$SRC_DIR/diff-size-segments" "sj://$BUCKET/"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2020-01-10 15:51:28 +00:00
|
|
|
uplink --config-dir "$UPLINK_DIR" import named-access $GATEWAY_0_ACCESS
|
|
|
|
FILES=$(uplink --config-dir "$UPLINK_DIR" --access named-access ls "sj://$BUCKET" | wc -l)
|
|
|
|
EXPECTED_FILES="4"
|
|
|
|
if [ "$FILES" == $EXPECTED_FILES ]
|
|
|
|
then
|
|
|
|
echo "listing returns $FILES files"
|
|
|
|
else
|
|
|
|
echo "listing returns $FILES files but want $EXPECTED_FILES"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-09 13:38:19 +00:00
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "sj://$BUCKET/small-upload-testfile" "$DST_DIR"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "sj://$BUCKET/big-upload-testfile" "$DST_DIR"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "sj://$BUCKET/multisegment-upload-testfile" "$DST_DIR"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --progress=false --debug.addr "$UPLINK_DEBUG_ADDR" cp "sj://$BUCKET/diff-size-segments" "$DST_DIR"
|
2019-08-15 12:45:49 +01:00
|
|
|
|
2020-01-09 13:38:19 +00:00
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --debug.addr "$UPLINK_DEBUG_ADDR" rm "sj://$BUCKET/small-upload-testfile"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --debug.addr "$UPLINK_DEBUG_ADDR" rm "sj://$BUCKET/big-upload-testfile"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --debug.addr "$UPLINK_DEBUG_ADDR" rm "sj://$BUCKET/multisegment-upload-testfile"
|
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --debug.addr "$UPLINK_DEBUG_ADDR" rm "sj://$BUCKET/diff-size-segments"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2020-01-09 13:38:19 +00:00
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --debug.addr "$UPLINK_DEBUG_ADDR" ls "sj://$BUCKET"
|
2019-07-03 15:10:51 +01:00
|
|
|
|
2020-01-09 13:38:19 +00:00
|
|
|
uplink --access "$GATEWAY_0_ACCESS" --debug.addr "$UPLINK_DEBUG_ADDR" rb "sj://$BUCKET"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
if cmp "$SRC_DIR/small-upload-testfile" "$DST_DIR/small-upload-testfile"
|
2019-02-13 21:44:36 +00:00
|
|
|
then
|
|
|
|
echo "small upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "small upload testfile does not match uploaded file"
|
2019-07-03 15:10:51 +01:00
|
|
|
exit 1
|
2019-02-13 21:44:36 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-20 14:58:07 +00:00
|
|
|
if cmp "$SRC_DIR/big-upload-testfile" "$DST_DIR/big-upload-testfile"
|
2019-02-13 21:44:36 +00:00
|
|
|
then
|
|
|
|
echo "big upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "big upload testfile does not match uploaded file"
|
2019-07-03 15:10:51 +01:00
|
|
|
exit 1
|
2019-02-13 21:44:36 +00:00
|
|
|
fi
|
|
|
|
|
2019-08-15 12:45:49 +01:00
|
|
|
if cmp "$SRC_DIR/multisegment-upload-testfile" "$DST_DIR/multisegment-upload-testfile"
|
|
|
|
then
|
|
|
|
echo "multisegment upload testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "multisegment upload testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-09-19 00:18:14 +01:00
|
|
|
if cmp "$SRC_DIR/diff-size-segments" "$DST_DIR/diff-size-segments"
|
|
|
|
then
|
|
|
|
echo "diff-size-segments testfile matches uploaded file"
|
|
|
|
else
|
|
|
|
echo "diff-size-segments testfile does not match uploaded file"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2019-03-18 10:55:06 +00:00
|
|
|
# check if all data files were removed
|
|
|
|
# FILES=$(find "$STORAGENODE_0_DIR/../" -type f -path "*/blob/*" ! -name "info.*")
|
|
|
|
# if [ -z "$FILES" ];
|
|
|
|
# then
|
|
|
|
# echo "all data files removed from storage nodes"
|
|
|
|
# else
|
|
|
|
# echo "not all data files removed from storage nodes:"
|
|
|
|
# echo $FILES
|
|
|
|
# exit 1
|
2019-03-20 14:58:07 +00:00
|
|
|
# fi
|