2019-05-24 17:51:27 +01:00
|
|
|
#!/usr/bin/env bash
|
2019-02-13 21:44:36 +00:00
|
|
|
set -ueo pipefail
|
|
|
|
|
2021-02-26 11:31:03 +00:00
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
source $SCRIPTDIR/utils.sh
|
|
|
|
|
2019-02-13 21:44:36 +00:00
|
|
|
TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
|
|
|
|
cleanup(){
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
echo "cleaned up test successfully"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
2021-02-26 11:31:03 +00:00
|
|
|
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR
|
2019-02-13 21:44:36 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2020-03-19 21:37:00 +00:00
|
|
|
random_bytes_file "2KiB" "$SRC_DIR/small-upload-testfile" # create 2KiB file of random bytes (inline)
|
|
|
|
random_bytes_file "5MiB" "$SRC_DIR/big-upload-testfile" # create 5MiB file of random bytes (remote)
|
|
|
|
# this is special case where we need to test at least one remote segment and inline segment of exact size 0
|
2020-04-17 10:20:55 +01:00
|
|
|
random_bytes_file "12MiB" "$SRC_DIR/multisegment-upload-testfile" # create 12MiB file of random bytes (1 remote segments + inline)
|
|
|
|
random_bytes_file "13MiB" "$SRC_DIR/diff-size-segments" # create 13MiB file of random bytes (2 remote segments)
|
2020-03-19 21:37:00 +00:00
|
|
|
|
|
|
|
random_bytes_file "100KiB" "$SRC_DIR/put-file" # create 100KiB 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-03-05 10:06:47 +00:00
|
|
|
export STORJ_ACCESS=$GATEWAY_0_ACCESS
|
|
|
|
export STORJ_DEBUG_ADDR=$UPLINK_DEBUG_ADDR
|
|
|
|
|
|
|
|
uplink mb "sj://$BUCKET/"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2020-03-19 21:37:00 +00:00
|
|
|
uplink cp "$SRC_DIR/small-upload-testfile" "sj://$BUCKET/" --progress=false
|
2020-03-05 10:06:47 +00:00
|
|
|
uplink cp "$SRC_DIR/big-upload-testfile" "sj://$BUCKET/" --progress=false
|
|
|
|
uplink cp "$SRC_DIR/multisegment-upload-testfile" "sj://$BUCKET/" --progress=false
|
2020-03-19 21:37:00 +00:00
|
|
|
uplink cp "$SRC_DIR/diff-size-segments" "sj://$BUCKET/" --progress=false
|
2020-03-05 10:06:47 +00:00
|
|
|
|
|
|
|
cat "$SRC_DIR/put-file" | uplink put "sj://$BUCKET/put-file"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2020-04-01 19:00:45 +01:00
|
|
|
uplink --config-dir "$UPLINK_DIR" import named-access $STORJ_ACCESS
|
2020-03-05 10:06:47 +00:00
|
|
|
FILES=$(STORJ_ACCESS= uplink --config-dir "$UPLINK_DIR" --access named-access ls "sj://$BUCKET" | tee $TMPDIR/list | wc -l)
|
|
|
|
EXPECTED_FILES="5"
|
2020-01-10 15:51:28 +00:00
|
|
|
if [ "$FILES" == $EXPECTED_FILES ]
|
|
|
|
then
|
|
|
|
echo "listing returns $FILES files"
|
|
|
|
else
|
|
|
|
echo "listing returns $FILES files but want $EXPECTED_FILES"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-05 10:06:47 +00:00
|
|
|
SIZE_CHECK=$(cat "$TMPDIR/list" | awk '{if($4 == "0") print "invalid size";}')
|
|
|
|
if [ "$SIZE_CHECK" != "" ]
|
2019-02-13 21:44:36 +00:00
|
|
|
then
|
2020-03-05 10:06:47 +00:00
|
|
|
echo "listing returns invalid size for one of the objects:"
|
|
|
|
cat "$TMPDIR/list"
|
2019-07-03 15:10:51 +01:00
|
|
|
exit 1
|
2019-02-13 21:44:36 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-19 21:37:00 +00:00
|
|
|
uplink ls "sj://$BUCKET/non-existing-prefix"
|
2019-02-13 21:44:36 +00:00
|
|
|
|
2020-03-05 10:06:47 +00:00
|
|
|
uplink cp "sj://$BUCKET/small-upload-testfile" "$DST_DIR" --progress=false
|
2020-03-19 21:37:00 +00:00
|
|
|
uplink cp "sj://$BUCKET/big-upload-testfile" "$DST_DIR" --progress=false
|
|
|
|
uplink cp "sj://$BUCKET/multisegment-upload-testfile" "$DST_DIR" --progress=false
|
|
|
|
uplink cp "sj://$BUCKET/diff-size-segments" "$DST_DIR" --progress=false
|
|
|
|
uplink cp "sj://$BUCKET/put-file" "$DST_DIR" --progress=false
|
2020-03-05 10:06:47 +00:00
|
|
|
uplink cat "sj://$BUCKET/put-file" >> "$DST_DIR/put-file-from-cat"
|
2019-08-15 12:45:49 +01:00
|
|
|
|
2021-02-24 16:35:02 +00:00
|
|
|
uplink ls "sj://$BUCKET/small-upload-testfile" | grep "small-upload-testfile"
|
|
|
|
|
2020-03-05 10:06:47 +00:00
|
|
|
uplink rm "sj://$BUCKET/small-upload-testfile"
|
|
|
|
uplink rm "sj://$BUCKET/big-upload-testfile"
|
|
|
|
uplink rm "sj://$BUCKET/multisegment-upload-testfile"
|
|
|
|
uplink rm "sj://$BUCKET/diff-size-segments"
|
|
|
|
uplink rm "sj://$BUCKET/put-file"
|
|
|
|
|
|
|
|
uplink ls "sj://$BUCKET"
|
2019-09-19 00:18:14 +01:00
|
|
|
|
2020-03-05 10:06:47 +00:00
|
|
|
uplink rb "sj://$BUCKET"
|
2019-09-19 00:18:14 +01:00
|
|
|
|
2020-03-05 10:06:47 +00:00
|
|
|
compare_files "$SRC_DIR/small-upload-testfile" "$DST_DIR/small-upload-testfile"
|
|
|
|
compare_files "$SRC_DIR/big-upload-testfile" "$DST_DIR/big-upload-testfile"
|
|
|
|
compare_files "$SRC_DIR/multisegment-upload-testfile" "$DST_DIR/multisegment-upload-testfile"
|
|
|
|
compare_files "$SRC_DIR/diff-size-segments" "$DST_DIR/diff-size-segments"
|
|
|
|
compare_files "$SRC_DIR/put-file" "$DST_DIR/put-file"
|
2020-03-19 21:37:00 +00:00
|
|
|
compare_files "$SRC_DIR/put-file" "$DST_DIR/put-file-from-cat"
|
2020-04-14 05:14:39 +01:00
|
|
|
|
|
|
|
# test deleting non empty bucket with --force flag
|
|
|
|
uplink mb "sj://$BUCKET/"
|
|
|
|
|
2020-08-28 19:27:58 +01:00
|
|
|
for i in $(seq -w 1 16); do
|
|
|
|
uplink cp "$SRC_DIR/small-upload-testfile" "sj://$BUCKET/small-file-$i" --progress=false
|
|
|
|
done
|
2020-04-14 05:14:39 +01:00
|
|
|
|
2020-08-28 19:27:58 +01:00
|
|
|
uplink rb "sj://$BUCKET" --force
|
|
|
|
|
|
|
|
if [ "$(uplink ls | grep "No buckets" | wc -l)" = "0" ]; then
|
|
|
|
echo "an integration test did not clean up after itself entirely"
|
|
|
|
exit 1
|
2021-02-24 16:35:02 +00:00
|
|
|
fi
|