From 8bc42fd1d9676c3141080860b41c34d3808c0424 Mon Sep 17 00:00:00 2001 From: Semen Bezrukov Date: Fri, 25 Oct 2019 10:20:26 +0300 Subject: [PATCH] Refactor Travis tests --- .travis.yml | 32 ++++++++++++--- activemq.yml => test/activemq.yml | 8 ++-- test/defaults.env | 40 +++++++++++++++++++ mysql.yml => test/mysql.yml | 20 +++++----- .../postgres-old.yml | 14 +++---- postgres.yml => test/postgres.yml | 16 ++++---- test.sh => test/test.sh | 18 +++++++-- 7 files changed, 110 insertions(+), 38 deletions(-) rename activemq.yml => test/activemq.yml (75%) create mode 100644 test/defaults.env rename mysql.yml => test/mysql.yml (62%) rename postgres-deprecated-vars.yml => test/postgres-old.yml (65%) rename postgres.yml => test/postgres.yml (69%) rename test.sh => test/test.sh (59%) diff --git a/.travis.yml b/.travis.yml index 82d909d..62c905d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,16 +3,38 @@ language: generic dist: trusty env: - - file: postgres.yml + # postgresql + - config: postgres.yml - - file: mysql.yml + # custom values + - config: postgres.yml + DB_NAME: mydb + DB_USER: myuser + DB_PWD: password + POSTGRES_DB: mydb + POSTGRES_USER: myuser - - file: activemq.yml + # deprecated variables + - config: postgres-old.yml + POSTGRESQL_SERVER_HOST: onlyoffice-postgresql + POSTGRESQL_SERVER_PORT: 5432 + POSTGRESQL_SERVER_DB_NAME: onlyoffice + POSTGRESQL_SERVER_USER: onlyoffice + POSTGRESQL_SERVER_PASS: onlyoffice - - file: postgres-deprecated-vars.yml + # mysql + - config: mysql.yml + DB_TYPE: mysql + DB_HOST: onlyoffice-mysql + DB_PORT: 3306 + + # activemq + - config: activemq.yml + AMQP_SERVER_TYPE: activemq + AMQP_SERVER_URL: amqp://guest:guest@onlyoffice-activemq services: - docker script: - - ./test.sh + - ./test/test.sh diff --git a/activemq.yml b/test/activemq.yml similarity index 75% rename from activemq.yml rename to test/activemq.yml index f6a5fed..14c3884 100644 --- a/activemq.yml +++ b/test/activemq.yml @@ -4,8 +4,8 @@ services: container_name: onlyoffice-documentserver image: onlyoffice/4testing-documentserver-ie:latest environment: - - AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-activemq - - AMQP_SERVER_TYPE=activemq + - AMQP_SERVER_TYPE + - AMQP_SERVER_URL stdin_open: true restart: always ports: @@ -18,8 +18,8 @@ services: container_name: onlyoffice-activemq image: webcenter/activemq:5.14.3 environment: - - ACTIVEMQ_USERS_guest=guest - - ACTIVEMQ_GROUPS_owners=guest + - ACTIVEMQ_USERS_guest + - ACTIVEMQ_GROUPS_owners restart: always networks: - onlyoffice diff --git a/test/defaults.env b/test/defaults.env new file mode 100644 index 0000000..664f342 --- /dev/null +++ b/test/defaults.env @@ -0,0 +1,40 @@ +# DocumentServer Container +ONLYOFFICE_DATA_CONTAINER=true +DB_TYPE=postgres +DB_HOST=onlyoffice-postgresql +DB_PORT=5432 +DB_NAME=onlyoffice +DB_USER=onlyoffice +DB_PWD=onlyoffice +AMQP_SERVER_TYPE=rabbitmq +AMQP_SERVER_URL=amqp://guest:guest@onlyoffice-rabbitmq +REDIS_SERVER_HOST=onlyoffice-redis +REDIS_SERVER_PORT=6379 +JWT_ENABLED=true +JWT_SECRET=secret +JWT_HEADER=Authorization + +ONLYOFFICE_DATA_CONTAINER_HOST=onlyoffice-documentserver-data +BALANCE=uri depth 3 +EXCLUDE_PORTS=443 +HTTP_CHECK=GET /healthcheck +EXTRA_SETTINGS=http-check expect string true +FORCE_SSL=true + +# HAProxy Container +MODE=http +CERT_FOLDER=/certs/ + +# ActiveMQ Container +ACTIVEMQ_USERS_guest=guest +ACTIVEMQ_GROUPS_owners=guest + +# Postgres Container +POSTGRES_DB=onlyoffice +POSTGRES_USER=onlyoffice + +# MySQL Container +MYSQL_DATABASE=onlyoffice +MYSQL_USER=onlyoffice +MYSQL_PASSWORD=onlyoffice +MYSQL_ALLOW_EMPTY_PASSWORD=yes \ No newline at end of file diff --git a/mysql.yml b/test/mysql.yml similarity index 62% rename from mysql.yml rename to test/mysql.yml index da654d3..9a4155f 100644 --- a/mysql.yml +++ b/test/mysql.yml @@ -6,12 +6,12 @@ services: depends_on: - onlyoffice-mysql environment: - - DB_TYPE=mysql - - DB_HOST=onlyoffice-mysql - - DB_PORT=3306 - - DB_NAME=onlyoffice - - DB_USER=onlyoffice - - DB_PWD=onlyoffice + - DB_TYPE + - DB_HOST + - DB_PORT + - DB_NAME + - DB_USER + - DB_PWD stdin_open: true restart: always ports: @@ -21,10 +21,10 @@ services: container_name: onlyoffice-mysql image: mysql:5.7 environment: - - MYSQL_DATABASE=onlyoffice - - MYSQL_USER=onlyoffice - - MYSQL_PASSWORD=onlyoffice - - MYSQL_ALLOW_EMPTY_PASSWORD=yes + - MYSQL_DATABASE + - MYSQL_USER + - MYSQL_PASSWORD + - MYSQL_ALLOW_EMPTY_PASSWORD restart: always volumes: - mysql_data:/var/lib/mysql diff --git a/postgres-deprecated-vars.yml b/test/postgres-old.yml similarity index 65% rename from postgres-deprecated-vars.yml rename to test/postgres-old.yml index b1df23b..4385562 100644 --- a/postgres-deprecated-vars.yml +++ b/test/postgres-old.yml @@ -6,11 +6,11 @@ services: depends_on: - onlyoffice-postgresql environment: - - POSTGRESQL_SERVER_HOST=onlyoffice-postgresql - - POSTGRESQL_SERVER_PORT=5432 - - POSTGRESQL_SERVER_DB_NAME=onlyoffice - - POSTGRESQL_SERVER_USER=onlyoffice - - POSTGRESQL_SERVER_PASS=onlyoffice + - POSTGRESQL_SERVER_HOST + - POSTGRESQL_SERVER_PORT + - POSTGRESQL_SERVER_DB_NAME + - POSTGRESQL_SERVER_USER + - POSTGRESQL_SERVER_PASS stdin_open: true restart: always ports: @@ -20,8 +20,8 @@ services: container_name: onlyoffice-postgresql image: postgres:9.5 environment: - - POSTGRES_DB=onlyoffice - - POSTGRES_USER=onlyoffice + - POSTGRES_DB + - POSTGRES_USER restart: always expose: - '5432' diff --git a/postgres.yml b/test/postgres.yml similarity index 69% rename from postgres.yml rename to test/postgres.yml index 05923b3..0c5c39d 100644 --- a/postgres.yml +++ b/test/postgres.yml @@ -6,12 +6,12 @@ services: depends_on: - onlyoffice-postgresql environment: - - DB_TYPE=postgres - - DB_HOST=onlyoffice-postgresql - - DB_PORT=5432 - - DB_NAME=onlyoffice - - DB_USER=onlyoffice - - DB_PWD=onlyoffice + - DB_TYPE + - DB_HOST + - DB_PORT + - DB_NAME + - DB_USER + - DB_PWD stdin_open: true restart: always ports: @@ -21,8 +21,8 @@ services: container_name: onlyoffice-postgresql image: postgres:9.5 environment: - - POSTGRES_DB=onlyoffice - - POSTGRES_USER=onlyoffice + - POSTGRES_DB + - POSTGRES_USER restart: always expose: - '5432' diff --git a/test.sh b/test/test.sh similarity index 59% rename from test.sh rename to test/test.sh index 8117b02..49d57c3 100755 --- a/test.sh +++ b/test/test.sh @@ -1,13 +1,23 @@ #!/bin/bash # Check if the yml exists -if [[ ! -f $file ]]; then - echo "File $file doesn't exist!" +if [[ ! -f $config ]]; then + echo "File $config doesn't exist!" + exit 1 +fi + +env_file=defaults.env + +# Copy .env +if [[ -f $env_file ]]; then + cp $env_file .env +else + echo "File $env_file doesn't exist!" exit 1 fi # Run test environment -docker-compose -p ds -f $file up -d +docker-compose -p ds -f $config up -d wakeup_timeout=30 @@ -24,4 +34,4 @@ else exit 1 fi -docker-compose -p ds -f $file down +docker-compose -p ds -f $config down