Jg/1622 add backwards compatibility test (#2656)
* add stage to jenkins, add script for backwards compat tests * debug backwards compat tests * add setup in a script * set env vars * add more env ars * mv to one script to debug * debug api key problem * add tmp dir * rm print statements
This commit is contained in:
parent
e34b2c553c
commit
2a464bfdb5
5
Makefile
5
Makefile
@ -124,6 +124,11 @@ test-all-in-one: ## Test docker images locally
|
||||
&& $(MAKE) satellite-image storagenode-image gateway-image \
|
||||
&& ./scripts/test-aio.sh
|
||||
|
||||
.PHONY: test-sim-backwards-compatible
|
||||
test-sim-backwards-compatible: ## Test uploading a file with lastest release (jenkins)
|
||||
@echo "Running ${@}"
|
||||
@./scripts/test-sim-backwards.sh
|
||||
|
||||
##@ Build
|
||||
|
||||
.PHONY: images
|
||||
|
80
scripts/test-backwards.sh
Executable file
80
scripts/test-backwards.sh
Executable file
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ueo pipefail
|
||||
|
||||
: "${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
|
||||
dd if=/dev/urandom of="$output" count=1 bs="$size" >/dev/null 2>&1
|
||||
}
|
||||
random_bytes_file 2x1024 "$TEST_FILES_DIR/small-upload-testfile" # create 2kb file of random bytes (inline)
|
||||
random_bytes_file 5x1024x1024 "$TEST_FILES_DIR/big-upload-testfile" # create 5mb file of random bytes (remote)
|
||||
echo "setup test successfully"
|
||||
}
|
||||
|
||||
cleanup(){
|
||||
rm -rf "$STORJ_NETWORK_DIR"
|
||||
echo "cleaned up test successfully"
|
||||
}
|
||||
|
||||
if [[ "$1" == "upload" ]]; then
|
||||
setup
|
||||
|
||||
uplink --config-dir "$GATEWAY_0_DIR" mb "sj://$BUCKET/"
|
||||
|
||||
uplink --config-dir "$GATEWAY_0_DIR" cp "$TEST_FILES_DIR/small-upload-testfile" "sj://$BUCKET/"
|
||||
uplink --config-dir "$GATEWAY_0_DIR" cp "$TEST_FILES_DIR/big-upload-testfile" "sj://$BUCKET/"
|
||||
|
||||
uplink --config-dir "$GATEWAY_0_DIR" cp "sj://$BUCKET/small-upload-testfile" "$RELEASE_DST_DIR"
|
||||
uplink --config-dir "$GATEWAY_0_DIR" cp "sj://$BUCKET/big-upload-testfile" "$RELEASE_DST_DIR"
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
if [[ "$1" == "download" ]]; then
|
||||
uplink --config-dir "$GATEWAY_0_DIR" cp "sj://$BUCKET/small-upload-testfile" "$BRANCH_DST_DIR"
|
||||
uplink --config-dir "$GATEWAY_0_DIR" cp "sj://$BUCKET/big-upload-testfile" "$BRANCH_DST_DIR"
|
||||
|
||||
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
|
||||
|
||||
uplink --config-dir "$GATEWAY_0_DIR" rm "sj://$BUCKET/small-upload-testfile"
|
||||
uplink --config-dir "$GATEWAY_0_DIR" rm "sj://$BUCKET/big-upload-testfile"
|
||||
uplink --config-dir "$GATEWAY_0_DIR" rb "sj://$BUCKET"
|
||||
cleanup
|
||||
fi
|
44
scripts/test-sim-backwards.sh
Executable file
44
scripts/test-sim-backwards.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
set -ueo pipefail
|
||||
set +x
|
||||
|
||||
TMP=$(mktemp -d -t tmp.XXXXXXXXXX)
|
||||
export STORJ_NETWORK_DIR=$TMP
|
||||
cleanup(){
|
||||
rm -rf "$STORJ_NETWORK_DIR"
|
||||
echo "cleaned up test successfully"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
BRANCH_DIR="$STORJ_NETWORK_DIR/branch"
|
||||
RELEASE_DIR="$STORJ_NETWORK_DIR/release"
|
||||
|
||||
# setup two different directories containing the code for the latest release tag
|
||||
# and for the current branch code
|
||||
git worktree add -f "$BRANCH_DIR"
|
||||
|
||||
latestReleaseTag=$(git describe --tags `git rev-list --tags --max-count=1`)
|
||||
latestReleaseCommit=$(git rev-list -n 1 "$latestReleaseTag")
|
||||
echo "Checking out latest release tag: $latestReleaseTag"
|
||||
git worktree add -f "$RELEASE_DIR" "$latestReleaseCommit"
|
||||
# to run with sqlite, we need to delete this release file that forces postgres
|
||||
rm "$RELEASE_DIR/internal/version/release.go"
|
||||
|
||||
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
make -C "$RELEASE_DIR" install-sim
|
||||
|
||||
STORJ_NETWORK_HOST4=${STORJ_NETWORK_HOST4:-127.0.0.1}
|
||||
|
||||
# setup the network
|
||||
storj-sim -x --host $STORJ_NETWORK_HOST4 network setup
|
||||
|
||||
# run upload part of backward compatibility tests from the lastest release branch
|
||||
storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh upload
|
||||
|
||||
make -C "$BRANCH_DIR" install-sim
|
||||
|
||||
# run download part of backward compatibility tests from the current branch
|
||||
storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh download
|
||||
|
||||
storj-sim -x --host $STORJ_NETWORK_HOST4 network destroy
|
Loading…
Reference in New Issue
Block a user