2019-08-07 00:03:14 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -ueo pipefail
|
|
|
|
set +x
|
|
|
|
|
|
|
|
TMP=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
export STORJ_NETWORK_DIR=$TMP
|
|
|
|
cleanup(){
|
2019-08-19 20:13:38 +01:00
|
|
|
git worktree remove -f "$RELEASE_DIR"
|
|
|
|
git worktree remove -f "$BRANCH_DIR"
|
2019-08-07 00:03:14 +01:00
|
|
|
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
|
2019-08-19 20:13:38 +01:00
|
|
|
git worktree add -f "$BRANCH_DIR" HEAD
|
2019-08-07 00:03:14 +01:00
|
|
|
|
|
|
|
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"
|
2019-08-18 15:51:33 +01:00
|
|
|
# delete this file that forces production config settings
|
2019-08-07 00:03:14 +01:00
|
|
|
rm "$RELEASE_DIR/internal/version/release.go"
|
|
|
|
|
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
|
2019-08-28 14:57:34 +01:00
|
|
|
GOBIN=$RELEASE_DIR/bin make -C "$RELEASE_DIR" install-sim
|
|
|
|
GOBIN=$BRANCH_DIR/bin make -C "$BRANCH_DIR" install-sim
|
2019-08-07 00:03:14 +01:00
|
|
|
|
|
|
|
STORJ_NETWORK_HOST4=${STORJ_NETWORK_HOST4:-127.0.0.1}
|
2019-08-18 15:51:33 +01:00
|
|
|
STORJ_SIM_POSTGRES=${STORJ_SIM_POSTGRES:-""}
|
2019-08-07 00:03:14 +01:00
|
|
|
|
2019-08-18 15:51:33 +01:00
|
|
|
if [ -z ${STORJ_SIM_POSTGRES} ]; then
|
2019-08-19 20:13:38 +01:00
|
|
|
echo "Postgres is required for the satellite DB. Exiting."
|
|
|
|
exit 1
|
2019-08-18 15:51:33 +01:00
|
|
|
fi
|
2019-08-07 00:03:14 +01:00
|
|
|
|
2019-08-19 20:13:38 +01:00
|
|
|
# setup the network
|
2019-08-28 14:57:34 +01:00
|
|
|
PATH=$RELEASE_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network --postgres=$STORJ_SIM_POSTGRES setup
|
2019-08-07 00:03:14 +01:00
|
|
|
# run upload part of backward compatibility tests from the lastest release branch
|
2019-08-28 14:57:34 +01:00
|
|
|
PATH=$RELEASE_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh upload
|
2019-08-07 00:03:14 +01:00
|
|
|
|
2019-08-14 16:34:12 +01:00
|
|
|
# this replaces anywhere that has "/release/" in the config file, which currently just renames the static dir paths
|
|
|
|
sed -i -e 's#/release/#/branch/#g' $STORJ_NETWORK_DIR/satellite/0/config.yaml
|
|
|
|
|
2019-08-07 00:03:14 +01:00
|
|
|
# run download part of backward compatibility tests from the current branch
|
2019-08-28 14:57:34 +01:00
|
|
|
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh download
|