Rewrite integration tests to run with Docker containers

This commit is contained in:
Frederic Guillot
2016-06-25 14:34:46 -04:00
parent fc93203e4d
commit 922e0fb6de
49 changed files with 1337 additions and 1637 deletions

View 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"]

View 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

View 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

View 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
View 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

View 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