OXYGENHUB
◆ v0.9.11 oxygenhub / .flow / test-postgres.sh
1.3 KiB · Bourne Again Shell (bash) · last changed Flow: the hub's tests on PostgreSQL too, in the new build image 19 days ago source blame history raw
1
#!/bin/sh
2
# The hub's tests on PostgreSQL (oxygenhub#211, docs/postgres.md): a server
3
# of the job's own on loopback, thrown away with the guest. The build image
4
# has Debian's server and nss_wrapper, which gives the job's user (the
5
# runner's builder, unknown to the image) the name initdb looks up.
6
set -eu
7
pg=/tmp/pg
8
if ! getent passwd "$(id -u)" >/dev/null; then
9
    printf 'flow:x:%s:%s:flow:/tmp:/bin/sh\n' "$(id -u)" "$(id -g)" >/tmp/passwd
10
    printf 'flow:x:%s:\n' "$(id -g)" >/tmp/group
11
    wrapper=$(find /usr/lib -name libnss_wrapper.so | head -1)
12
    export LD_PRELOAD="$wrapper" NSS_WRAPPER_PASSWD=/tmp/passwd NSS_WRAPPER_GROUP=/tmp/group
13
fi
14
initdb -D "$pg" -U hub --auth=trust >/tmp/initdb.log || { cat /tmp/initdb.log >&2; exit 1; }
15
# Thrown away with the guest: no need to survive a crash.
16
pg_ctl -D "$pg" -l /tmp/postgres.log -w start \
17
    -o "-c listen_addresses=127.0.0.1 -p 55432 -k /tmp -c fsync=off -c synchronous_commit=off -c full_page_writes=off" \
18
    >/dev/null || { cat /tmp/postgres.log >&2; exit 1; }
19
unset LD_PRELOAD NSS_WRAPPER_PASSWD NSS_WRAPPER_GROUP
20
echo "flow: $(postgres --version) on 127.0.0.1:55432"
21
export OXYHUB_DATABASE_URL=postgres://[email protected]:55432/postgres OXYHUB_DATABASE_SCHEMA='*'
22
exec sh .flow/warm-target.sh cargo test -p oxygenhub --features postgres --locked