2024-06-04 16:30:48 +02:00
|
|
|
# Copyright 2024 The Forgejo Authors
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
FEDERATION_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
2024-06-04 16:30:48 +02:00
|
|
|
|
|
|
|
export FEDERATION_INSTANCES="ONE TWO"
|
|
|
|
export FEDERATION_CONFIGS
|
|
|
|
|
|
|
|
function federation_setup_variables() {
|
2024-08-07 08:31:33 +02:00
|
|
|
if test "$FEDERATION_CONFIGS"; then
|
|
|
|
return
|
2024-06-04 16:30:48 +02:00
|
|
|
fi
|
2024-08-07 08:31:33 +02:00
|
|
|
for instance in $FEDERATION_INSTANCES; do
|
|
|
|
local config=$FEDERATION_DIR/$instance-app.ini
|
|
|
|
FEDERATION_CONFIGS="$FEDERATION_CONFIGS $config"
|
|
|
|
local base=$(work_path_base $config)
|
|
|
|
local work_path=$DIR/$base
|
|
|
|
local host_port=$(get_host_port $config)
|
|
|
|
|
|
|
|
eval export ${instance}_CONFIG=$config
|
|
|
|
eval export ${instance}_CURL=$work_path/forgejo-curl.sh
|
|
|
|
eval export ${instance}_HOST_PORT=$host_port
|
2024-06-04 16:30:48 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function federation_verify_scenario() {
|
2024-08-07 08:31:33 +02:00
|
|
|
local scenario=$1
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
export scenario
|
|
|
|
export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
if test -f $SCENARIO_DIR/setup.sh; then
|
|
|
|
echo "============================ SETUP scenario-$scenario ==================="
|
|
|
|
bash -ex $SCENARIO_DIR/setup.sh || return 1
|
|
|
|
fi
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
echo "============================ RUN scenario-$scenario ==================="
|
|
|
|
bash -ex $SCENARIO_DIR/run.sh || return 1
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
if test -f $SCENARIO_DIR/teardown.sh; then
|
|
|
|
echo "============================ TEARDOWN scenario-$scenario ==================="
|
|
|
|
bash -ex $SCENARIO_DIR/teardown.sh || return 1
|
|
|
|
fi
|
2024-06-04 16:30:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function federation_setup() {
|
|
|
|
federation_setup_variables
|
|
|
|
|
|
|
|
local version=$1
|
|
|
|
federation_teardown
|
|
|
|
|
|
|
|
local config
|
2024-08-07 08:31:33 +02:00
|
|
|
for config in $FEDERATION_CONFIGS; do
|
|
|
|
reset_forgejo $config
|
|
|
|
start_forgejo $version $config
|
2024-06-04 16:30:48 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function federation_teardown() {
|
|
|
|
federation_setup_variables
|
|
|
|
|
|
|
|
local config
|
2024-08-07 08:31:33 +02:00
|
|
|
for config in $FEDERATION_CONFIGS; do
|
|
|
|
stop_forgejo $config
|
2024-06-04 16:30:48 +02:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_federation() {
|
2024-06-23 00:22:19 +02:00
|
|
|
# start_gitlab octobus/heptapod:1.5.3
|
2024-06-04 16:30:48 +02:00
|
|
|
federation_setup_variables
|
|
|
|
|
2024-08-08 16:48:39 +02:00
|
|
|
local versions="${1:-$RELEASE_NUMBERS}"
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
for version in $versions; do
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
if dpkg --compare-versions $version lt 7.1; then
|
|
|
|
continue
|
|
|
|
fi
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
federation_setup $version
|
2024-06-04 16:30:48 +02:00
|
|
|
|
2024-08-07 08:31:33 +02:00
|
|
|
for scenario in star; do
|
|
|
|
run federation_verify_scenario $scenario
|
|
|
|
done
|
2024-06-04 16:30:48 +02:00
|
|
|
done
|
|
|
|
}
|