2023-06-08 15:38:26 -04:00
|
|
|
#!/usr/bin/env bash
|
2023-07-19 04:28:10 -04:00
|
|
|
# IMPORTANT NOTE: this script does not use the normal LEMMY_DATABASE_URL format
|
|
|
|
# it is expected that this script is called by run-federation-test.sh script.
|
2020-12-10 12:03:11 -05:00
|
|
|
set -e
|
|
|
|
|
2024-05-21 14:47:06 -04:00
|
|
|
if [ -z "$LEMMY_LOG_LEVEL" ];
|
2024-01-26 04:38:15 -05:00
|
|
|
then
|
2024-05-21 14:47:06 -04:00
|
|
|
LEMMY_LOG_LEVEL=info
|
2024-01-26 04:38:15 -05:00
|
|
|
fi
|
|
|
|
|
2020-12-10 12:03:11 -05:00
|
|
|
export RUST_BACKTRACE=1
|
2024-05-21 14:47:06 -04:00
|
|
|
export RUST_LOG="warn,lemmy_server=$LEMMY_LOG_LEVEL,lemmy_federate=$LEMMY_LOG_LEVEL,lemmy_api=$LEMMY_LOG_LEVEL,lemmy_api_common=$LEMMY_LOG_LEVEL,lemmy_api_crud=$LEMMY_LOG_LEVEL,lemmy_apub=$LEMMY_LOG_LEVEL,lemmy_db_schema=$LEMMY_LOG_LEVEL,lemmy_db_views=$LEMMY_LOG_LEVEL,lemmy_db_views_actor=$LEMMY_LOG_LEVEL,lemmy_db_views_moderator=$LEMMY_LOG_LEVEL,lemmy_routes=$LEMMY_LOG_LEVEL,lemmy_utils=$LEMMY_LOG_LEVEL,lemmy_websocket=$LEMMY_LOG_LEVEL"
|
2020-12-10 12:03:11 -05:00
|
|
|
|
2023-09-20 10:18:31 -04:00
|
|
|
export LEMMY_TEST_FAST_FEDERATION=1 # by default, the persistent federation queue has delays in the scale of 30s-5min
|
2023-09-15 11:51:31 -04:00
|
|
|
|
2023-11-16 23:43:40 -05:00
|
|
|
# pictrs setup
|
2024-02-27 09:11:41 -05:00
|
|
|
if [ ! -f "api_tests/pict-rs" ]; then
|
2024-06-20 06:44:06 -04:00
|
|
|
curl "https://git.asonix.dog/asonix/pict-rs/releases/download/v0.5.16/pict-rs-linux-amd64" -o api_tests/pict-rs
|
2023-11-16 23:43:40 -05:00
|
|
|
chmod +x api_tests/pict-rs
|
|
|
|
fi
|
|
|
|
./api_tests/pict-rs \
|
|
|
|
run -a 0.0.0.0:8080 \
|
|
|
|
--danger-dummy-mode \
|
2023-11-22 10:15:06 -05:00
|
|
|
--api-key "my-pictrs-key" \
|
2023-11-16 23:43:40 -05:00
|
|
|
filesystem -p /tmp/pictrs/files \
|
|
|
|
sled -p /tmp/pictrs/sled-repo 2>&1 &
|
|
|
|
|
2020-12-11 12:09:47 -05:00
|
|
|
for INSTANCE in lemmy_alpha lemmy_beta lemmy_gamma lemmy_delta lemmy_epsilon; do
|
2023-07-19 04:28:10 -04:00
|
|
|
echo "DB URL: ${LEMMY_DATABASE_URL} INSTANCE: $INSTANCE"
|
2020-12-15 08:58:11 -05:00
|
|
|
psql "${LEMMY_DATABASE_URL}/lemmy" -c "DROP DATABASE IF EXISTS $INSTANCE"
|
2023-07-19 04:28:10 -04:00
|
|
|
echo "create database"
|
2020-12-15 08:58:11 -05:00
|
|
|
psql "${LEMMY_DATABASE_URL}/lemmy" -c "CREATE DATABASE $INSTANCE"
|
2020-12-11 12:09:47 -05:00
|
|
|
done
|
|
|
|
|
2020-12-15 08:58:11 -05:00
|
|
|
if [ -z "$DO_WRITE_HOSTS_FILE" ]; then
|
|
|
|
if ! grep -q lemmy-alpha /etc/hosts; then
|
|
|
|
echo "Please add the following to your /etc/hosts file, then press enter:
|
|
|
|
|
|
|
|
127.0.0.1 lemmy-alpha
|
|
|
|
127.0.0.1 lemmy-beta
|
|
|
|
127.0.0.1 lemmy-gamma
|
|
|
|
127.0.0.1 lemmy-delta
|
|
|
|
127.0.0.1 lemmy-epsilon"
|
|
|
|
read -p ""
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
for INSTANCE in lemmy-alpha lemmy-beta lemmy-gamma lemmy-delta lemmy-epsilon; do
|
2023-09-09 12:25:03 -04:00
|
|
|
echo "127.0.0.1 $INSTANCE" >>/etc/hosts
|
2020-12-15 08:58:11 -05:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2021-03-01 12:24:11 -05:00
|
|
|
echo "$PWD"
|
|
|
|
|
2024-01-26 04:38:15 -05:00
|
|
|
LOG_DIR=target/log
|
|
|
|
mkdir -p $LOG_DIR
|
|
|
|
|
2020-12-10 12:03:11 -05:00
|
|
|
echo "start alpha"
|
2022-11-09 05:05:00 -05:00
|
|
|
LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_alpha.hjson \
|
2023-09-18 10:28:49 -04:00
|
|
|
LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_alpha" \
|
2024-01-26 04:38:15 -05:00
|
|
|
target/lemmy_server >$LOG_DIR/lemmy_alpha.out 2>&1 &
|
2020-12-10 12:03:11 -05:00
|
|
|
|
|
|
|
echo "start beta"
|
2022-11-09 05:05:00 -05:00
|
|
|
LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_beta.hjson \
|
2023-09-18 10:28:49 -04:00
|
|
|
LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_beta" \
|
2024-01-26 04:38:15 -05:00
|
|
|
target/lemmy_server >$LOG_DIR/lemmy_beta.out 2>&1 &
|
2020-12-10 12:03:11 -05:00
|
|
|
|
|
|
|
echo "start gamma"
|
2022-11-09 05:05:00 -05:00
|
|
|
LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_gamma.hjson \
|
2023-09-18 10:28:49 -04:00
|
|
|
LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_gamma" \
|
2024-01-26 04:38:15 -05:00
|
|
|
target/lemmy_server >$LOG_DIR/lemmy_gamma.out 2>&1 &
|
2020-12-10 12:03:11 -05:00
|
|
|
|
|
|
|
echo "start delta"
|
|
|
|
# An instance with only an allowlist for beta
|
2022-11-09 05:05:00 -05:00
|
|
|
LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_delta.hjson \
|
2023-09-18 10:28:49 -04:00
|
|
|
LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_delta" \
|
2024-01-26 04:38:15 -05:00
|
|
|
target/lemmy_server >$LOG_DIR/lemmy_delta.out 2>&1 &
|
2020-12-10 12:03:11 -05:00
|
|
|
|
|
|
|
echo "start epsilon"
|
|
|
|
# An instance who has a blocklist, with lemmy-alpha blocked
|
2022-11-09 05:05:00 -05:00
|
|
|
LEMMY_CONFIG_LOCATION=./docker/federation/lemmy_epsilon.hjson \
|
2023-09-18 10:28:49 -04:00
|
|
|
LEMMY_DATABASE_URL="${LEMMY_DATABASE_URL}/lemmy_epsilon" \
|
2024-01-26 04:38:15 -05:00
|
|
|
target/lemmy_server >$LOG_DIR/lemmy_epsilon.out 2>&1 &
|
2020-12-10 12:03:11 -05:00
|
|
|
|
|
|
|
echo "wait for all instances to start"
|
2022-11-09 05:05:00 -05:00
|
|
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'lemmy-alpha:8541/api/v3/site')" != "200" ]]; do sleep 1; done
|
2023-07-19 04:28:10 -04:00
|
|
|
echo "alpha started"
|
2022-11-09 05:05:00 -05:00
|
|
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'lemmy-beta:8551/api/v3/site')" != "200" ]]; do sleep 1; done
|
2023-07-19 04:28:10 -04:00
|
|
|
echo "beta started"
|
2022-11-09 05:05:00 -05:00
|
|
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'lemmy-gamma:8561/api/v3/site')" != "200" ]]; do sleep 1; done
|
2023-07-19 04:28:10 -04:00
|
|
|
echo "gamma started"
|
2022-11-09 05:05:00 -05:00
|
|
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'lemmy-delta:8571/api/v3/site')" != "200" ]]; do sleep 1; done
|
2023-07-19 04:28:10 -04:00
|
|
|
echo "delta started"
|
2022-11-09 05:05:00 -05:00
|
|
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'lemmy-epsilon:8581/api/v3/site')" != "200" ]]; do sleep 1; done
|
2023-07-19 04:28:10 -04:00
|
|
|
echo "epsilon started. All started"
|