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
|
|
|
|
2020-03-17 23:12:05 +00:00
|
|
|
latestReleaseCommit="$(git rev-list --exclude='*rc*' --tags --max-count=1)"
|
|
|
|
latestReleaseTag=$(git describe --tags "$latestReleaseCommit")
|
2019-08-07 00:03:14 +01:00
|
|
|
echo "Checking out latest release tag: $latestReleaseTag"
|
|
|
|
git worktree add -f "$RELEASE_DIR" "$latestReleaseCommit"
|
2019-11-14 19:46:15 +00:00
|
|
|
|
2019-08-18 15:51:33 +01:00
|
|
|
# delete this file that forces production config settings
|
2019-11-14 19:46:15 +00:00
|
|
|
rm -f "$RELEASE_DIR/private/version/release.go"
|
|
|
|
rm -f "$RELEASE_DIR/internal/version/release.go"
|
2019-08-07 00:03:14 +01:00
|
|
|
|
|
|
|
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
|
2019-09-04 09:30:59 +01:00
|
|
|
# replace unstable git.apache.org package with github
|
|
|
|
(cd $RELEASE_DIR && go mod edit -replace git.apache.org/thrift.git=github.com/apache/thrift@v0.12.0)
|
|
|
|
|
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-11-16 00:59:32 +00:00
|
|
|
|
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
|
|
|
|
2020-02-07 16:36:28 +00:00
|
|
|
SATELLITE_CONFIG=$(storj-sim network env SATELLITE_0_DIR)/config.yaml
|
|
|
|
|
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
|
2020-02-07 16:36:28 +00:00
|
|
|
sed -i -e 's#/release/#/branch/#g' $SATELLITE_CONFIG
|
2019-09-09 20:13:38 +01:00
|
|
|
|
2019-11-04 19:01:02 +00:00
|
|
|
# replace any 140XX port with 100XX port to fix, satellite.API part removal from satellite.Core
|
2020-02-07 16:36:28 +00:00
|
|
|
sed -i -e "s#$STORJ_NETWORK_HOST4:140#$STORJ_NETWORK_HOST4:100#g" $SATELLITE_CONFIG
|
|
|
|
|
|
|
|
# add new address for admin panel
|
|
|
|
if ! grep -q "admin.address" $SATELLITE_CONFIG; then
|
|
|
|
echo admin.address: $STORJ_NETWORK_HOST4:10005 >> $SATELLITE_CONFIG
|
|
|
|
fi
|
2019-11-06 11:46:54 +00:00
|
|
|
|
|
|
|
# create redis config if it's missing
|
2019-11-01 17:27:47 +00:00
|
|
|
REDIS_CONFIG=$(storj-sim network env REDIS_0_DIR)/redis.conf
|
|
|
|
if [ ! -f "$REDIS_CONFIG" ] ; then
|
|
|
|
echo "daemonize no" >> $REDIS_CONFIG
|
|
|
|
echo "bind $STORJ_NETWORK_HOST4" >> $REDIS_CONFIG
|
|
|
|
echo "port 10004" >> $REDIS_CONFIG
|
|
|
|
echo "timeout 0" >> $REDIS_CONFIG
|
|
|
|
echo "databases 2" >> $REDIS_CONFIG
|
|
|
|
echo "dbfilename sim.rdb" >> $REDIS_CONFIG
|
|
|
|
echo "dir ./" >> $REDIS_CONFIG
|
|
|
|
fi
|
2019-10-30 19:23:09 +00:00
|
|
|
|
2019-09-09 20:13:38 +01:00
|
|
|
## Ensure that partially upgraded network works
|
|
|
|
|
|
|
|
# keep half of the storage nodes on the old version
|
|
|
|
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_0_DIR`/storagenode
|
|
|
|
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_1_DIR`/storagenode
|
|
|
|
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_2_DIR`/storagenode
|
|
|
|
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_3_DIR`/storagenode
|
|
|
|
ln $RELEASE_DIR/bin/storagenode `storj-sim network env STORAGENODE_4_DIR`/storagenode
|
|
|
|
|
2019-11-16 00:59:32 +00:00
|
|
|
# upgrade the trust configuration on the other half as the old configuration is
|
|
|
|
# most certainly not being used outside of test environments and is not
|
|
|
|
# backwards compatible (i.e. ignored)
|
|
|
|
sed -i -e "s#storage.whitelisted-satellites#storage2.trust.sources#g" `storj-sim network env STORAGENODE_5_DIR`/config.yaml
|
|
|
|
sed -i -e "s#storage.whitelisted-satellites#storage2.trust.sources#g" `storj-sim network env STORAGENODE_6_DIR`/config.yaml
|
|
|
|
sed -i -e "s#storage.whitelisted-satellites#storage2.trust.sources#g" `storj-sim network env STORAGENODE_7_DIR`/config.yaml
|
|
|
|
sed -i -e "s#storage.whitelisted-satellites#storage2.trust.sources#g" `storj-sim network env STORAGENODE_8_DIR`/config.yaml
|
|
|
|
sed -i -e "s#storage.whitelisted-satellites#storage2.trust.sources#g" `storj-sim network env STORAGENODE_9_DIR`/config.yaml
|
|
|
|
|
2020-02-18 10:14:50 +00:00
|
|
|
# override configured access with access where address is node ID + satellite addess
|
|
|
|
export STORJ_ACCESS=$(go run "$SCRIPTDIR"/update-access.go `storj-sim network env SATELLITE_0_DIR` `storj-sim network env GATEWAY_0_ACCESS`)
|
|
|
|
|
2019-09-09 20:13:38 +01:00
|
|
|
# run download part of backward compatibility tests from the current branch, using new uplink
|
|
|
|
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh download
|
|
|
|
|
|
|
|
## Ensure that old uplink works
|
|
|
|
|
|
|
|
# overwrite new uplink with release branch and test the download
|
|
|
|
cp $RELEASE_DIR/bin/uplink $BRANCH_DIR/bin/uplink
|
2019-08-14 16:34:12 +01:00
|
|
|
|
2019-08-07 00:03:14 +01:00
|
|
|
# run download part of backward compatibility tests from the current branch
|
2019-09-09 20:13:38 +01:00
|
|
|
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh download
|
|
|
|
|
|
|
|
# run a delete in the network
|
2019-10-30 19:23:09 +00:00
|
|
|
PATH=$BRANCH_DIR/bin:$PATH storj-sim -x --host $STORJ_NETWORK_HOST4 network test bash "$SCRIPTDIR"/test-backwards.sh cleanup
|