1
0
mirror of https://lab.enough.community/fedeproxy/server synced 2024-12-27 19:02:22 +01:00

create two GitLab instances for testing purposes

This commit is contained in:
Loic Dachary 2021-01-18 23:58:23 +01:00
parent d72172bf2f
commit 9618664e91
No known key found for this signature in database
GPG Key ID: 992D23B392F9E4F2
3 changed files with 95 additions and 13 deletions

1
.gitignore vendored
View File

@ -11,3 +11,4 @@ build
*.egg-info
dist
.eggs
data

View File

@ -2,9 +2,9 @@
image: python:3.7-buster
jobs:
script:
# - tests/setup-gitlab.sh
- tests/setup-gitlab.sh
- pip install tox
- tox
after_script:
- for i in test-gitlab test-mysql test-redis ; do sudo docker stop $i || true ; sudo docker rm $i || true ; done
- tests/setup-gitlab.sh cleanup

View File

@ -1,12 +1,93 @@
#!/bin/bash
set -ex
DATA=$(pwd)/data
for i in test-gitlab test-mysql test-redis ; do sudo docker stop $i || true ; sudo docker rm $i || true ; done
mkdir -p $DATA
sudo docker run --name=test-redis -d sameersbn/redis:latest
sudo rm -fr $DATA/mysql
mkdir -p $DATA/mysql
sudo docker run --name=test-mysql -d -e 'DB_NAME=gitlabhq_production' -e 'DB_USER=gitlab' -e 'DB_PASS=Wrobyak4' -v $DATA/mysql/data:/var/lib/mysql sameersbn/mysql:latest
sudo rm -fr $DATA/gitlab
mkdir -p $DATA/gitlab
sudo docker run --name='test-gitlab' -it -d --link test-mysql:mysql --link test-redis:redisio -e 'GITLAB_SIGNUP=true' -e 'GITLAB_PORT=80' -e 'GITLAB_HOST=localhost' -e 'GITLAB_SSH_PORT=2222' -p 2222:22 -p 8181:80 -e GITLAB_SECRETS_DB_KEY_BASE=4W44tm7bJFRPWNMVzKngffxVWXRpVs49dxhFwgpx7FbCj3wXCMmsz47LzWsdr7nM -v /var/run/docker.sock:/run/docker.sock -v $DATA/gitlab/data:/home/git/data -v $(which docker):/bin/docker sameersbn/gitlab
sleep 60
function prepare_environment() {
if test $(id -u) != 0 ; then
SUDO=sudo
fi
DATA=$(pwd)/data
mkdir -p $DATA
}
function cleanup() {
local serial=$1
for i in test-gitlab$serial test-postgres$serial test-redis$serial ; do
docker stop $i || true
docker rm $i || true
done
}
function run_redis() {
local serial=$1
docker run --name=test-redis$serial -d sameersbn/redis:latest
}
function run_db() {
local serial=$1
$SUDO rm -fr $DATA/postgres$serial
mkdir -p $DATA/postgres$serial
docker run --name=test-postgres$serial -d \
-e 'DB_NAME=gitlabhq_production' \
-e 'DB_USER=gitlab' \
-e 'DB_PASS=Wrobyak4' \
-e 'DB_EXTENSION=pg_trgm,btree_gist' \
-v $DATA/postgres$serial/data:/var/lib/postgresql \
sameersbn/postgresql:11-20200524
}
function run_gitlab() {
local serial=$1
$SUDO rm -fr $DATA/gitlab$serial
mkdir -p $DATA/gitlab$serial
docker run --name="test-gitlab$serial" -d -it --link test-postgres$serial:postgresql --link test-redis$serial:redisio \
-e OAUTH_BLOCK_AUTO_CREATED_USERS=false \
-e 'GITLAB_SIGNUP=true' \
-e 'GITLAB_PORT=80' \
-e 'GITLAB_HOST=localhost' \
-e "GITLAB_SSH_PORT=222$serial" \
-p 222$serial:22 \
-p 818$serial:80 \
-e GITLAB_SECRETS_SECRET_KEY_BASE=4W44tm7bJFRPWNMVzKngffxVWXRpVs49dxhFwgpx7FbCj3wXCMmsz47LzWsdr7nM \
-e GITLAB_SECRETS_DB_KEY_BASE=4W44tm7bJFRPWNMVzKngffxVWXRpVs49dxhFwgpx7FbCj3wXCMmsz47LzWsdr7nM \
-e GITLAB_SECRETS_OTP_KEY_BASE=4W44tm7bJFRPWNMVzKngffxVWXRpVs49dxhFwgpx7FbCj3wXCMmsz47LzWsdr7nM \
-e GITLAB_ROOT_PASSWORD=Wrobyak4 \
-v $DATA/gitlab$serial/data:/home/git/data \
sameersbn/gitlab
}
function main() {
local action=$1
local serials="1 2"
case $action in
cleanup)
for serial in $serials ; do
cleanup $serial
done
;;
*)
prepare_environment
local serial
for serial in $serials ; do
cleanup $serial
run_redis $serial
run_db $serial
run_gitlab $serial
done
for serial in $serials ; do
while true ; do
test $(curl --silent http://localhost:818$serial -o /dev/null -w "%{http_code}") = 302 && break
sleep 5
done
done
;;
esac
}
main "$@"