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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#!/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_postgres-?; 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|s390x)
ETCD_ARCH=$DEB_HOST_ARCH
;;
armel|armhf)
ETCD_ARCH=arm
;;
i386)
ETCD_ARCH=386
;;
esac
if [ $(id -u) -eq 0 ]
then
# ensure no etcd server is running.
if [ "$DCS" = "etcd" -o "$DCS" = "etcd3" ]
then
if [ -x /etc/init.d/etcd ]
then
service etcd stop
service etcd status || true
else
if [ -d /run/systemd/system ]
then
systemctl stop etcd
fi
fi
fi
# make sure various directories are writable by the postgres user
for dir in features/output data /tmp/pgpass_postgres-?; do
if [ -d $dir ]
then
if [ "$(stat -c "%U" $dir)" != "postgres" ]
then
echo "removing directory $dir not belonging to postgres"
rm -rf $dir
fi
fi
done
fi
set -x
for PG_VERSION in $(ls -1r /usr/lib/postgresql/); do
if [ "${PG_VERSION}" == "10" -o "${PG_VERSION}" == "11" ]; then
echo "PostgreSQL ${PG_VERSION} skipped"
continue
fi
echo "### PostgreSQL $PG_VERSION acceptance-$DCS $@ ###"
if ! $SU "set -o pipefail; ETCD_UNSUPPORTED_ARCH=$ETCD_ARCH DCS=$DCS \
PATH=/usr/lib/postgresql/${PG_VERSION}/bin:$PATH \
behave $@ | 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
else
$SU "rm -rf features/output"
fi
echo "### End $PG_VERSION acceptance-$DCS $@ ###"
done
|