end-to-end/forgejo/upgrades/test-upgrade.sh
Twenty Panda 9ff495254a packages: simplify the setup to use the same as upgrades
the packages tests control which Forgejo version they run against so
they can test a feature on version X+1 and not on version X
2024-03-15 19:54:34 +07:00

107 lines
2.6 KiB
Bash
Executable file

#!/bin/bash
# SPDX-License-Identifier: MIT
#
# Debug loop from the source tree:
#
# ./forgejo/upgrades/test-upgrade.sh dependencies
# ./forgejo/upgrades/test-upgrade.sh build_all
# VERBOSE=true ./forgejo/upgrades/test-upgrade.sh test_downgrade_1.20.2_fails
#
# Everything happens in /tmp/forgejo-upgrades
#
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SELF="${BASH_SOURCE[0]}"
source $SELF_DIR/../../lib/lib.sh
STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars"
STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars"
: ${FORGEJO_REPO:=fixture}
source $SELF_DIR/fixtures.sh
function reset() {
local config=$1
reset_forgejo $SELF_DIR/$config-app.ini
reset_minio
reset_garage
}
function verify_storage() {
local work_path=$DIR/forgejo-work-path
for path in ${STORAGE_PATHS} ; do
test -d $work_path/data/$path
done
}
function cleanup_storage() {
local work_path=$DIR/forgejo-work-path
for path in ${STORAGE_PATHS} ; do
rm -fr $work_path/data/$path
done
}
function test_storage_stable_s3() {
local work_path=$DIR/forgejo-work-path
local s3_backend=${1:-minio}
log_info "See also https://codeberg.org/forgejo/forgejo/issues/1338"
for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do
log_info "Forgejo $version & $s3_backend"
stop
reset stable-s3
start $version $s3_backend
fixture_create
for fun in ${STORAGE_FUN} ; do
fixture_${fun}_assert_s3
done
done
}
function test_successful_upgrades() {
for config in default specific ; do
log_info "using $config app.ini"
reset $config
for version in 1.18 1.19 1.20.2-0 1.20.3-0 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do
log_info "run $version"
cleanup_storage
start $version
verify_storage
stop
done
done
}
function test_forgejo_database_version() {
local expected_version=$1
local work_path=$DIR/forgejo-work-path
actual_version=$(sqlite3 $work_path/forgejo.db "select version from forgejo_version")
test "$expected_version" = "$actual_version"
}
source $SELF_DIR/test-upgrade-1.20-storage.sh
source $SELF_DIR/test-upgrade-forgejo-database-v3.sh
source $SELF_DIR/../../packages/packages.sh
function test_upgrades() {
run stop
run dependencies
run build_all
test_packages
run test_successful_upgrades
run test_storage_stable_s3 minio
run test_storage_stable_s3 garage
test_upgrade_1_20_storage
run test_forgejo_database_v3_upgrades
}
"$@"