Added travis config to test branch 2.6

This commit is contained in:
Daniele Varrazzo 2016-12-25 19:55:24 +01:00
parent 9a6b7e8b10
commit 934f30db1b
3 changed files with 106 additions and 5 deletions

View File

@ -1,13 +1,24 @@
# Travis CI configuration file for psycopg2
dist: trusty
sudo: required
language: python
python:
- 2.6
- 2.7
before_script:
- psql -c 'create database psycopg2_test;' -U postgres
- 3.6-dev
- 2.6
- 3.5
- 3.4
- 3.3
- 3.2
install:
- python setup.py install
- sudo scripts/travis_prepare.sh
script: make check
script:
- scripts/travis_test.sh
notifications:
email: false

60
scripts/travis_prepare.sh Executable file
View File

@ -0,0 +1,60 @@
#!/bin/bash
set -e
# Prepare the test databases in Travis CI.
# The script should be run with sudo.
# The script is not idempotent: it assumes the machine in a clean state
# and is designed for a sudo-enabled Trusty environment.
set_param () {
# Set a parameter in a postgresql.conf file
version=$1
param=$2
value=$3
sed -i "s/^\s*#\?\s*$param.*/$param = $value/" \
"/etc/postgresql/$version/psycopg/postgresql.conf"
}
create () {
version=$1
port=$2
dbname=psycopg2_test
pg_createcluster -p $port --start-conf manual $version psycopg
# for two-phase commit testing
set_param "$version" max_prepared_transactions 10
# for replication testing
set_param "$version" max_wal_senders 5
set_param "$version" max_replication_slots 5
if [ "$version" == "9.2" -o "$version" == "9.3" ]
then
set_param "$version" wal_level hot_standby
else
set_param "$version" wal_level logical
fi
echo "local replication travis trust" \
>> "/etc/postgresql/$version/psycopg/pg_hba.conf"
pg_ctlcluster "$version" psycopg start
sudo -u postgres psql -c "create user travis replication" "port=$port"
sudo -u postgres psql -c "create database $dbname" "port=$port"
sudo -u postgres psql -c "grant create on database $dbname to travis" "port=$port"
sudo -u postgres psql -c "create extension hstore" "port=$port dbname=$dbname"
}
# Would give a permission denied error in the travis build dir
cd /
create 9.6 54396
create 9.5 54395
create 9.4 54394
create 9.3 54393
create 9.2 54392

30
scripts/travis_test.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
# Run the tests in all the databases
# The script is designed for a Trusty environment.
set -e
run_test () {
version=$1
port=$2
dbname=psycopg2_test
printf "\n\nRunning tests against PostgreSQL $version\n\n"
export PSYCOPG2_TESTDB=$dbname
export PSYCOPG2_TESTDB_PORT=$port
export PSYCOPG2_TESTDB_USER=travis
export PSYCOPG2_TEST_REPL_DSN=
python -c "from psycopg2 import tests; tests.unittest.main(defaultTest='tests.test_suite')" --verbose
printf "\n\nRunning tests against PostgreSQL $version (green mode)\n\n"
export PSYCOPG2_TEST_GREEN=1
python -c "from psycopg2 import tests; tests.unittest.main(defaultTest='tests.test_suite')" --verbose
}
run_test 9.6 54396
run_test 9.5 54395
run_test 9.4 54394
run_test 9.3 54393
run_test 9.2 54392