Optimize db core tests

This commit is contained in:
Théophile Diot 2023-07-04 12:44:25 -04:00
parent 559039dfd1
commit be46f7a8d8
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
5 changed files with 136 additions and 33 deletions

View File

@ -0,0 +1,16 @@
version: "3.5"
services:
bw-db:
image: mariadb:10.10
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=db
- MYSQL_USER=bunkerweb
- MYSQL_PASSWORD=secret
networks:
- bw-docker
networks:
bw-docker:
name: bw-docker

View File

@ -0,0 +1,16 @@
version: "3.5"
services:
bw-db:
image: mysql:8.0
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=db
- MYSQL_USER=bunkerweb
- MYSQL_PASSWORD=secret
networks:
- bw-docker
networks:
bw-docker:
name: bw-docker

View File

@ -0,0 +1,15 @@
version: "3.5"
services:
bw-db:
image: postgres:15.1
environment:
- POSTGRES_USER=bunkerweb
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=db
networks:
- bw-docker
networks:
bw-docker:
name: bw-docker

View File

@ -57,35 +57,6 @@ services:
bw-services:
ipv4_address: 192.168.0.4
bw-maria-db:
image: mariadb:10.10
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=db
- MYSQL_USER=bunkerweb
- MYSQL_PASSWORD=secret
networks:
- bw-docker
bw-mysql-db:
image: mysql:8.0
environment:
- MYSQL_RANDOM_ROOT_PASSWORD=yes
- MYSQL_DATABASE=db
- MYSQL_USER=bunkerweb
- MYSQL_PASSWORD=secret
networks:
- bw-docker
bw-postgres-db:
image: postgres:15.1
environment:
- POSTGRES_USER=bunkerweb
- POSTGRES_PASSWORD=secret
- POSTGRES_DB=db
networks:
- bw-docker
volumes:
bw-data:
name: bw-data

View File

@ -3,7 +3,25 @@
echo "💾 Building db stack ..."
# Starting stack
docker compose pull bw-docker app1 bw-maria-db bw-mysql-db bw-postgres-db
docker compose pull bw-docker app1
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.mariadb.yml pull bw-db
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.mysql.yml pull bw-db
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
fi
docker compose -f docker-compose.postgres.yml pull bw-db
if [ $? -ne 0 ] ; then
echo "💾 Pull failed ❌"
exit 1
@ -110,6 +128,9 @@ for test in "local" "multisite" "mariadb" "mysql" "postgres"
do
if [ "$test" = "local" ] ; then
echo "💾 Running tests with a local database ..."
echo "💾 Creating the bw-docker network ..."
docker network create bw-docker 2>/dev/null
elif [ "$test" = "multisite" ] ; then
echo "💾 Running tests with MULTISITE set to yes and with multisite settings ..."
find . -type f -name 'docker-compose.*' -exec sed -i 's@MULTISITE: "no"$@MULTISITE: "yes"@' {} \;
@ -123,18 +144,63 @@ do
sed -i 's@GLOBAL_USE_REVERSE_PROXY@SERVICE_USE_REVERSE_PROXY@' docker-compose.test.yml
sed -i 's@GLOBAL_REVERSE_PROXY_HOST@SERVICE_REVERSE_PROXY_HOST@' docker-compose.test.yml
sed -i 's@GLOBAL_REVERSE_PROXY_URL@SERVICE_REVERSE_PROXY_URL@' docker-compose.test.yml
echo "💾 Creating the bw-docker network ..."
docker network create bw-docker 2>/dev/null
elif [ "$test" = "mariadb" ] ; then
echo "💾 Running tests with MariaDB database ..."
echo " Keeping the MULTISITE variable to yes and multisite settings ..."
find . -type f -name 'docker-compose.*' -exec sed -i 's@DATABASE_URI: ".*"$@DATABASE_URI: "mariadb+pymysql://bunkerweb:secret\@bw-maria-db:3306/db"@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@DATABASE_URI: ".*"$@DATABASE_URI: "mariadb+pymysql://bunkerweb:secret\@bw-db:3306/db"@' {} \;
echo "💾 Starting mariadb ..."
docker compose -f docker-compose.mariadb.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose -f docker-compose.mariadb.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
fi
fi
elif [ "$test" = "mysql" ] ; then
echo "💾 Running tests with MySQL database ..."
echo " Keeping the MULTISITE variable to yes and multisite settings ..."
find . -type f -name 'docker-compose.*' -exec sed -i 's@DATABASE_URI: ".*"$@DATABASE_URI: "mysql+pymysql://bunkerweb:secret\@bw-mysql-db:3306/db"@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@DATABASE_URI: ".*"$@DATABASE_URI: "mysql+pymysql://bunkerweb:secret\@bw-db:3306/db"@' {} \;
echo "💾 Starting mysql ..."
docker compose -f docker-compose.mysql.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose -f docker-compose.mysql.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
fi
fi
elif [ "$test" = "postgres" ] ; then
echo "💾 Running tests with PostgreSQL database ..."
echo " Keeping the MULTISITE variable to yes and multisite settings ..."
find . -type f -name 'docker-compose.*' -exec sed -i 's@DATABASE_URI: ".*"$@DATABASE_URI: "postgresql://bunkerweb:secret\@bw-postgres-db:5432/db"@' {} \;
find . -type f -name 'docker-compose.*' -exec sed -i 's@DATABASE_URI: ".*"$@DATABASE_URI: "postgresql://bunkerweb:secret\@bw-db:5432/db"@' {} \;
echo "💾 Starting postgres ..."
docker compose -f docker-compose.postgres.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
manual=0
docker compose -f docker-compose.postgres.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
fi
fi
fi
echo "💾 Starting stack ..."
@ -143,6 +209,25 @@ do
echo "💾 Up failed, retrying ... ⚠️"
manual=1
cleanup_stack
if [ "$test" = "mariadb" ] ; then
docker compose -f docker-compose.mariadb.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
fi
elif [ "$test" = "mysql" ] ; then
docker compose -f docker-compose.mysql.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
fi
elif [ "$test" = "postgres" ] ; then
docker compose -f docker-compose.postgres.yml up -d 2>/dev/null
if [ $? -ne 0 ] ; then
echo "💾 Up failed ❌"
exit 1
fi
fi
manual=0
docker compose up -d 2>/dev/null
if [ $? -ne 0 ] ; then