Skip to content

Commit

Permalink
Test Travis-CI with MySQL + MariaDB + PostgreSQL #54
Browse files Browse the repository at this point in the history
  • Loading branch information
dennissiemensma committed Mar 8, 2016
1 parent f284082 commit 29bb05e
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 26 deletions.
16 changes: 10 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ python:
- "3.4"

services:
- postgresql
- mysql

addons:
postgresql: "9.3"

env:
- DB=sqlite DJANGO_SETTINGS_MODULE='dsmrreader.config.travis.test_sqlite'
- DB=mysql DJANGO_SETTINGS_MODULE='dsmrreader.config.travis.test_mysql'
# - DB=postgres
- DB=sqlite DJANGO_SETTINGS_MODULE='dsmrreader.config.travis.sqlite'
- DB=mysql DJANGO_SETTINGS_MODULE='dsmrreader.config.travis.mysql'
- DB=postgresql DJANGO_SETTINGS_MODULE='dsmrreader.config.travis.postgresql'

before_install:
- pip install codecov

install:
- pip install -r dsmrreader/provisioning/requirements/base.txt
- pip install -r dsmrreader/provisioning/requirements/test.txt
# - pip install -r dsmrreader/provisioning/requirements/postgresql.txt
- pip install -r dsmrreader/provisioning/requirements/postgresql.txt
- pip install -r dsmrreader/provisioning/requirements/mysql.txt

before_script:
# - sh -c "if [ '$DB' = 'pgsql' ]; then dropdb -U postgres --if-exists dsmrreader; fi"
# - sh -c "if [ '$DB' = 'pgsql' ]; then createdb -U postgres dsmrreader; fi"
- sh -c "if [ '$DB' = 'postgresql' ]; then dropdb -U postgres --if-exists dsmrreader; fi"
- sh -c "if [ '$DB' = 'postgresql' ]; then createdb -U postgres dsmrreader; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'drop database IF EXISTS dsmrreader;' -u root; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysqladmin create dsmrreader; fi"

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ v0.14 (β) - 2016-xx-xx
- Show exceptions in production (webinterface) (#87).
- Keep Supervisor processes running (#79).
- Hourly stats of 22:00:00+00 every day lack gas (#78).
- Test Travis-CI with MySQL + MariaDB + PostgreSQL (#54).
- PostgreSQL tests + nosetests + coverage failure: unrecognized configuration parameter "foreign_key_checks" (#62).
-


Expand Down
10 changes: 9 additions & 1 deletion dsmrreader/config/test_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@


# Use for TESTING only: GRANT ALL PRIVILEGES ON test_dsmrreader.* TO 'dsmrreader'@'localhost';
DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dsmrreader', # Will be adjusted to 'test_*' by Django.
'USER': 'dsmrreader',
'PASSWORD': 'dsmrreader',
'HOST': '127.0.0.1',
}
}
13 changes: 9 additions & 4 deletions dsmrreader/config/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@


# Use for TESTING only: ALTER USER dsmrreader CREATEDB;
DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'

# For some reason nosetests can't handle postgresql. See issue #62 @ Github.
del TEST_RUNNER
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Sub configs should set this.
'NAME': 'dsmrreader', # Will be adjusted to 'test_*' by Django.
'USER': 'dsmrreader',
'PASSWORD': 'dsmrreader',
'HOST': '127.0.0.1',
}
}
14 changes: 14 additions & 0 deletions dsmrreader/config/test_sqlite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
""" Tests with PostgreSQL backend. """
from dsmrreader.config.test import *


# Use for TESTING only: ALTER USER dsmrreader CREATEDB;
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'dsmrreader', # Will be adjusted to 'test_*' by Django.
'USER': 'dsmrreader',
'PASSWORD': 'dsmrreader',
'HOST': '127.0.0.1',
}
}
13 changes: 13 additions & 0 deletions dsmrreader/config/travis/mysql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dsmrreader.config.test_mysql import *


# https://docs.travis-ci.com/user/database-setup/#MySQL
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'dsmrreader',
'USER': 'travis',
'PASSWORD': '',
'HOST': '127.0.0.1',
}
}
13 changes: 13 additions & 0 deletions dsmrreader/config/travis/postgresql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dsmrreader.config.test_postgresql import *


# https://docs.travis-ci.com/user/database-setup/#PostgreSQL
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'dsmrreader',
'USER': 'postgres',
'PASSWORD': '',
'HOST': '127.0.0.1',
}
}
1 change: 1 addition & 0 deletions dsmrreader/config/travis/sqlite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from dsmrreader.config.test_sqlite import *
7 changes: 0 additions & 7 deletions dsmrreader/config/travis/test_mysql.py

This file was deleted.

4 changes: 0 additions & 4 deletions dsmrreader/config/travis/test_sqlite.py

This file was deleted.

7 changes: 3 additions & 4 deletions test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

echo ""
echo "--- Testing with SQLite..."
./manage.py test --settings=dsmrreader.config.test --noinput --with-coverage
./manage.py test --noinput --with-coverage --settings=dsmrreader.config.test_sqlite

echo ""
echo "--- Testing with PostgreSQL..."
# See issue #62 @ Github.
./manage.py test --settings=dsmrreader.config.test_postgresql --noinput
./manage.py test --noinput --with-coverage --settings=dsmrreader.config.test_postgresql

echo ""
echo "--- Testing with MySQL..."
./manage.py test --settings=dsmrreader.config.test_mysql --noinput --with-coverage
./manage.py test --noinput --with-coverage --settings=dsmrreader.config.test_mysql

0 comments on commit 29bb05e

Please sign in to comment.