patroni/debian/tests/acceptance

77 lines
2.3 KiB
Bash
Executable file

#!/bin/bash
set -eu
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export TZ=UTC # suppress UnknownTimeZoneError('Etc/UTC',)
DCS=$1
shift
if [ $(id -u) -eq 0 ]
then
# required so that the postgres user can create .coverage* and features/output/
chmod 777 .
chmod 777 features
SU='su postgres -p -c'
# zookeeper must be started manually (as root)
if [ "$DCS" = "zookeeper" ]; then
JAVA_OPTS="-Djava.net.preferIPv4Stack=true" /usr/bin/java -cp /etc/zookeeper/conf:/usr/share/java/jline.jar:/usr/share/java/log4j-1.2.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/xmlParserAPIs.jar:/usr/share/java/netty.jar:/usr/share/java/slf4j-api.jar:/usr/share/java/slf4j-log4j12.jar:/usr/share/java/zookeeper.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=true -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf/zoo.cfg &
# let Java have some more time to startup
sleep 5
fi
else
SU='bash -c'
fi
# clean up afterwards
trap 'rm -f /tmp/pgpass?; if [ $(id -u) -eq 0 ] && [ -x /etc/init.d/zookeeper ]; then /etc/init.d/zookeeper stop; fi' EXIT
# set ETCD_ARCH for ETCD_UNSUPPORTED_ARCH
# see https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/supported-platform.md#current-support
ETCD_ARCH=
DEB_HOST_ARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
case $DEB_HOST_ARCH in
arm64)
ETCD_ARCH=arm64
;;
armel|armhf)
ETCD_ARCH=arm
;;
i386)
ETCD_ARCH=386
;;
esac
# ensure no etcd server is running.
if [ $(id -u) -eq 0 ]
then
if [ "$DCS" = "etcd" -o "$DCS" = "etcd3" ]
then
service etcd stop
service etcd status || true
fi
fi
set -x
for PG_VERSION in $(ls -1r /usr/lib/postgresql/); do
echo "### PostgreSQL $PG_VERSION acceptance-$DCS $@ ###"
if [ "${PG_VERSION}" == "10" ]; then
SKIP=--tags=-skip
else
SKIP=
fi
if ! $SU "set -o pipefail; ETCD_UNSUPPORTED_ARCH=$ETCD_ARCH DCS=$DCS \
PATH=/usr/lib/postgresql/${PG_VERSION}/bin:$PATH \
behave ${SKIP} $@ | ts"; then
for file in features/output/*_failed/*; do
case $file in *.journal*) continue ;; esac # skip RAFT journal files
echo "$file:"
cat $file
done
exit 1
fi
echo "### End $PG_VERSION acceptance-$DCS $@ ###"
done