File: setup-pgsql.sh

package info (click to toggle)
ruby-moneta 1.6.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,776 kB
  • sloc: ruby: 13,201; sh: 178; makefile: 7
file content (44 lines) | stat: -rwxr-xr-x 1,096 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
#
# Copyright (C) 2014 Thomas Goirand <zigo@debian.org>
#
# Runs pgsql server, then use that to run tests.
#

set -eu
set -x

PG_MYTMPDIR=${1}
PGSQL_PORT=${2}
BINDIR=`pg_config --bindir`

# depends on language-pack-en | language-pack-en
# because initdb acquires encoding from locale
export LC_ALL="C"
export LANGUAGE=C
${BINDIR}/initdb -D ${PG_MYTMPDIR}

${BINDIR}/pg_ctl -w -D ${PG_MYTMPDIR} -o "-k ${PG_MYTMPDIR} -p ${PGSQL_PORT} -c max_connections=500" start > /dev/null
attempts=0
while ! [ -e ${PG_MYTMPDIR}/postmaster.pid ] ; do
	attempts=$((attempts+1))
	if [ "${attempts}" -gt 10 ] ; then
		echo "Exiting test: postgres pid file was not created after 30 seconds"
		exit 1
	fi
	sleep 3
	echo `date`: retrying..
done

# Set the env. var so that pgsql client doesn't use networking
# libpq uses this for all host params if not explicitly passed
export PGHOST=${PG_MYTMPDIR}
export PGPORT=${PGSQL_PORT}

# Create a new test db
createuser --superuser moneta
createdb -O moneta moneta1
createdb -O moneta moneta2

# Create hstore extension
psql -c 'create extension hstore;' moneta1