end-to-end/federation/federation.sh
famfo 45417622c0 feat(federation): add scenario-gotosocial setup and teardown (#1275)
3/5 taken out of #1269

This patch adds the setup and teardown of GoToSocial for use in the end-to-end tests

Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/1275
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Reviewed-by: Beowulf <beowulf@beocode.eu>
Co-authored-by: famfo <famfo@famfo.xyz>
Co-committed-by: famfo <famfo@famfo.xyz>
2026-01-05 17:36:57 +00:00

96 lines
2.6 KiB
Bash
Executable file

# Copyright 2024 The Forgejo Authors
# SPDX-License-Identifier: MIT
FEDERATION_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export FEDERATION_INSTANCES="ONE TWO"
export FEDERATION_CONFIGS
function federation_setup_variables() {
if test "$FEDERATION_CONFIGS"; then
return
fi
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
done
}
function federation_verify_scenario() {
local scenario=$1
federation_setup_variables
export scenario
export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario
if test -f $SCENARIO_DIR/setup.sh; then
echo "============================ SETUP scenario-$scenario ==================="
bash -ex $SCENARIO_DIR/setup.sh || return 1
fi
echo "============================ RUN scenario-$scenario ==================="
bash -ex $SCENARIO_DIR/run.sh || return 1
if test -f $SCENARIO_DIR/teardown.sh; then
echo "============================ TEARDOWN scenario-$scenario ==================="
bash -ex $SCENARIO_DIR/teardown.sh || return 1
fi
}
function federation_setup() {
federation_setup_variables
local version=$1
federation_teardown
local config
for config in $FEDERATION_CONFIGS; do
reset_forgejo $config
start_forgejo $version $config
done
}
function federation_teardown() {
federation_setup_variables
local config
for config in $FEDERATION_CONFIGS; do
stop_forgejo $config
done
}
function test_federation() {
# start_gitlab gitlab/gitlab-ce:17.1.0-ce.0
federation_setup_variables
local versions="${1:-$RELEASE_NUMBERS}"
for version in $versions; do
# name, minimum version
# NOTE: newline seperated, not comma :>
scenarios=(
"star 7.1"
"mastodon 14.0"
"gotosocial 14.0"
)
for scenario_version_str in "${scenarios[@]}"; do
IFS=' ' declare -a scenario_version="($scenario_version_str)"
if dpkg --compare-versions "$version" lt "${scenario_version[1]}"; then
continue
fi
federation_setup "$version"
run federation_verify_scenario "${scenario_version[0]}"
done
done
}