mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-29 12:23:42 +03:00
Run the tests against all the available server versions
This commit is contained in:
parent
11ad1005e0
commit
def22982fb
18
.travis.yml
18
.travis.yml
|
@ -1,11 +1,9 @@
|
|||
# Travis CI configuration file for psycopg2
|
||||
|
||||
dist: trusty
|
||||
sudo: required
|
||||
language: python
|
||||
|
||||
services:
|
||||
- postgresql
|
||||
|
||||
addons:
|
||||
postgresql: 9.4
|
||||
|
||||
python:
|
||||
- 2.6
|
||||
- 2.7
|
||||
|
@ -15,14 +13,12 @@ python:
|
|||
- 3.5
|
||||
- 3.6-dev
|
||||
|
||||
before_script:
|
||||
- psql -c 'create database psycopg2_test;' -U postgres
|
||||
- psql -c 'create extension hstore;' -U postgres
|
||||
|
||||
install:
|
||||
- python setup.py install
|
||||
|
||||
script: make check
|
||||
script:
|
||||
- sudo scripts/travis_prepare.sh
|
||||
- scripts/travis_test.sh
|
||||
|
||||
|
||||
notifications:
|
||||
|
|
41
scripts/travis_prepare.sh
Executable file
41
scripts/travis_prepare.sh
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/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_$port
|
||||
|
||||
pg_createcluster -p $port --start-conf manual $version psycopg
|
||||
set_param "$version" max_prepared_transactions 10
|
||||
sed -i "s/local\s*all\s*postgres.*/local all postgres trust/" \
|
||||
"/etc/postgresql/$version/psycopg/pg_hba.conf"
|
||||
pg_ctlcluster "$version" psycopg start
|
||||
|
||||
sudo -u postgres psql -c "create user travis" "port=$port"
|
||||
}
|
||||
|
||||
# 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
|
39
scripts/travis_test.sh
Executable file
39
scripts/travis_test.sh
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/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
|
||||
pyver=$(python -c "import sys; print(''.join(map(str,sys.version_info[:2])))")
|
||||
dbname=psycopg_test_$pyver
|
||||
|
||||
# Create a database for each python version to allow tests to run in parallel
|
||||
psql -c "create database $dbname" \
|
||||
"user=postgres port=$port dbname=postgres"
|
||||
|
||||
psql -c "grant create on database $dbname to travis" \
|
||||
"user=postgres port=$port dbname=postgres"
|
||||
|
||||
psql -c "create extension hstore" \
|
||||
"user=postgres port=$port dbname=$dbname"
|
||||
|
||||
printf "\n\nRunning tests against PostgreSQL $version\n\n"
|
||||
export PSYCOPG2_TESTDB=$dbname
|
||||
export PSYCOPG2_TESTDB_PORT=$port
|
||||
export PSYCOPG2_TESTDB_USER=travis
|
||||
make check
|
||||
|
||||
printf "\n\nRunning tests against PostgreSQL $version (green mode)\n\n"
|
||||
export PSYCOPG2_TEST_GREEN=1
|
||||
make check
|
||||
}
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user