2020-12-16 18:38:01 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-03-10 11:15:37 +00:00
|
|
|
set -Eeo pipefail
|
2020-12-16 18:38:01 +00:00
|
|
|
set +x
|
|
|
|
|
|
|
|
# Required environment variables
|
|
|
|
if [ -z "${STORJ_SIM_POSTGRES}" ]; then
|
|
|
|
echo "STORJ_SIM_POSTGRES environment variable must be set to a non-empty string"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-03-10 11:15:37 +00:00
|
|
|
if [ -z "${STORJ_REDIS_PORT}" ]; then
|
|
|
|
echo STORJ_REDIS_PORT env var is required
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-16 18:38:01 +00:00
|
|
|
# constants
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
|
|
|
readonly SCRIPT_DIR
|
|
|
|
TMP_DIR=$(mktemp -d -t tmp.XXXXXXXXXX)
|
|
|
|
readonly TMP_DIR
|
2021-03-10 11:15:37 +00:00
|
|
|
STORJ_REDIS_DIR=$(mktemp -d -p /tmp test-sim-redis.XXXX)
|
|
|
|
readonly STORJ_REDIS_DIR
|
|
|
|
export STORJ_REDIS_DIR
|
2020-12-16 18:38:01 +00:00
|
|
|
|
|
|
|
cleanup() {
|
2021-03-10 11:15:37 +00:00
|
|
|
trap - EXIT ERR
|
2020-12-16 18:38:01 +00:00
|
|
|
|
2021-03-10 11:15:37 +00:00
|
|
|
"${SCRIPT_DIR}/redis-server.sh" stop
|
2020-12-16 18:38:01 +00:00
|
|
|
rm -rf "${TMP_DIR}"
|
2021-03-10 11:15:37 +00:00
|
|
|
rm -rf "${STORJ_REDIS_DIR}"
|
2020-12-16 18:38:01 +00:00
|
|
|
}
|
2021-03-10 11:15:37 +00:00
|
|
|
trap cleanup ERR EXIT
|
2020-12-16 18:38:01 +00:00
|
|
|
|
|
|
|
echo "install sim"
|
2022-09-16 10:12:06 +01:00
|
|
|
make -C "$SCRIPT_DIR"/../../.. install-sim
|
2020-12-16 18:38:01 +00:00
|
|
|
|
|
|
|
echo "overriding default max segment size to 6MiB"
|
|
|
|
GOBIN="${TMP_DIR}" go install -v -ldflags "-X 'storj.io/uplink.maxSegmentSize=6MiB'" storj.io/storj/cmd/uplink
|
|
|
|
|
|
|
|
# use modified version of uplink
|
|
|
|
export PATH="${TMP_DIR}:${PATH}"
|
|
|
|
export STORJ_NETWORK_DIR="${TMP_DIR}"
|
|
|
|
|
|
|
|
STORJ_NETWORK_HOST4=${STORJ_NETWORK_HOST4:-127.0.0.1}
|
2021-03-10 11:15:37 +00:00
|
|
|
export STORJ_REDIS_HOST=${STORJ_NETWORK_HOST4}
|
2020-12-16 18:38:01 +00:00
|
|
|
|
|
|
|
# setup the network
|
2021-03-10 11:15:37 +00:00
|
|
|
"${SCRIPT_DIR}/redis-server.sh" start
|
2020-12-16 18:38:01 +00:00
|
|
|
storj-sim --failfast -x --satellites 1 --host "${STORJ_NETWORK_HOST4}" network \
|
2021-03-10 11:15:37 +00:00
|
|
|
--postgres="${STORJ_SIM_POSTGRES}" --redis="${STORJ_REDIS_HOST}:${STORJ_REDIS_PORT}" setup
|
2020-12-16 18:38:01 +00:00
|
|
|
|
|
|
|
# run test that checks that the satellite runs when Redis is up and down
|
|
|
|
storj-sim --failfast -x --satellites 1 --host "${STORJ_NETWORK_HOST4}" network \
|
|
|
|
--redis="127.0.0.1:6379" test bash "${SCRIPT_DIR}/test-uplink-redis-up-and-down.sh" "${REDIS_CONTAINER_NAME}"
|
|
|
|
|
|
|
|
# run test that checks that the satellite runs despite of not being able to connect to Redis
|
2021-03-10 11:15:37 +00:00
|
|
|
"${SCRIPT_DIR}/redis-server.sh" stop
|
2020-12-16 18:38:01 +00:00
|
|
|
storj-sim --failfast -x --satellites 1 --host "${STORJ_NETWORK_HOST4}" network \
|
2022-09-16 10:12:06 +01:00
|
|
|
--redis="127.0.0.1:6379" test bash "${SCRIPT_DIR}/../integration/test-uplink.sh"
|