Rewrite integration tests to run with Docker containers
This commit is contained in:
24
tests/docker/Dockerfile.xenial
Normal file
24
tests/docker/Dockerfile.xenial
Normal file
@@ -0,0 +1,24 @@
|
||||
FROM ubuntu:16.04
|
||||
|
||||
RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/supervisor
|
||||
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install -y apache2 supervisor cron curl unzip \
|
||||
libapache2-mod-php7.0 php7.0-cli php7.0-mbstring php7.0-xml php7.0-mysql php7.0-sqlite3 \
|
||||
php7.0-opcache php7.0-json php7.0-pgsql php7.0-ldap php7.0-gd php7.0-zip && \
|
||||
apt clean && \
|
||||
echo "ServerName localhost" >> /etc/apache2/apache2.conf && \
|
||||
sed -ri 's/AllowOverride None/AllowOverride All/g' /etc/apache2/apache2.conf && \
|
||||
a2enmod rewrite && \
|
||||
curl -sS https://getcomposer.org/installer | php -- --filename=/usr/local/bin/composer
|
||||
|
||||
COPY . /var/www/html
|
||||
|
||||
RUN chown -R www-data:www-data /var/www/html/data /var/www/html/plugins
|
||||
|
||||
COPY tests/docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY tests/configs /configs/
|
||||
|
||||
EXPOSE 80
|
||||
|
||||
ENTRYPOINT ["/var/www/html/tests/docker/entrypoint.sh"]
|
||||
27
tests/docker/compose.integration.mysql.yaml
Normal file
27
tests/docker/compose.integration.mysql.yaml
Normal file
@@ -0,0 +1,27 @@
|
||||
version: '2'
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: "kanboard"
|
||||
MYSQL_DATABASE: "kanboard"
|
||||
MYSQL_USER: "kanboard"
|
||||
MYSQL_PASSWORD: "kanboard"
|
||||
ports:
|
||||
- "3306:3306"
|
||||
app:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: tests/docker/Dockerfile.xenial
|
||||
ports:
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- mysql
|
||||
command: config-mysql
|
||||
tests:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: tests/docker/Dockerfile.xenial
|
||||
depends_on:
|
||||
- app
|
||||
command: integration-test-mysql
|
||||
26
tests/docker/compose.integration.postgres.yaml
Normal file
26
tests/docker/compose.integration.postgres.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
version: '2'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:9.5
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: kanboard
|
||||
ports:
|
||||
- "5432:5432"
|
||||
app:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: tests/docker/Dockerfile.xenial
|
||||
ports:
|
||||
- "8000:80"
|
||||
depends_on:
|
||||
- postgres
|
||||
command: config-postgres
|
||||
tests:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: tests/docker/Dockerfile.xenial
|
||||
depends_on:
|
||||
- app
|
||||
command: integration-test-postgres
|
||||
16
tests/docker/compose.integration.sqlite.yaml
Normal file
16
tests/docker/compose.integration.sqlite.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
version: '2'
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: tests/docker/Dockerfile.xenial
|
||||
ports:
|
||||
- "8000:80"
|
||||
command: config-sqlite
|
||||
tests:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: tests/docker/Dockerfile.xenial
|
||||
depends_on:
|
||||
- app
|
||||
command: integration-test-sqlite
|
||||
33
tests/docker/entrypoint.sh
Executable file
33
tests/docker/entrypoint.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function wait_schema_creation() {
|
||||
curl -s http://app/login > /dev/null
|
||||
sleep $1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"config-sqlite")
|
||||
cp /configs/config.sqlite.php /var/www/html/config.php
|
||||
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||
;;
|
||||
"config-postgres")
|
||||
cp /configs/config.postgres.php /var/www/html/config.php
|
||||
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||
;;
|
||||
"config-mysql")
|
||||
cp /configs/config.mysql.php /var/www/html/config.php
|
||||
/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
|
||||
;;
|
||||
"integration-test-sqlite")
|
||||
wait_schema_creation 1
|
||||
/var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.sqlite.xml
|
||||
;;
|
||||
"integration-test-postgres")
|
||||
wait_schema_creation 5
|
||||
/var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.postgres.xml
|
||||
;;
|
||||
"integration-test-mysql")
|
||||
wait_schema_creation 15
|
||||
/var/www/html/vendor/phpunit/phpunit/phpunit -c /var/www/html/tests/integration.mysql.xml
|
||||
;;
|
||||
esac
|
||||
6
tests/docker/supervisord.conf
Normal file
6
tests/docker/supervisord.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
[supervisord]
|
||||
nodaemon=true
|
||||
|
||||
[program:apache2]
|
||||
command=/bin/bash -c "source /etc/apache2/envvars && exec /usr/sbin/apache2 -DFOREGROUND"
|
||||
autorestart=true
|
||||
Reference in New Issue
Block a user