Last active
December 24, 2015 17:56
-
-
Save jasonmp85/9963879 to your computer and use it in GitHub Desktop.
PostgreSQL Travis Tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux | |
status=0 | |
# Create Ubuntu's PostgreSQL socket dir and relax permissions. | |
sudo mkdir -p /var/run/postgresql | |
sudo chown -R `whoami` /var/run/postgresql | |
# Configure, build, and install extension | |
./configure PG_CONFIG=/usr/lib/postgresql/$PGVERSION/bin/pg_config | |
make all | |
sudo make install | |
# Change to test directory for remainder | |
cd src/test/regress | |
# Run tests. DBs owned by non-standard owner put socket in /tmp | |
make check-multi check-multi-fdw check-worker || status=$? | |
# Print diff if it exists | |
if test -f regression.diffs; then cat regression.diffs; fi | |
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by https://gist.github.com/petere/6023944 | |
set -eux | |
# Create fully-trusting cluster on custom port, owned by us | |
sudo pg_createcluster $PGVERSION test -p 55435 -u `whoami` -- -A trust | |
# Build and install extension | |
make all PG_CONFIG=/usr/lib/postgresql/$PGVERSION/bin/pg_config | |
sudo make install PG_CONFIG=/usr/lib/postgresql/$PGVERSION/bin/pg_config | |
# Preload library if asked to do so | |
if [ ${PG_PRELOAD+1} ] | |
then | |
echo "shared_preload_libraries = '$PG_PRELOAD'" >> \ | |
/etc/postgresql/$PGVERSION/test/postgresql.conf | |
fi | |
# Start cluster | |
sudo pg_ctlcluster $PGVERSION test start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by https://gist.github.com/petere/6023944 | |
set -eux | |
# we set PGVERSION to 10x of the Citus version when testing Citus, so | |
# only install PostgreSQL proper if it's greater than 9.5 | |
if [ "${PGVERSION//./}" -gt "95" ]; then | |
cituspkgs="$HOME/.cache/citusdb_pkgs" | |
citusversion="$((${PGVERSION//./} / 100)).0" | |
citusdownload="citusdb-${citusversion}.0-1.amd64.deb" | |
citusurl="https://s3.amazonaws.com/packages.citusdata.com/travis/${citusdownload}" | |
# install travis Citus package | |
wget -N -P "${cituspkgs}" "${citusurl}" | |
sudo dpkg --force-confdef --force-confold --install "${cituspkgs}/${citusdownload}" | |
sudo ln -s "/opt/citusdb/${citusversion}" "/usr/lib/postgresql/${PGVERSION}" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by https://gist.github.com/petere/6023944 | |
set -eux | |
# always install postgresql-common | |
packages="postgresql-common libedit-dev libpam0g-dev" | |
# we set PGVERSION to 10x of the Citus version when testing Citus, so | |
# only install PostgreSQL proper if it's 9.5 or lower | |
if [ "${PGVERSION//./}" -le "95" ]; then | |
packages="$packages postgresql-$PGVERSION postgresql-server-dev-$PGVERSION" | |
fi | |
sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install $packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by https://gist.github.com/petere/6023944 | |
set -eux | |
# stop all existing instances (because of https://github.com/travis-ci/travis-cookbooks/pull/221) | |
sudo service postgresql stop | |
# and make sure they don't come back | |
echo 'exit 0' | sudo tee /etc/init.d/postgresql | |
sudo chmod a+x /etc/init.d/postgresql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by https://gist.github.com/petere/6023944 | |
set -eux | |
status=0 | |
# Run tests. DBs owned by non-standard owner put socket in /tmp | |
PGHOST=/tmp PGPORT=55435 make installcheck PGUSER=`whoami` PG_CONFIG=/usr/lib/postgresql/$PGVERSION/bin/pg_config || status=$? | |
# Print diff if it exists | |
if test -f regression.diffs; then cat regression.diffs; fi | |
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Inspired by https://gist.github.com/petere/6023944 | |
set -eux | |
# import the PostgreSQL repository key | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
# add the PostgreSQL 9.5 repository | |
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main 9.5" >> /etc/apt/sources.list.d/postgresql.list' | |
# update package index files from sources | |
sudo apt-get update -qq | |
# remove traces of PostgreSQL versions | |
# see: postgresql.org/message-id/[email protected] | |
sudo update-alternatives --remove-all postmaster.1.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment