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
|
|
|
|
|
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
|
|
|
|
dd if=/dev/urandom of="$output" count=1 bs="$size" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
random_bytes_file 2x1024 "$SRC_DIR/small-upload-testfile" # create 2kb file of random bytes (inline)
|
|
|
|
random_bytes_file 5x1024x1024 "$SRC_DIR/big-upload-testfile" # create 5mb file of random bytes (remote)
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-05-22 14:57:12 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" mb "sj://$BUCKET/"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-05-22 14:57:12 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" cp "$SRC_DIR/small-upload-testfile" "sj://$BUCKET/"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" cp "$SRC_DIR/big-upload-testfile" "sj://$BUCKET/"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-05-22 14:57:12 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" cp "sj://$BUCKET/small-upload-testfile" "$DST_DIR"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" cp "sj://$BUCKET/big-upload-testfile" "$DST_DIR"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-05-22 14:57:12 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" rm "sj://$BUCKET/small-upload-testfile"
|
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" rm "sj://$BUCKET/big-upload-testfile"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-05-22 14:57:12 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" ls "sj://$BUCKET"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2019-05-22 14:57:12 +01:00
|
|
|
uplink --config-dir "$GATEWAY_0_DIR" --enc.encryption-key "test-uplink" 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"
|
|
|
|
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"
|
|
|
|
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
|