mirror of
https://lab.enough.community/fedeproxy/server
synced 2024-12-27 19:22:48 +01:00
create two GitLab instances for testing purposes
This commit is contained in:
parent
d72172bf2f
commit
9618664e91
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ build
|
||||
*.egg-info
|
||||
dist
|
||||
.eggs
|
||||
data
|
||||
|
@ -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
|
||||
|
@ -1,12 +1,93 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
function prepare_environment() {
|
||||
if test $(id -u) != 0 ; then
|
||||
SUDO=sudo
|
||||
fi
|
||||
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 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 "$@"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user