From b48ed93e9d8006142b9c579843d49b5d0f93f7b5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 20 Jan 2016 01:06:00 +0100 Subject: [PATCH] Added postgresql support. --- .gitlab-ci.yml | 17 ++++++- script/build/test_db_config.sh | 85 ++++++++++++++++++++++++---------- script/build/test_shutdown.sh | 2 + 3 files changed, 78 insertions(+), 26 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9e9f7c9e3..7fceb9758 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,10 +21,25 @@ coffeelint: script: - coffeelint app/ -job_unit: +job_unit_mysql: stage: test tags: - core + - mysql + script: + - export RAILS_ENV=test + - rake db:drop; + - rake db:create + - rake db:migrate + - rake db:seed + - rake test:units + - rake test:controllers + +job_unit_postgresql: + stage: test + tags: + - core + - postgresql script: - export RAILS_ENV=test - rake db:drop; diff --git a/script/build/test_db_config.sh b/script/build/test_db_config.sh index 002e603fb..4fcaac586 100755 --- a/script/build/test_db_config.sh +++ b/script/build/test_db_config.sh @@ -5,7 +5,13 @@ if [ "$RNAME" == '' ]; then exit 1 fi -DBNAME=$RNAME +if [ "$RDB" == '' ]; then + echo "ERROR: Env RDB is missing!" + exit 1 +fi + +export RAND=`perl -e 'print rand(99999999)*100000'` +DBNAME="$RNAME-$RAND" DBFILE=config/database.yml DB_PRODUCTION=$DBNAME"_production" DB_TEST=$DBNAME"_test" @@ -13,27 +19,56 @@ DB_DEVELOPMENT=$DBNAME"_development" echo "Creating $DBFILE for tests with $DBNAME" -echo "production:" > $DBFILE -echo " adapter: mysql2" >> $DBFILE -echo " database: $DB_PRODUCTION" >> $DBFILE -echo " pool: 50" >> $DBFILE -echo " timeout: 5000" >> $DBFILE -echo " encoding: utf8" >> $DBFILE -echo " username: root" >> $DBFILE -echo " password:" >> $DBFILE -echo "test:" >> $DBFILE -echo " adapter: mysql2" >> $DBFILE -echo " database: $DB_TEST" >> $DBFILE -echo " pool: 50" >> $DBFILE -echo " timeout: 5000" >> $DBFILE -echo " encoding: utf8" >> $DBFILE -echo " username: root" >> $DBFILE -echo " password:" >> $DBFILE -echo "development:" >> $DBFILE -echo " adapter: mysql2" >> $DBFILE -echo " database: $DB_DEVELOPMENT" >> $DBFILE -echo " pool: 50" >> $DBFILE -echo " timeout: 5000" >> $DBFILE -echo " encoding: utf8" >> $DBFILE -echo " username: root" >> $DBFILE -echo " password:" >> $DBFILE +if [ "$RDB" == 'mysql' ]; then + echo "production:" > $DBFILE + echo " adapter: mysql2" >> $DBFILE + echo " database: $DB_PRODUCTION" >> $DBFILE + echo " pool: 50" >> $DBFILE + echo " timeout: 5000" >> $DBFILE + echo " encoding: utf8" >> $DBFILE + echo " username: root" >> $DBFILE + echo " password:" >> $DBFILE + echo "test:" >> $DBFILE + echo " adapter: mysql2" >> $DBFILE + echo " database: $DB_TEST" >> $DBFILE + echo " pool: 50" >> $DBFILE + echo " timeout: 5000" >> $DBFILE + echo " encoding: utf8" >> $DBFILE + echo " username: root" >> $DBFILE + echo " password:" >> $DBFILE + echo "development:" >> $DBFILE + echo " adapter: mysql2" >> $DBFILE + echo " database: $DB_DEVELOPMENT" >> $DBFILE + echo " pool: 50" >> $DBFILE + echo " timeout: 5000" >> $DBFILE + echo " encoding: utf8" >> $DBFILE + echo " username: root" >> $DBFILE + echo " password:" >> $DBFILE +fi + +if [ "$RDB" == 'postgresql' ]; then + echo "production:" > $DBFILE + echo " adapter: postgresql" >> $DBFILE + echo " database: $DB_PRODUCTION" >> $DBFILE + echo " pool: 50" >> $DBFILE + echo " timeout: 5000" >> $DBFILE + echo " encoding: utf8" >> $DBFILE + echo " username: root" >> $DBFILE + echo " password: pass" >> $DBFILE + echo "test:" >> $DBFILE + echo " adapter: postgresql" >> $DBFILE + echo " database: $DB_TEST" >> $DBFILE + echo " pool: 50" >> $DBFILE + echo " timeout: 5000" >> $DBFILE + echo " encoding: utf8" >> $DBFILE + echo " username: root" >> $DBFILE + echo " password: pass" >> $DBFILE + echo "development:" >> $DBFILE + echo " adapter: postgresql" >> $DBFILE + echo " database: $DB_DEVELOPMENT" >> $DBFILE + echo " pool: 50" >> $DBFILE + echo " timeout: 5000" >> $DBFILE + echo " encoding: utf8" >> $DBFILE + echo " username: root" >> $DBFILE + echo " password: pass" >> $DBFILE +fi \ No newline at end of file diff --git a/script/build/test_shutdown.sh b/script/build/test_shutdown.sh index eb8e82d74..ed4c900a7 100755 --- a/script/build/test_shutdown.sh +++ b/script/build/test_shutdown.sh @@ -8,4 +8,6 @@ script/scheduler.rb stop script/websocket-server.rb stop kill $(cat tmp/pids/puma.pid) +rake db:drop + exit $EXIT