Merge pull request 'split tests into upgrades, storages and packages' (#108) from twenty-panda/end-to-end:wip-versions into main
Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/108 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
This commit is contained in:
commit
8034186267
26 changed files with 358 additions and 191 deletions
19
.forgejo/prepare-end-to-end/action.yml
Normal file
19
.forgejo/prepare-end-to-end/action.yml
Normal file
|
@ -0,0 +1,19 @@
|
|||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/setup-forgejo@v2
|
||||
with:
|
||||
install-only: true
|
||||
- run: forgejo-binary.sh ensure_user forgejo
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: forgejo-dev
|
||||
path: /srv/forgejo-binaries
|
||||
- name: chown/chmod /srv/forgejo-binaries
|
||||
run: |
|
||||
chmod +x /srv/forgejo-binaries/*
|
||||
chown -R forgejo /srv/forgejo-binaries
|
||||
- run: |
|
||||
script=$(pwd)/end-to-end.sh
|
||||
$script run dependencies
|
||||
$script clobber
|
72
.forgejo/workflows/end-to-end.yml
Normal file
72
.forgejo/workflows/end-to-end.yml
Normal file
|
@ -0,0 +1,72 @@
|
|||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: 'docker.io/node:20-bookworm'
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://code.forgejo.org/actions/setup-go@v4
|
||||
with:
|
||||
go-version: "1.21"
|
||||
- name: lib/build.sh
|
||||
run: |
|
||||
set -x
|
||||
|
||||
#
|
||||
# SQLite needs gcc to be compiled
|
||||
#
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -qq
|
||||
apt-get -q install -y -qq build-essential
|
||||
|
||||
d=/tmp/forgejo-binaries
|
||||
mkdir $d /tmp/forgejo-upload
|
||||
|
||||
for version in $(ls forgejo/sources) ; do
|
||||
forgejo=$d/forgejo-$version-dev
|
||||
lib/build.sh $version $d
|
||||
$forgejo --version
|
||||
mv $forgejo /tmp/forgejo-upload
|
||||
done
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: forgejo-dev
|
||||
path: /tmp/forgejo-upload
|
||||
|
||||
packages:
|
||||
needs: [build]
|
||||
runs-on: lxc-bookworm
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: ./.forgejo/prepare-end-to-end
|
||||
- run: su forgejo -c "./end-to-end.sh test_packages"
|
||||
|
||||
upgrade:
|
||||
name: upgrade and storage
|
||||
needs: [build]
|
||||
runs-on: lxc-bookworm
|
||||
steps:
|
||||
- name: cache S3 binaries
|
||||
id: S3
|
||||
uses: https://code.forgejo.org/actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
/usr/local/bin/minio
|
||||
/usr/local/bin/mc
|
||||
/usr/local/bin/garage
|
||||
key: S3
|
||||
|
||||
- name: skip if S3 cache hit
|
||||
if: steps.S3.outputs.cache-hit != 'true'
|
||||
run: echo no hit
|
||||
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: ./.forgejo/prepare-end-to-end
|
||||
- run: su forgejo -c "./end-to-end.sh test_upgrades"
|
||||
- run: su forgejo -c "./end-to-end.sh test_storage"
|
|
@ -1,42 +0,0 @@
|
|||
name: upgrade
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
upgrade:
|
||||
runs-on: lxc-bookworm
|
||||
steps:
|
||||
- name: cache S3 binaries
|
||||
id: S3
|
||||
uses: https://code.forgejo.org/actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
/usr/local/bin/minio
|
||||
/usr/local/bin/mc
|
||||
/usr/local/bin/garage
|
||||
key: S3
|
||||
|
||||
- name: skip if S3 cache hit
|
||||
if: steps.S3.outputs.cache-hit != 'true'
|
||||
run: echo no hit
|
||||
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://code.forgejo.org/actions/setup-forgejo@v2
|
||||
with:
|
||||
install-only: true
|
||||
- uses: https://code.forgejo.org/actions/setup-go@v4
|
||||
with:
|
||||
go-version: "1.21"
|
||||
- run: |
|
||||
set -x
|
||||
forgejo-binary.sh ensure_user forgejo
|
||||
apt-get -q install -y -qq build-essential
|
||||
- run: |
|
||||
script=$(pwd)/forgejo/upgrades/test-upgrade.sh
|
||||
$script run dependencies
|
||||
$script clobber
|
||||
su forgejo -c "$script test_upgrades"
|
|
@ -37,8 +37,8 @@ git clone https://code.forgejo.org/actions/setup-forgejo
|
|||
export PATH=$(pwd)/setup-forgejo:$PATH
|
||||
git clone https://code.forgejo.org/forgejo/end-to-end
|
||||
cd end-to-end
|
||||
export DIR=/tmp/end-to-end
|
||||
rm -fr /tmp/end-to-end ; sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example
|
||||
export DIR=/tmp/forgejo-end-to-end
|
||||
rm -fr /tmp/forgejo-end-to-end ; sudo rm -fr /srv/example ; sudo mkdir /srv/example ; sudo chown -R $USER /srv/example
|
||||
```
|
||||
|
||||
Run using Forgejo built from source.
|
||||
|
|
23
end-to-end.sh
Executable file
23
end-to-end.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
#
|
||||
# Debug loop from the source tree:
|
||||
#
|
||||
# ./end-to-end.sh dependencies
|
||||
# ./end-to-end.sh build_all
|
||||
# VERBOSE=true ./end-to-end.sh test_downgrade_1.20.2_fails
|
||||
#
|
||||
# Everything happens in /tmp/forgejo-end-to-end
|
||||
#
|
||||
|
||||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
SELF="${BASH_SOURCE[0]}"
|
||||
source $SELF_DIR/lib/lib.sh
|
||||
|
||||
source $SELF_DIR/forgejo/fixtures.sh
|
||||
source $SELF_DIR/storage/storage.sh
|
||||
source $SELF_DIR/upgrade/upgrade.sh
|
||||
source $SELF_DIR/packages/packages.sh
|
||||
|
||||
"$@"
|
6
forgejo/fixtures.sh
Normal file
6
forgejo/fixtures.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
FIXTURES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
source $FIXTURES_DIR/fixtures/storage.sh
|
||||
source $FIXTURES_DIR/fixtures/doctor.sh
|
7
forgejo/fixtures/doctor.sh
Normal file
7
forgejo/fixtures/doctor.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
function doctor_run() {
|
||||
local version=$1
|
||||
|
||||
forgejo_cli $version doctor check --all # --log-file -
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
#ONEPIXEL="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
|
||||
|
@ -8,6 +7,9 @@
|
|||
#
|
||||
ONEPIXEL="iVBORw0KGgoAAAANSUhEUgAAASIAAAEiCAYAAABdvt+2AAADrElEQVR4nOzUMRHAMADEsL9eeQd6AsOLhMCT/7udAYS+OgDAiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDuBQAA//+4jAPFe1H1tgAAAABJRU5ErkJggg=="
|
||||
|
||||
STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars"
|
||||
: ${FORGEJO_REPO:=fixture}
|
||||
|
||||
function fixture_get_paths_s3() {
|
||||
local path=$1
|
||||
|
||||
|
@ -82,6 +84,18 @@ function fixture_lfs_create() {
|
|||
)
|
||||
}
|
||||
|
||||
function fixture_lfs_assert() {
|
||||
local d=$(mktemp -d)
|
||||
(
|
||||
git clone http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} $d/${FORGEJO_REPO}
|
||||
cd $d/${FORGEJO_REPO}
|
||||
rm file.txt
|
||||
git-lfs checkout file.txt
|
||||
test -f file.txt
|
||||
)
|
||||
rm -fr $d
|
||||
}
|
||||
|
||||
function fixture_lfs_assert_s3() {
|
||||
local content=$(mc cat testS3/forgejo/lfs/d6/1e/5fa787e50330288923bd0c9866b44643925965144262288447cf52f9f9b7)
|
||||
test "$content" = CONTENT
|
||||
|
@ -201,3 +215,9 @@ function fixture_create() {
|
|||
fixture_${fun}_create
|
||||
done
|
||||
}
|
||||
|
||||
function fixture_assert() {
|
||||
for fun in lfs ; do
|
||||
fixture_${fun}_assert
|
||||
done
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
#!/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() {
|
||||
stop
|
||||
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
|
||||
}
|
||||
|
||||
"$@"
|
13
lib/build.sh
13
lib/build.sh
|
@ -7,18 +7,19 @@ set -ex
|
|||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
version=$1
|
||||
DIR=$2
|
||||
dir_binaries=$2
|
||||
|
||||
v=$(echo $version | sed -E -e 's/^([0-9]+\.[0-9]+).*/\1/')
|
||||
src=$dir_binaries/src-$v
|
||||
read url ref semver < $SELF_DIR/../forgejo/sources/$v
|
||||
|
||||
if ! test -d $DIR/src ; then
|
||||
mkdir -p $DIR/src
|
||||
cd $DIR/src
|
||||
if ! test -d $src ; then
|
||||
mkdir -p $src
|
||||
cd $src
|
||||
git init
|
||||
git remote add origin $url
|
||||
else
|
||||
cd $DIR/src
|
||||
cd $src
|
||||
fi
|
||||
|
||||
if ! [[ "$ref" =~ ^refs/ ]] ; then
|
||||
|
@ -30,4 +31,4 @@ git switch --force-create $v $ref
|
|||
export TAGS="bindata sqlite sqlite_unlock_notify" FORGEJO_VERSION=$semver
|
||||
make deps-backend backend
|
||||
make generate forgejo
|
||||
cp -a forgejo $DIR/forgejo-$v-dev
|
||||
cp -a forgejo $dir_binaries/forgejo-$v-dev
|
||||
|
|
41
lib/lib.sh
41
lib/lib.sh
|
@ -29,6 +29,7 @@ RELEASE_NUMBERS="7.0"
|
|||
PREFIX===============
|
||||
HOST_PORT=$IP:3000
|
||||
DIR=/tmp/forgejo-end-to-end
|
||||
DIR_BINARIES=/srv/forgejo-binaries
|
||||
export DOT_FORGEJO_CURL=$DIR/forgejo-curl
|
||||
export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0
|
||||
: ${FORGEJO_USER:=root}
|
||||
|
@ -70,8 +71,13 @@ function dependencies() {
|
|||
|
||||
function build_all() {
|
||||
for dev in $RELEASE_NUMBERS ; do
|
||||
log_info $dev-dev
|
||||
$LIB_DIR/build.sh $dev $DIR
|
||||
local forgejo=$DIR_BINARIES/forgejo-$dev-dev
|
||||
if test -f $forgejo ; then
|
||||
log_info $dev already exists
|
||||
else
|
||||
$LIB_DIR/build.sh $dev $DIR_BINARIES
|
||||
log_info $dev built from sources
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -108,18 +114,18 @@ function full_version() {
|
|||
function download() {
|
||||
local version=$1
|
||||
|
||||
if ! test -f $DIR/forgejo-$version ; then
|
||||
mkdir -p $DIR
|
||||
if ! test -f $DIR_BINARIES/forgejo-$version ; then
|
||||
mkdir -p $DIR_BINARIES
|
||||
for owner in forgejo forgejo-experimental forgejo-integration ; do
|
||||
full_version=$(full_version $version $owner)
|
||||
if test "$full_version" = "" ; then
|
||||
continue
|
||||
fi
|
||||
if wget -O $DIR/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then
|
||||
if wget -O $DIR_BINARIES/forgejo-$version --quiet https://codeberg.org/$owner/forgejo/releases/download/v$full_version/forgejo-$full_version-linux-amd64 ; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -s $DIR/forgejo-$version ; then
|
||||
if test -s $DIR_BINARIES/forgejo-$version ; then
|
||||
if test "$version" != "$full_version" ; then
|
||||
log_info "downloaded $full_version for $version"
|
||||
fi
|
||||
|
@ -127,7 +133,7 @@ function download() {
|
|||
echo unable to download Forgejo $version
|
||||
return 1
|
||||
fi
|
||||
chmod +x $DIR/forgejo-$version
|
||||
chmod +x $DIR_BINARIES/forgejo-$version
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -147,8 +153,8 @@ function start_forgejo() {
|
|||
|
||||
download $version
|
||||
local work_path=$DIR/forgejo-work-path
|
||||
daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path
|
||||
if ! retry grep 'Starting server on' $work_path/log/forgejo.log ; then
|
||||
daemon --chdir=$DIR --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --pidfile=$DIR/forgejo-pid --errlog=$DIR/forgejo-err.log --output=$DIR/forgejo-out.log -- $DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path
|
||||
if ! retry grep --no-messages --quiet 'Starting server on' $work_path/log/forgejo.log ; then
|
||||
grep '' $DIR/*.log
|
||||
grep '' $work_path/log/*.log 2> /dev/null
|
||||
return 1
|
||||
|
@ -164,7 +170,8 @@ function start_minio() {
|
|||
--env=MINIO_ROOT_PASSWORD=12345678 \
|
||||
--env=MINIO_VOLUMES=$DIR/minio \
|
||||
--pidfile=$DIR/minio-pid --errlog=$DIR/minio-err.log --output=$DIR/minio-out.log -- /usr/local/bin/minio server
|
||||
retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678
|
||||
retry mc alias set testS3 http://127.0.0.1:9000 123456 12345678 >& /dev/null
|
||||
mc alias set testS3 http://127.0.0.1:9000 123456 12345678
|
||||
}
|
||||
|
||||
function start_garage() {
|
||||
|
@ -242,14 +249,20 @@ function reset_garage() {
|
|||
rm -fr $DIR/garage
|
||||
}
|
||||
|
||||
function forgejo_cli() {
|
||||
local version="$1"
|
||||
shift
|
||||
local work_path=$DIR/forgejo-work-path
|
||||
|
||||
$DIR_BINARIES/forgejo-$version --config $work_path/app.ini --work-path $work_path "$@"
|
||||
}
|
||||
|
||||
function create_user_and_login() {
|
||||
local version=$1
|
||||
|
||||
local work_path=$DIR/forgejo-work-path
|
||||
local email="$FORGEJO_USER@example.com"
|
||||
local cli="$DIR/forgejo-$version --config $work_path/app.ini --work-path $work_path"
|
||||
if ! $cli admin user list | grep --quiet "$email" ; then
|
||||
$cli admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email
|
||||
if ! forgejo_cli $version admin user list | grep --quiet "$email" ; then
|
||||
forgejo_cli $version admin user create --admin --username "$FORGEJO_USER" --password "$FORGEJO_PASSWORD" --email $email
|
||||
fi
|
||||
|
||||
forgejo-curl.sh logout
|
||||
|
|
56
storage/storage.sh
Executable file
56
storage/storage.sh
Executable file
|
@ -0,0 +1,56 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
STORAGE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars"
|
||||
|
||||
function storage_reset() {
|
||||
local config=$1
|
||||
reset_forgejo $STORAGE_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
|
||||
storage_reset stable-s3
|
||||
start $version $s3_backend
|
||||
fixture_create
|
||||
for fun in ${STORAGE_FUN} ; do
|
||||
fixture_${fun}_assert_s3
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
source $STORAGE_DIR/test-upgrade-1.20-storage.sh
|
||||
|
||||
function test_storage() {
|
||||
run test_storage_stable_s3 minio
|
||||
run test_storage_stable_s3 garage
|
||||
|
||||
test_upgrade_1_20_storage
|
||||
run test_forgejo_database_v3_upgrades
|
||||
}
|
|
@ -8,11 +8,11 @@ function test_downgrade_1.20.2_fails() {
|
|||
|
||||
log_info "downgrading from 1.20.3-0 to 1.20.2-0 fails"
|
||||
stop
|
||||
reset default
|
||||
storage_reset default
|
||||
start 1.20.3-0
|
||||
stop
|
||||
download 1.20.2-0
|
||||
timeout 60 $DIR/forgejo-1.20.2-0 --config $work_path/app.ini --work-path $work_path || true
|
||||
timeout 60 $DIR_BINARIES/forgejo-1.20.2-0 --config $work_path/app.ini --work-path $work_path || true
|
||||
if ! grep --fixed-strings --quiet 'use the newer database' $work_path/log/forgejo.log ; then
|
||||
cat $work_path/log/forgejo.log
|
||||
return 1
|
||||
|
@ -27,7 +27,7 @@ function test_bug_storage_merged() {
|
|||
log_info "using < 1.20.3-0 and [storage].PATH merge all storage"
|
||||
for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do
|
||||
stop
|
||||
reset merged
|
||||
storage_reset merged
|
||||
start $version
|
||||
for path in ${STORAGE_PATHS} ; do
|
||||
! test -d $work_path/data/$path
|
||||
|
@ -41,7 +41,7 @@ function test_bug_storage_merged() {
|
|||
|
||||
log_info "upgrading from 1.20.2-0 with [storage].PATH fails"
|
||||
download 1.20.3-0
|
||||
timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true
|
||||
timeout 60 $DIR_BINARIES/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true
|
||||
if ! grep --fixed-strings --quiet '[storage].PATH is set and may create storage issues' $work_path/log/forgejo.log ; then
|
||||
cat $work_path/log/forgejo.log
|
||||
return 1
|
||||
|
@ -54,7 +54,7 @@ function test_bug_storage_relative_path() {
|
|||
log_info "using < 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to WORK_PATH"
|
||||
for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do
|
||||
stop
|
||||
reset legagy-relative
|
||||
storage_reset legagy-relative
|
||||
start $version
|
||||
test -d $work_path/relative-lfs
|
||||
test -d $work_path/relative-avatars
|
||||
|
@ -64,7 +64,7 @@ function test_bug_storage_relative_path() {
|
|||
log_info "using >= 1.20.3-0 legacy [server].XXXX and [picture].XXXX are relative to APP_DATA_PATH"
|
||||
for version in 1.20.3-0 1.21.0-5-rc2 ; do
|
||||
stop
|
||||
reset legagy-relative
|
||||
storage_reset legagy-relative
|
||||
start $version
|
||||
test -d $work_path/data/relative-lfs
|
||||
test -d $work_path/data/relative-avatars
|
||||
|
@ -74,7 +74,7 @@ function test_bug_storage_relative_path() {
|
|||
log_info "using >= 1.20.3-0 relative [storage.XXXX].PATHS are relative to APP_DATA_PATH"
|
||||
for version in 1.20.3-0 1.21.0-5-rc2 ; do
|
||||
stop
|
||||
reset storage-relative
|
||||
storage_reset storage-relative
|
||||
start $version
|
||||
for path in ${STORAGE_PATHS} ; do
|
||||
test -d $work_path/data/relative-$path
|
||||
|
@ -84,7 +84,7 @@ function test_bug_storage_relative_path() {
|
|||
log_info "using 1.20.[12]-0 relative [storage.XXXX].PATHS are inconsistent"
|
||||
for version in 1.20.2-0 ; do
|
||||
stop
|
||||
reset storage-relative
|
||||
storage_reset storage-relative
|
||||
start $version
|
||||
test -d $work_path/data/packages
|
||||
test -d $work_path/relative-repo-archive
|
||||
|
@ -97,7 +97,7 @@ function test_bug_storage_relative_path() {
|
|||
log_info "using < 1.20 relative [storage.XXXX].PATHS are inconsistent"
|
||||
for version in 1.18.5-0 1.19.4-0 ; do
|
||||
stop
|
||||
reset storage-relative
|
||||
storage_reset storage-relative
|
||||
start $version
|
||||
test -d $work_path/relative-packages
|
||||
test -d $work_path/relative-repo-archive
|
||||
|
@ -110,7 +110,7 @@ function test_bug_storage_relative_path() {
|
|||
log_info "using < 1.20.3-0 relative [XXXX].PATHS are relative to WORK_PATH"
|
||||
for version in 1.18.5-0 1.19.4-0 1.20.2-0 ; do
|
||||
stop
|
||||
reset relative
|
||||
storage_reset relative
|
||||
start $version
|
||||
for path in ${STORAGE_PATHS} ; do
|
||||
test -d $work_path/relative-$path
|
||||
|
@ -120,7 +120,7 @@ function test_bug_storage_relative_path() {
|
|||
log_info "using >= 1.20.3-0 relative [XXXX].PATHS are relative to APP_DATA_PATH"
|
||||
for version in 1.20.3-0 1.21.0-5-rc2 ; do
|
||||
stop
|
||||
reset relative
|
||||
storage_reset relative
|
||||
start $version
|
||||
for path in ${STORAGE_PATHS} ; do
|
||||
test -d $work_path/data/relative-$path
|
||||
|
@ -139,7 +139,7 @@ function test_bug_storage_s3_misplace() {
|
|||
for version in 1.20.2-0 1.20.3-0 ; do
|
||||
log_info "Forgejo $version & $s3_backend"
|
||||
stop
|
||||
reset misplace-s3
|
||||
storage_reset misplace-s3
|
||||
start $version $s3_backend
|
||||
fixture_create
|
||||
for fun in ${STORAGE_FUN} ; do
|
||||
|
@ -150,7 +150,7 @@ function test_bug_storage_s3_misplace() {
|
|||
for version in 1.18.5-0 1.19.4-0 ; do
|
||||
log_info "Forgejo $version & $s3_backend"
|
||||
stop
|
||||
reset misplace-s3
|
||||
storage_reset misplace-s3
|
||||
start $version $s3_backend
|
||||
fixture_create
|
||||
#
|
||||
|
@ -176,7 +176,7 @@ function test_bug_storage_misplace() {
|
|||
log_info "using < 1.20 and conflicting sections misplace storage"
|
||||
for version in 1.18.5-0 1.19.4-0 ; do
|
||||
stop
|
||||
reset misplace
|
||||
storage_reset misplace
|
||||
start $version
|
||||
#
|
||||
# some storage are where they should be
|
||||
|
@ -195,7 +195,7 @@ function test_bug_storage_misplace() {
|
|||
log_info "using < 1.20.[12]-0 and conflicting sections ignores [storage.*]"
|
||||
for version in 1.20.2-0 ; do
|
||||
stop
|
||||
reset misplace
|
||||
storage_reset misplace
|
||||
start $version
|
||||
for path in ${STORAGE_PATHS} ; do
|
||||
test -d $work_path/elsewhere/$path
|
||||
|
@ -206,7 +206,7 @@ function test_bug_storage_misplace() {
|
|||
|
||||
log_info "upgrading from 1.20.2-0 with conflicting sections fails"
|
||||
download 1.20.3-0
|
||||
timeout 60 $DIR/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true
|
||||
timeout 60 $DIR_BINARIES/forgejo-1.20.3-0 --config $work_path/app.ini --work-path $work_path || true
|
||||
for path in ${STORAGE_PATHS} ; do
|
||||
if ! grep --fixed-strings --quiet "[storage.$path] may conflict" $work_path/log/forgejo.log ; then
|
||||
cat $work_path/log/forgejo.log
|
33
upgrade/default-app.ini
Normal file
33
upgrade/default-app.ini
Normal file
|
@ -0,0 +1,33 @@
|
|||
RUN_MODE = prod
|
||||
WORK_PATH = ${WORK_PATH}
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/data
|
||||
HTTP_PORT = 3000
|
||||
SSH_LISTEN_PORT = 2222
|
||||
LFS_START_SERVER = true
|
||||
|
||||
[queue]
|
||||
TYPE = immediate
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
PATH = ${WORK_PATH}/forgejo.db
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = trace
|
||||
ROUTER = file
|
||||
|
||||
[log.file]
|
||||
FILE_NAME = forgejo.log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[repository]
|
||||
ENABLE_PUSH_CREATE_USER = true
|
||||
DEFAULT_PUSH_CREATE_PRIVATE = false
|
||||
|
||||
[actions]
|
||||
ENABLED = true
|
|
@ -1,6 +1,13 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
function test_forgejo_database_v3_upgrades_list_table() {
|
||||
local table=$1
|
||||
local work_path=$DIR/forgejo-work-path
|
||||
|
@ -13,7 +20,7 @@ function test_forgejo_database_v3_upgrades() {
|
|||
|
||||
stop
|
||||
|
||||
reset default
|
||||
upgrade_reset default
|
||||
log_info "run 1.20.4-1"
|
||||
start 1.20.4-1
|
||||
stop
|
60
upgrade/upgrade.sh
Executable file
60
upgrade/upgrade.sh
Executable file
|
@ -0,0 +1,60 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
UPGRADE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
function upgrade_reset() {
|
||||
local config=$1
|
||||
reset_forgejo $UPGRADE_DIR/$config-app.ini
|
||||
reset_minio
|
||||
}
|
||||
|
||||
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_successful_upgrades() {
|
||||
stop
|
||||
for config in default ; do
|
||||
log_info "using $config app.ini"
|
||||
upgrade_reset $config
|
||||
|
||||
version=1.18
|
||||
log_info "run $version"
|
||||
cleanup_storage
|
||||
start $version
|
||||
fixture_create
|
||||
fixture_assert
|
||||
doctor_run $version
|
||||
|
||||
for version in 1.19 1.20 1.21 $RELEASE_NUMBERS_AND_DEV ; do
|
||||
stop
|
||||
log_info "run $version"
|
||||
start $version
|
||||
verify_storage
|
||||
fixture_assert
|
||||
doctor_run $version
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
source $UPGRADE_DIR/test-upgrade-forgejo-database-v3.sh
|
||||
|
||||
function test_upgrades() {
|
||||
run dependencies
|
||||
run build_all
|
||||
|
||||
run test_successful_upgrades
|
||||
run test_forgejo_database_v3_upgrades
|
||||
}
|
Loading…
Add table
Reference in a new issue