Skip to content

Commit

Permalink
Merge pull request #49 from ezweb/pg10
Browse files Browse the repository at this point in the history
rewrite
  • Loading branch information
arsonik authored Nov 5, 2018
2 parents 974d8d6 + 85cfc28 commit c26747f
Show file tree
Hide file tree
Showing 39 changed files with 782 additions and 658 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bin/
vendor/
.idea/
/composer.lock
39 changes: 12 additions & 27 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
language: php
language: ruby

php:
- "7.1"
env:
- DOCKER_COMPOSE_VERSION=1.22.0

addons:
postgresql: "9.6"
before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin

before_script:
- phpenv config-add config/docker/php/behat/apc.ini
- composer install
- psql -c "create role admin login createdb password 'adminpassword' superuser ;" -U postgres
- psql -c "create role behat login createdb password 'behatpassword';" -U postgres
- psql -c 'create database behat OWNER=behat;' -U postgres
- psql -c 'create database dblinker_test OWNER=behat;' -U postgres
- psql -c 'create database forbidden_db;'
- mysql -e 'create database dblinker_test;'
- mysql -e 'create database forbidden_db;'
- mysql -e 'CREATE USER "behat"@"localhost" IDENTIFIED BY "behatpassword";'
- mysql -u root -e 'GRANT ALL PRIVILEGES ON dblinker_test.* TO "behat"@"localhost";'
- mysql -u root -e 'FLUSH PRIVILEGES;'
services:
- docker

script:
- vendor/bin/behat -s $BEHAT_DB_DRIVER --tags $SKIP_TAGS

env:
- BEHAT_DB_DRIVER=mysqli SKIP_TAGS="~@skip-travis&&~@skip-travis-mysqli" DBLINKER_MYSQL_1_ENV_MYSQL_DATABASE=dblinker_test DBLINKER_MYSQL_1_PORT_3306_TCP_ADDR=127.0.0.1 DBLINKER_MYSQL_1_ENV_MYSQL_USER=behat DBLINKER_MYSQL_1_ENV_MYSQL_PASSWORD=behatpassword DBLINKER_MYSQL_1_ENV_MYSQL_ROOT_PASSWORD=
- BEHAT_DB_DRIVER=pdo_mysql SKIP_TAGS="~@skip-travis&&~@skip-travis-pdo-mysql" DBLINKER_MYSQL_1_ENV_MYSQL_DATABASE=dblinker_test DBLINKER_MYSQL_1_PORT_3306_TCP_ADDR=127.0.0.1 DBLINKER_MYSQL_1_ENV_MYSQL_USER=behat DBLINKER_MYSQL_1_ENV_MYSQL_PASSWORD=behatpassword DBLINKER_MYSQL_1_ENV_MYSQL_ROOT_PASSWORD=
- BEHAT_DB_DRIVER=pdo_pgsql SKIP_TAGS="~@skip-travis&&~@skip-travis-pdo-pgsql" DBLINKER_POSTGRESQL_1_ENV_POSTGRES_DATABASE=dblinker_test DBLINKER_POSTGRESQL_1_PORT_5432_TCP_ADDR=127.0.0.1 DBLINKER_POSTGRESQL_1_ENV_POSTGRES_USER=behat DBLINKER_POSTGRESQL_1_ENV_POSTGRES_PASSWORD=behatpassword DBLINKER_POSTGRES_1_ENV_POSTGRES_ROOT_USER=admin DBLINKER_POSTGRES_1_ENV_POSTGRES_ROOT_PASSWORD=adminpassword

matrix:
fast_finish: true
- docker-compose run composer install
- docker-compose run --rm behat --tags "~@skip-travis&&~@skip-travis-pdo-pgsql&&~@skip-travis-mysqli"
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ Note: You can nest a `MysqlMasterSlavesConnection` in a `MysqlRetryConnection`.

To run the test suite, you need Docker & Docker-Compose:

docker-compose run composer install
docker-compose run behat
6 changes: 1 addition & 5 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,4 @@ default:
pdo_pgsql:
contexts: [ PdoPgsqlContext ]
filters:
tags: ~@skip-pdo-pgsql
mysqlreplic:
contexts: [ MysqlReplicContext ]
filters:
tags: ~@skip-mysql-replic
tags: ~@skip-pdo-pgsql
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
}
},
"require": {
"php": "^7",
"doctrine/dbal": "^2.5.2",
"php": "^7.1",
"doctrine/dbal": "^2.8",
"psr/cache": "^1.0",
"cache/apcu-adapter": "^1.0"
},
Expand Down
9 changes: 9 additions & 0 deletions config/docker/db/init-mysql-master.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE db.`users` (
`name` varchar(50) NULL,
`email` varchar(128) NOT NULL
);

INSERT INTO db.`users` (name, email) VALUES
('John', '[email protected]'),
('Roger', '[email protected]'),
('Max', '[email protected]');
14 changes: 14 additions & 0 deletions config/docker/db/init-mysql-slave.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE TABLE db.`users` (
`name` varchar(50) NULL,
`email` varchar(128) NOT NULL
);

INSERT INTO db.`users` (name, email) VALUES
('John', '[email protected]'),
('Roger', '[email protected]'),
('Max', '[email protected]');

REVOKE ALL ON db.* FROM 'slave_user'@'%';
GRANT SELECT ON *.* TO 'slave_user'@'%';

FLUSH PRIVILEGES ;
9 changes: 9 additions & 0 deletions config/docker/db/init-pgsql-master.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TABLE users (
name varchar(50) NULL,
email varchar(128) NOT NULL
);

INSERT INTO users (name, email) VALUES
('John', '[email protected]'),
('Roger', '[email protected]'),
('Max', '[email protected]');
12 changes: 12 additions & 0 deletions config/docker/db/init-pgsql-slave.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE users (
name varchar(50) NULL,
email varchar(128) NOT NULL
);

INSERT INTO users (name, email) VALUES
('John', '[email protected]'),
('Roger', '[email protected]'),
('Max', '[email protected]');

REVOKE ALL ON users FROM slave_user;
GRANT SELECT ON users TO slave_user;
2 changes: 2 additions & 0 deletions config/docker/db/my.cnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mysqld]
max_user_connections=8
3 changes: 0 additions & 3 deletions config/docker/php/cli/Dockerfile

This file was deleted.

8 changes: 2 additions & 6 deletions config/docker/php/composer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
FROM php:7.1
FROM php:7.1-fpm-alpine

RUN apt-get update
RUN apt-get install -y zlib1g-dev
RUN docker-php-ext-install zip
RUN docker-php-ext-install mbstring

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir /usr/local/bin --filename composer

RUN docker-php-ext-install mbstring

ENTRYPOINT ["/usr/local/bin/composer"]

WORKDIR /scripts
2 changes: 1 addition & 1 deletion config/docker/php/vendor/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:7.1-fpm
FROM php:7.1-fpm-alpine

VOLUME /scripts/vendor/

Expand Down
94 changes: 85 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ composer:
build: config/docker/php/composer
volumes:
- ./composer.json:/scripts/composer.json:rw
- ./composer.lock:/scripts/composer.lock:rw
# - ./composer.lock:/scripts/composer.lock:rw
- ./bin:/scripts/bin:rw
volumes_from:
- vendor
Expand All @@ -19,19 +19,95 @@ behat:
volumes_from:
- vendor
links:
- mysql
- postgresql
mysql:
- mysql_master
- mysql_slave_1
- mysql_slave_2
- mysql_slave_3
- postgresql_master
- postgresql_slave_1
- postgresql_slave_2
- postgresql_slave_3

mysql_master:
image: mariadb:10.2
volumes:
- ./config/docker/db/my.cnf:/etc/mysql/conf.d/docker.cnf
- ./config/docker/db/init-mysql-master.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
MYSQL_DATABASE: db
MYSQL_USER: master_user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword

mysql_slave_1:
image: mariadb:10.2
volumes:
- ./config/docker/db/my.cnf:/etc/mysql/conf.d/docker.cnf
- ./config/docker/db/init-mysql-slave.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
MYSQL_DATABASE: db
MYSQL_USER: slave_user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword

mysql_slave_2:
image: mariadb:10.2
volumes:
- ./config/docker/db/my.cnf:/etc/mysql/conf.d/docker.cnf
- ./config/docker/db/init-mysql-slave.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
MYSQL_DATABASE: db
MYSQL_USER: user
MYSQL_USER: slave_user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword
postgresql:
image: postgres:9.6

mysql_slave_3:
image: mariadb:10.2
volumes:
- ./config/docker/db/my.cnf:/etc/mysql/conf.d/docker.cnf
- ./config/docker/db/init-mysql-slave.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
POSTGRES_DATABASE: db
POSTGRES_USER: user
MYSQL_DATABASE: db
MYSQL_USER: slave_user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpassword

postgresql_master:
image: postgres:10
volumes:
- ./config/docker/db/init-pgsql-master.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
POSTGRES_DB: db
POSTGRES_USER: master_user
POSTGRES_PASSWORD: password
POSTGRES_ROOT_PASSWORD: password

postgresql_slave_1:
image: postgres:10
volumes:
- ./config/docker/db/init-pgsql-slave.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
POSTGRES_DB: db
POSTGRES_USER: slave_user
POSTGRES_PASSWORD: password
POSTGRES_ROOT_PASSWORD: password

postgresql_slave_2:
image: postgres:10
volumes:
- ./config/docker/db/init-pgsql-slave.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
POSTGRES_DB: db
POSTGRES_USER: slave_user
POSTGRES_PASSWORD: password
POSTGRES_ROOT_PASSWORD: password

postgresql_slave_3:
image: postgres:10
volumes:
- ./config/docker/db/init-pgsql-slave.sql:/docker-entrypoint-initdb.d/init.sql:ro
environment:
POSTGRES_DB: db
POSTGRES_USER: slave_user
POSTGRES_PASSWORD: password
POSTGRES_ROOT_PASSWORD: password
Loading

0 comments on commit c26747f

Please sign in to comment.