2021-08-31 17:58:01 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -ueo pipefail
|
|
|
|
|
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
source $SCRIPTDIR/utils.sh
|
|
|
|
|
|
|
|
TMPDIR=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
|
|
|
|
cleanup(){
|
|
|
|
rm -rf "$TMPDIR"
|
|
|
|
echo "cleaned up test successfully"
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
trap 'failure ${LINENO} "$BASH_COMMAND"' ERR
|
|
|
|
|
|
|
|
BUCKET=bucket-123
|
|
|
|
SRC_DIR=$TMPDIR/source
|
|
|
|
DST_DIR=$TMPDIR/dst
|
2021-12-16 15:19:50 +00:00
|
|
|
|
|
|
|
export UPLINK_CONFIG_DIR=$TMPDIR/uplink
|
2021-08-31 17:58:01 +01:00
|
|
|
|
|
|
|
mkdir -p "$SRC_DIR" "$DST_DIR"
|
|
|
|
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
|
|
|
|
random_bytes_file "100KiB" "$SRC_DIR/put-file" # create 100KiB file of random bytes (remote)
|
|
|
|
|
|
|
|
# workaround for issues with automatic accepting monitoring question
|
|
|
|
# with first run we need to accept question y/n about monitoring
|
2021-12-16 15:19:50 +00:00
|
|
|
mkdir -p "$UPLINK_CONFIG_DIR"
|
|
|
|
touch "$UPLINK_CONFIG_DIR/config.ini"
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng access save -f --name test-access --access "$GATEWAY_0_ACCESS"
|
|
|
|
uplinkng access use test-access
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng mb "sj://$BUCKET/"
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng cp "$SRC_DIR/small-upload-testfile" "sj://$BUCKET/" --progress=false
|
|
|
|
uplinkng cp "$SRC_DIR/big-upload-testfile" "sj://$BUCKET/" --progress=false
|
|
|
|
uplinkng cp "$SRC_DIR/multisegment-upload-testfile" "sj://$BUCKET/" --progress=false
|
|
|
|
uplinkng cp "$SRC_DIR/diff-size-segments" "sj://$BUCKET/" --progress=false
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
# check named access
|
|
|
|
uplinkng access save -f --name named-access --access "$GATEWAY_0_ACCESS"
|
|
|
|
FILES=$(uplinkng ls "sj://$BUCKET" --access named-access | tee "$TMPDIR/list" | wc -l)
|
2021-08-31 17:58:01 +01:00
|
|
|
EXPECTED_FILES="5"
|
2021-12-16 15:19:50 +00:00
|
|
|
if [ "$FILES" == "$EXPECTED_FILES" ]
|
2021-08-31 17:58:01 +01:00
|
|
|
then
|
|
|
|
echo "listing returns $FILES files"
|
|
|
|
else
|
|
|
|
echo "listing returns $FILES files but want $EXPECTED_FILES"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
SIZE_CHECK=$(cat "$TMPDIR/list" | awk '{if($4 == "0") print "invalid size";}')
|
|
|
|
if [ "$SIZE_CHECK" != "" ]
|
|
|
|
then
|
|
|
|
echo "listing returns invalid size for one of the objects:"
|
|
|
|
cat "$TMPDIR/list"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng ls "sj://$BUCKET/non-existing-prefix"
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng cp "sj://$BUCKET/small-upload-testfile" "$DST_DIR" --progress=false
|
|
|
|
uplinkng cp "sj://$BUCKET/big-upload-testfile" "$DST_DIR" --progress=false
|
|
|
|
uplinkng cp "sj://$BUCKET/multisegment-upload-testfile" "$DST_DIR" --progress=false
|
|
|
|
uplinkng cp "sj://$BUCKET/diff-size-segments" "$DST_DIR" --progress=false
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng ls "sj://$BUCKET/small-upload-testfile" | grep "small-upload-testfile"
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-10-26 11:49:03 +01:00
|
|
|
# test ranged download of object
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng cp "sj://$BUCKET/small-upload-testfile" "$DST_DIR/file-from-cp-range" --progress=false --range bytes=0-5
|
2021-10-26 11:49:03 +01:00
|
|
|
EXPECTED_FILE_SIZE="6"
|
|
|
|
ACTUAL_FILE_SIZE=$(get_file_size "$DST_DIR/file-from-cp-range")
|
|
|
|
if [ "$EXPECTED_FILE_SIZE" != "$ACTUAL_FILE_SIZE" ]
|
|
|
|
then
|
|
|
|
echo "expected downloaded file size to be equal to $EXPECTED_FILE_SIZE, got $ACTUAL_FILE_SIZE"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-10-05 17:48:13 +01:00
|
|
|
# test server-side move operation
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng mv "sj://$BUCKET/big-upload-testfile" "sj://$BUCKET/moved-big-upload-testfile"
|
|
|
|
uplinkng ls "sj://$BUCKET/moved-big-upload-testfile" | grep "moved-big-upload-testfile"
|
|
|
|
uplinkng mv "sj://$BUCKET/moved-big-upload-testfile" "sj://$BUCKET/big-upload-testfile"
|
|
|
|
|
2021-10-05 17:48:13 +01:00
|
|
|
# move prefix
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng mv "sj://$BUCKET/" "sj://$BUCKET/my-prefix/" --recursive
|
|
|
|
FILES=$(uplinkng ls "sj://$BUCKET/my-prefix/" | tee "$TMPDIR/list" | wc -l)
|
2021-10-05 17:48:13 +01:00
|
|
|
EXPECTED_FILES="5" # 4 objects + one line more for headers
|
2021-12-16 15:19:50 +00:00
|
|
|
if [ "$FILES" == "$EXPECTED_FILES" ]
|
2021-10-05 17:48:13 +01:00
|
|
|
then
|
|
|
|
echo "listing after move returns $FILES files"
|
|
|
|
else
|
|
|
|
echo "listing after move returns $FILES files but want $EXPECTED_FILES"
|
2021-12-16 15:19:50 +00:00
|
|
|
cat "$TMPDIR/list"
|
2021-10-05 17:48:13 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng mv "sj://$BUCKET/my-prefix/" "sj://$BUCKET/" --recursive
|
2021-10-05 17:48:13 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng rm "sj://$BUCKET/small-upload-testfile"
|
|
|
|
uplinkng rm "sj://$BUCKET/big-upload-testfile"
|
|
|
|
uplinkng rm "sj://$BUCKET/multisegment-upload-testfile"
|
|
|
|
uplinkng rm "sj://$BUCKET/diff-size-segments"
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng ls "sj://$BUCKET"
|
|
|
|
uplinkng ls -x "sj://$BUCKET"
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng rb "sj://$BUCKET"
|
2021-08-31 17:58:01 +01: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"
|
|
|
|
|
|
|
|
# test deleting non empty bucket with --force flag
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng mb "sj://$BUCKET/"
|
2021-08-31 17:58:01 +01:00
|
|
|
|
|
|
|
for i in $(seq -w 1 16); do
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng cp "$SRC_DIR/small-upload-testfile" "sj://$BUCKET/small-file-$i" --progress=false
|
2021-08-31 17:58:01 +01:00
|
|
|
done
|
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
uplinkng rb "sj://$BUCKET" --force
|
2021-08-31 17:58:01 +01:00
|
|
|
|
2021-12-16 15:19:50 +00:00
|
|
|
if [ "$(uplinkng ls | wc -l)" != "0" ]; then
|
2021-08-31 17:58:01 +01:00
|
|
|
echo "an integration test did not clean up after itself entirely"
|
|
|
|
exit 1
|
|
|
|
fi
|