#!/bin/sh # The hub's tests on PostgreSQL (oxygenhub#211, docs/postgres.md): a server # of the job's own on loopback, thrown away with the guest. The build image # has Debian's server and nss_wrapper, which gives the job's user (the # runner's builder, unknown to the image) the name initdb looks up. set -eu pg=/tmp/pg if ! getent passwd "$(id -u)" >/dev/null; then printf 'flow:x:%s:%s:flow:/tmp:/bin/sh\n' "$(id -u)" "$(id -g)" >/tmp/passwd printf 'flow:x:%s:\n' "$(id -g)" >/tmp/group wrapper=$(find /usr/lib -name libnss_wrapper.so | head -1) export LD_PRELOAD="$wrapper" NSS_WRAPPER_PASSWD=/tmp/passwd NSS_WRAPPER_GROUP=/tmp/group fi initdb -D "$pg" -U hub --auth=trust >/tmp/initdb.log || { cat /tmp/initdb.log >&2; exit 1; } # Thrown away with the guest: no need to survive a crash. pg_ctl -D "$pg" -l /tmp/postgres.log -w start \ -o "-c listen_addresses=127.0.0.1 -p 55432 -k /tmp -c fsync=off -c synchronous_commit=off -c full_page_writes=off" \ >/dev/null || { cat /tmp/postgres.log >&2; exit 1; } unset LD_PRELOAD NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP echo "flow: $(postgres --version) on 127.0.0.1:55432" export OXYHUB_DATABASE_URL=postgres://hub@127.0.0.1:55432/postgres OXYHUB_DATABASE_SCHEMA='*' exec sh .flow/warm-target.sh cargo test -p oxygenhub --features postgres --locked