Skip to content

Commit 1111ddc

Browse files
committed
Docker test environment
1 parent d3aad91 commit 1111ddc

17 files changed

+554
-26
lines changed

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/.idea
2+
/.git
3+
/.dockerignore
4+
/.editorconfig
5+
/.gitattributes
6+
/.github
7+
/.gitignore
8+
/.php_cs.cache
9+
/.travis.yml
10+
/composer.lock
11+
/tests/runtime
12+
/vendor

.gitattributes

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Ignore all test and documentation for archive
22
/.github export-ignore
3+
/docs export-ignore
4+
/tests export-ignore
5+
/.dockerignore export-ignore
6+
/.editorconfig export-ignore
37
/.gitattributes export-ignore
48
/.gitignore export-ignore
5-
/.editorconfig export-ignore
6-
/.scrutinizer.yml export-ignore
9+
/.php_cs export-ignore
710
/.travis.yml export-ignore
811
/phpunit.xml.dist export-ignore
9-
/tests export-ignore
10-
/docs export-ignore

phpunit.xml.dist

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<phpunit bootstrap="./tests/bootstrap.php"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
stopOnFailure="false">
8-
<testsuites>
9-
<testsuite name="Test Suite">
10-
<directory>./tests</directory>
11-
</testsuite>
12-
</testsuites>
3+
colors="true"
4+
convertErrorsToExceptions="true"
5+
convertNoticesToExceptions="true"
6+
convertWarningsToExceptions="true"
7+
stopOnFailure="false">
8+
<testsuites>
9+
<testsuite name="Test Suite">
10+
<directory>./tests</directory>
11+
<exclude>./tests/app</exclude>
12+
</testsuite>
13+
</testsuites>
1314
</phpunit>

tests/benchmark/Controller.php renamed to tests/app/benchmark/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @license http://www.yiiframework.com/license/
66
*/
77

8-
namespace tests\benchmark;
8+
namespace tests\app\benchmark;
99

1010
/**
1111
* Benchmark commands.

tests/benchmark/waiting/Action.php renamed to tests/app/benchmark/waiting/Action.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @license http://www.yiiframework.com/license/
66
*/
77

8-
namespace tests\benchmark\waiting;
8+
namespace tests\app\benchmark\waiting;
99

1010
use Symfony\Component\Process\Process;
1111
use Yii;

tests/benchmark/waiting/Job.php renamed to tests/app/benchmark/waiting/Job.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @license http://www.yiiframework.com/license/
66
*/
77

8-
namespace tests\benchmark\waiting;
8+
namespace tests\app\benchmark\waiting;
99

1010
use yii\base\BaseObject;
1111
use yii\queue\JobInterface;

tests/app/config/console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
'yii\queue\db\migrations',
2626
],
2727
],
28-
'benchmark' => \tests\benchmark\Controller::class,
28+
'benchmark' => \tests\app\benchmark\Controller::class,
2929
],
3030
];

tests/app/config/main.php

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$config = [
33
'id' => 'yii2-queue-app',
44
'basePath' => dirname(__DIR__),
5-
'vendorPath' => dirname(dirname(dirname(__DIR__))) . '/vendor',
5+
'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
66
'bootstrap' => [
77
'fileQueue',
88
'mysqlQueue',
@@ -22,9 +22,14 @@
2222
],
2323
'mysql' => [
2424
'class' => \yii\db\Connection::class,
25-
'dsn' => 'mysql:host=localhost;dbname=yii2_queue_test',
26-
'username' => 'root',
27-
'password' => '',
25+
'dsn' => sprintf(
26+
'mysql:host=%s;port=%s;dbname=%s',
27+
getenv('MYSQL_HOST') ?: 'localhost',
28+
getenv('MYSQL_PORT') ?: 3306,
29+
getenv('MYSQL_DATABASE') ?: 'yii2_queue_test'
30+
),
31+
'username' => getenv('MYSQL_USER') ?: 'root',
32+
'password' => getenv('MYSQL_PASSWORD') ?: '',
2833
'charset' => 'utf8',
2934
'attributes' => [
3035
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode = "STRICT_ALL_TABLES"',
@@ -49,9 +54,14 @@
4954
],
5055
'pgsql' => [
5156
'class' => \yii\db\Connection::class,
52-
'dsn' => 'pgsql:host=localhost;dbname=yii2_queue_test',
53-
'username' => 'postgres',
54-
'password' => '',
57+
'dsn' => sprintf(
58+
'pgsql:host=%s;port=%s;dbname=%s',
59+
getenv('POSTGRES_HOST') ?: 'localhost',
60+
getenv('POSTGRES_PORT') ?: 5432,
61+
getenv('POSTGRES_DB') ?: 'yii2_queue_test'
62+
),
63+
'username' => getenv('POSTGRES_USER') ?: 'postgres',
64+
'password' => getenv('POSTGRES_PASSWORD') ?: '',
5565
'charset' => 'utf8',
5666
],
5767
'pgsqlQueue' => [
@@ -65,23 +75,35 @@
6575
],
6676
'redis' => [
6777
'class' => \yii\redis\Connection::class,
68-
'database' => 2,
78+
'hostname' => getenv('REDIS_HOST') ?: 'localhost',
79+
'port' => getenv('REDIS_PORT') ?: 6379,
80+
'database' => getenv('REDIS_DB') ?: 1,
6981
],
7082
'redisQueue' => [
7183
'class' => \yii\queue\redis\Queue::class,
7284
],
7385
'amqpQueue' => [
7486
'class' => \yii\queue\amqp\Queue::class,
87+
'host' => getenv('RABBITMQ_HOST') ?: 'localhost',
88+
'port' => getenv('RABBITMQ_PORT') ?: 5672,
89+
'user' => getenv('RABBITMQ_USER') ?: 'guest',
90+
'password' => getenv('RABBITMQ_PASSWORD') ?: 'guest',
7591
'queueName' => 'queue-basic',
7692
'exchangeName' => 'exchange-basic',
7793
],
7894
'amqpInteropQueue' => [
7995
'class' => \yii\queue\amqp_interop\Queue::class,
96+
'host' => getenv('RABBITMQ_HOST') ?: 'localhost',
97+
'port' => getenv('RABBITMQ_PORT') ?: 5672,
98+
'user' => getenv('RABBITMQ_USER') ?: 'guest',
99+
'password' => getenv('RABBITMQ_PASSWORD') ?: 'guest',
80100
'queueName' => 'queue-interop',
81101
'exchangeName' => 'exchange-interop',
82102
],
83103
'beanstalkQueue' => [
84104
'class' => \yii\queue\beanstalk\Queue::class,
105+
'host' => getenv('BEANSTALK_HOST') ?: 'localhost',
106+
'port' => getenv('BEANSTALK_PORT') ?: 11300,
85107
],
86108
],
87109
];
@@ -90,6 +112,8 @@
90112
$config['bootstrap'][] = 'gearmanQueue';
91113
$config['components']['gearmanQueue'] = [
92114
'class' => \yii\queue\gearman\Queue::class,
115+
'host' => getenv('GEARMAN_HOST') ?: 'localhost',
116+
'port' => getenv('GEARMAN_PORT') ?: 4730,
93117
];
94118
}
95119

tests/app/docker/mysql/8.0/auth.cnf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mysqld]
2+
default_authentication_plugin=mysql_native_password

tests/app/docker/php/5.6/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM php:5.6-cli
2+
3+
RUN apt-get update \
4+
&& apt-get install -y curl \
5+
&& apt-get install -y zlib1g-dev \
6+
&& docker-php-ext-install zip \
7+
&& apt-get install -y libicu-dev \
8+
&& docker-php-ext-configure intl \
9+
&& docker-php-ext-install intl \
10+
&& docker-php-ext-install pcntl \
11+
&& pecl install igbinary \
12+
&& docker-php-ext-enable igbinary \
13+
&& docker-php-ext-install bcmath \
14+
&& docker-php-ext-install pdo_mysql \
15+
&& apt-get install -y libpq-dev \
16+
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
17+
&& docker-php-ext-install pdo_pgsql \
18+
&& apt-get install -y libgearman-dev \
19+
&& pecl install gearman \
20+
&& docker-php-ext-enable gearman \
21+
&& curl -L -o /tmp/composer-setup.php https://getcomposer.org/installer \
22+
&& php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer \
23+
&& rm /tmp/composer-setup.php \
24+
&& curl -L -o /usr/local/bin/php-cs-fixer https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar \
25+
&& chmod a+x /usr/local/bin/php-cs-fixer
26+
27+
COPY . /code
28+
WORKDIR /code
29+
30+
ENTRYPOINT ["tests/app/docker/php/entrypoint.sh"]

tests/app/docker/php/7.0/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM php:7.0-cli
2+
3+
RUN apt-get update \
4+
&& apt-get install -y curl \
5+
&& apt-get install -y zlib1g-dev \
6+
&& docker-php-ext-install zip \
7+
&& apt-get install -y libicu-dev \
8+
&& docker-php-ext-configure intl \
9+
&& docker-php-ext-install intl \
10+
&& docker-php-ext-install pcntl \
11+
&& pecl install igbinary \
12+
&& docker-php-ext-enable igbinary \
13+
&& docker-php-ext-install bcmath \
14+
&& docker-php-ext-install pdo_mysql \
15+
&& apt-get install -y libpq-dev \
16+
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
17+
&& docker-php-ext-install pdo_pgsql \
18+
&& apt-get -y install libgearman-dev \
19+
&& TMPDIR=$(mktemp -d) \
20+
&& cd $TMPDIR \
21+
&& curl -L https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.3.tar.gz | tar xzv --strip 1 \
22+
&& phpize \
23+
&& ./configure \
24+
&& make -j$(nproc) \
25+
&& make install \
26+
&& cd - \
27+
&& rm -r $TMPDIR \
28+
&& docker-php-ext-enable gearman \
29+
&& curl -L -o /tmp/composer-setup.php https://getcomposer.org/installer \
30+
&& php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer \
31+
&& rm /tmp/composer-setup.php \
32+
&& curl -L -o /usr/local/bin/php-cs-fixer https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar \
33+
&& chmod a+x /usr/local/bin/php-cs-fixer
34+
35+
COPY . /code
36+
WORKDIR /code
37+
38+
ENTRYPOINT ["tests/app/docker/php/entrypoint.sh"]

tests/app/docker/php/7.1/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM php:7.1-cli
2+
3+
RUN apt-get update \
4+
&& apt-get install -y curl \
5+
&& apt-get install -y zlib1g-dev \
6+
&& docker-php-ext-install zip \
7+
&& apt-get install -y libicu-dev \
8+
&& docker-php-ext-configure intl \
9+
&& docker-php-ext-install intl \
10+
&& docker-php-ext-install pcntl \
11+
&& pecl install igbinary \
12+
&& docker-php-ext-enable igbinary \
13+
&& docker-php-ext-install bcmath \
14+
&& docker-php-ext-install pdo_mysql \
15+
&& apt-get install -y libpq-dev \
16+
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
17+
&& docker-php-ext-install pdo_pgsql \
18+
&& apt-get -y install libgearman-dev \
19+
&& TMPDIR=$(mktemp -d) \
20+
&& cd $TMPDIR \
21+
&& curl -L https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.3.tar.gz | tar xzv --strip 1 \
22+
&& phpize \
23+
&& ./configure \
24+
&& make -j$(nproc) \
25+
&& make install \
26+
&& cd - \
27+
&& rm -r $TMPDIR \
28+
&& docker-php-ext-enable gearman \
29+
&& curl -L -o /tmp/composer-setup.php https://getcomposer.org/installer \
30+
&& php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer \
31+
&& rm /tmp/composer-setup.php \
32+
&& curl -L -o /usr/local/bin/php-cs-fixer https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar \
33+
&& chmod a+x /usr/local/bin/php-cs-fixer
34+
35+
COPY . /code
36+
WORKDIR /code
37+
38+
ENTRYPOINT ["tests/app/docker/php/entrypoint.sh"]

tests/app/docker/php/7.2/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM php:7.2-cli
2+
3+
RUN apt-get update \
4+
&& apt-get install -y curl \
5+
&& apt-get install -y zlib1g-dev \
6+
&& docker-php-ext-install zip \
7+
&& apt-get install -y libicu-dev \
8+
&& docker-php-ext-configure intl \
9+
&& docker-php-ext-install intl \
10+
&& docker-php-ext-install pcntl \
11+
&& pecl install igbinary \
12+
&& docker-php-ext-enable igbinary \
13+
&& docker-php-ext-install bcmath \
14+
&& docker-php-ext-install pdo_mysql \
15+
&& apt-get install -y libpq-dev \
16+
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
17+
&& docker-php-ext-install pdo_pgsql \
18+
&& apt-get -y install libgearman-dev \
19+
&& TMPDIR=$(mktemp -d) \
20+
&& cd $TMPDIR \
21+
&& curl -L https://github.com/wcgallego/pecl-gearman/archive/gearman-2.0.3.tar.gz | tar xzv --strip 1 \
22+
&& phpize \
23+
&& ./configure \
24+
&& make -j$(nproc) \
25+
&& make install \
26+
&& cd - \
27+
&& rm -r $TMPDIR \
28+
&& docker-php-ext-enable gearman \
29+
&& curl -L -o /tmp/composer-setup.php https://getcomposer.org/installer \
30+
&& php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer \
31+
&& rm /tmp/composer-setup.php \
32+
&& curl -L -o /usr/local/bin/php-cs-fixer https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar \
33+
&& chmod a+x /usr/local/bin/php-cs-fixer
34+
35+
COPY . /code
36+
WORKDIR /code
37+
38+
ENTRYPOINT ["tests/app/docker/php/entrypoint.sh"]

tests/app/docker/php/entrypoint.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
composer install --prefer-dist --no-interaction \
4+
&& php tests/yii sqlite-migrate/up --interactive=0 \
5+
&& tests/app/docker/wait-for-it.sh $MYSQL_HOST:$MYSQL_PORT \
6+
&& php tests/yii mysql-migrate/up --interactive=0 \
7+
&& tests/app/docker/wait-for-it.sh $POSTGRES_HOST:$POSTGRES_PORT \
8+
&& php tests/yii pgsql-migrate/up --interactive=0 \
9+
&& tests/app/docker/wait-for-it.sh $REDIS_HOST:$REDIS_PORT \
10+
&& tests/app/docker/wait-for-it.sh $RABBITMQ_HOST:$RABBITMQ_PORT \
11+
&& tests/app/docker/wait-for-it.sh $BEANSTALK_HOST:$BEANSTALK_PORT \
12+
&& tests/app/docker/wait-for-it.sh $GEARMAN_HOST:$GEARMAN_PORT \
13+
&& exec "$@"

0 commit comments

Comments
 (0)