Skip to content

Commit

Permalink
Run integration tests with PostgreSQL
Browse files Browse the repository at this point in the history
 * Add integration test profile that uses PostgreSQL
 * Add PostgreSQL service to the Travis build
 * Run integration tests using PostgreSQL as persistence layer when building PRs on Travis
  • Loading branch information
mprimi committed Nov 14, 2017
1 parent dd0b52a commit 43f9011
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sudo: required
dist: trusty
addons:
postgresql: "9.6"
apt:
packages:
- mysql-server-5.6
Expand All @@ -11,6 +12,7 @@ jdk:
- oraclejdk8
services:
- mysql
- postgresql
- docker
git:
depth: 250
Expand All @@ -19,6 +21,7 @@ before_script:
- cat "$TRAVIS_BUILD_DIR/travis/config/mysql/my.cnf" | sudo tee -a /etc/mysql/my.cnf
- sudo service mysql restart
- mysql -u root -e 'create database genie;'
- psql -U postgres -c 'create database genie;'
script: ./travis/buildViaTravis.sh
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ public class IntegrationTestActiveProfilesResolver implements ActiveProfilesReso

private static final String DB_SELECTOR_ENV_VARIABLE_NAME = "INTEGRATION_TEST_DB";
private static final String MYSQL = "mysql";
private static final String POSTGRESQL = "postgresql";
private static final String HSQL_MEM = "hsql-mem";
private final Set<String> knownDatabaseProfiles = Sets.newHashSet(
MYSQL,
POSTGRESQL,
HSQL_MEM
);

Expand Down
25 changes: 25 additions & 0 deletions genie-web/src/test/resources/application-db-postgresql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
##
#
# Copyright 2017 Netflix, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##

spring:
datasource:
url: jdbc:postgresql://127.0.0.1/genie
username: postgres
password:
tomcat:
validation-query: select 0;
2 changes: 2 additions & 0 deletions travis/buildViaTravis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
./gradlew build asciidoc coveralls dockerBuildAllImages
# Re-run genie-web integration tests with MySQL...
INTEGRATION_TEST_DB=mysql ./gradlew genie-web:integrationTests
# ... and PostgreSQL
INTEGRATION_TEST_DB=postgresql ./gradlew genie-web:integrationTests
elif [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_TAG" == "" ]; then
echo -e 'Build Branch with Snapshot => Branch ['$TRAVIS_BRANCH']'
./gradlew -Prelease.travisci=true -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" snapshot coveralls publishGhPages dockerPush
Expand Down

0 comments on commit 43f9011

Please sign in to comment.