[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] branch master updated (6f4969cbc -> 9efa30cdd)
From: |
gnunet |
Subject: |
[taler-exchange] branch master updated (6f4969cbc -> 9efa30cdd) |
Date: |
Thu, 12 Dec 2024 22:54:44 +0100 |
This is an automated email from the git hooks/post-receive script.
oec pushed a change to branch master
in repository exchange.
from 6f4969cbc new prebuilt
new 6fb685d27 [exchange] fix auditor tests in container
new 9efa30cdd [exchange] fix auditor tests in container (actual)
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
contrib/ci/Containerfile | 8 +-
.../build.sh => jobs/002-test/1-build.sh} | 10 +-
contrib/ci/jobs/002-test/2-install.sh | 4 +
contrib/ci/jobs/002-test/3-startdb.sh | 9 ++
contrib/ci/jobs/002-test/4-test.sh | 37 ++++++
contrib/ci/jobs/002-test/job.sh | 5 +-
contrib/ci/jobs/002-test/test.sh | 50 --------
src/auditor/generate-auditor-basedb.sh | 4 +-
src/auditor/test-auditor.sh | 142 ++++++++++++---------
src/auditor/test-kyc.sh | 111 ++++++++--------
src/auditor/test-revocation.sh | 100 ++++++++-------
src/auditor/test-sync.sh | 90 +++++++------
12 files changed, 312 insertions(+), 258 deletions(-)
copy contrib/ci/{disabled_jobs/130-build-debian-unstable-riscv64-gen/build.sh
=> jobs/002-test/1-build.sh} (67%)
create mode 100755 contrib/ci/jobs/002-test/2-install.sh
create mode 100755 contrib/ci/jobs/002-test/3-startdb.sh
create mode 100755 contrib/ci/jobs/002-test/4-test.sh
delete mode 100755 contrib/ci/jobs/002-test/test.sh
diff --git a/contrib/ci/Containerfile b/contrib/ci/Containerfile
index b00b59433..5fb900773 100644
--- a/contrib/ci/Containerfile
+++ b/contrib/ci/Containerfile
@@ -45,7 +45,8 @@ RUN apt-get update -yqq && \
jq \
postgresql \
sudo \
- wget
+ wget \
+ faketime
# Install Taler (and friends) packages
RUN curl -sS https://deb.taler.net/apt-nightly/taler-bookworm-ci.sources \
@@ -62,6 +63,11 @@ RUN cat /etc/apt/preferences.d/taler && \
libgnunet-dev \
libgnunet \
gnunet \
+ taler-wallet-cli \
+ taler-merchant \
+ libeufin-common \
+ libeufin-bank \
+ libeufin-nexus \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /workdir
diff --git
a/contrib/ci/disabled_jobs/130-build-debian-unstable-riscv64-gen/build.sh
b/contrib/ci/jobs/002-test/1-build.sh
similarity index 67%
copy from
contrib/ci/disabled_jobs/130-build-debian-unstable-riscv64-gen/build.sh
copy to contrib/ci/jobs/002-test/1-build.sh
index d3fcfab85..e8378dd43 100755
--- a/contrib/ci/disabled_jobs/130-build-debian-unstable-riscv64-gen/build.sh
+++ b/contrib/ci/jobs/002-test/1-build.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-set -exuo pipefail
+set -evux
apt-get update
apt-get upgrade -yqq
@@ -10,5 +10,11 @@ apt-get upgrade -yqq
--disable-doc
nump=$(grep processor /proc/cpuinfo | wc -l)
+make clean
make -j$(( $nump / 2 ))
-make
+cd src/templating/
+./run-original-tests.sh
+make clean
+cd -
+make -j$(( $nump / 2 ))
+
diff --git a/contrib/ci/jobs/002-test/2-install.sh
b/contrib/ci/jobs/002-test/2-install.sh
new file mode 100755
index 000000000..41bb3c019
--- /dev/null
+++ b/contrib/ci/jobs/002-test/2-install.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+set -evux
+
+make install
diff --git a/contrib/ci/jobs/002-test/3-startdb.sh
b/contrib/ci/jobs/002-test/3-startdb.sh
new file mode 100755
index 000000000..e1f6bce5f
--- /dev/null
+++ b/contrib/ci/jobs/002-test/3-startdb.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+set -evux
+
+export PGPORT=5432
+sudo -u postgres /usr/lib/postgresql/15/bin/pg_ctl \
+ start -D /etc/postgresql/15/main -o "-h localhost -p $PGPORT"
+sudo -u postgres createuser -p $PGPORT root -s -w
+sudo -u postgres createdb -p $PGPORT -O root talercheck
+
diff --git a/contrib/ci/jobs/002-test/4-test.sh
b/contrib/ci/jobs/002-test/4-test.sh
new file mode 100755
index 000000000..bfae0f953
--- /dev/null
+++ b/contrib/ci/jobs/002-test/4-test.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+set -evux
+
+check_command()
+{
+ # /usr/local is where the install step has put the libararies
+ export TALER_EXCHANGE_PREFIX=/usr/local
+ export TALER_AUDITOR_PREFIX=/usr/local
+
+ # bank and merchant are from the debian package, having /usr as
+ # their installation path's
+ export TALER_BANK_PREFIX=/usr
+ export TALER_MERCHANT_PREFIX=/usr
+ export
LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu/taler-merchant
+
+ make check
+}
+
+print_logs()
+{
+ set +e
+ for i in src/*/test-suite.log
+ do
+ echo "Printing ${i}"
+ cat "$i"
+ for FAILURE in $(grep '^FAIL:' ${i} | cut -d' ' -f2)
+ do
+ echo "Printing $(dirname $i)/${FAILURE}.log"
+ cat "$(dirname $i)/${FAILURE}.log"
+ done
+ done
+}
+
+if ! check_command ; then
+ print_logs
+ exit 1
+fi
diff --git a/contrib/ci/jobs/002-test/job.sh b/contrib/ci/jobs/002-test/job.sh
index bfb24e335..149ce1fab 100755
--- a/contrib/ci/jobs/002-test/job.sh
+++ b/contrib/ci/jobs/002-test/job.sh
@@ -3,4 +3,7 @@ set -exuo pipefail
job_dir=$(dirname "${BASH_SOURCE[0]}")
-"${job_dir}"/test.sh
+. "${job_dir}"/1-build.sh
+. "${job_dir}"/2-install.sh
+. "${job_dir}"/3-startdb.sh
+. "${job_dir}"/4-test.sh
diff --git a/contrib/ci/jobs/002-test/test.sh b/contrib/ci/jobs/002-test/test.sh
deleted file mode 100755
index 529c4f29f..000000000
--- a/contrib/ci/jobs/002-test/test.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-set -evux
-
-apt-get update
-apt-get upgrade -yqq
-
-./bootstrap
-./configure CFLAGS="-ggdb -O0" \
- --enable-logging=verbose \
- --disable-doc
-
-nump=$(grep processor /proc/cpuinfo | wc -l)
-make clean
-make -j$(( $nump / 2 ))
-cd src/templating/
-./run-original-tests.sh
-make clean
-cd -
-make -j$(( $nump / 2 ))
-make install
-
-sudo -u postgres /usr/lib/postgresql/15/bin/pg_ctl start -D
/etc/postgresql/15/main -o '-h localhost -p 5432'
-sudo -u postgres createuser -p 5432 root
-sudo -u postgres createdb -p 5432 -O root talercheck
-
-check_command()
-{
- # Set LD_LIBRARY_PATH so tests can find the installed libs
- LD_LIBRARY_PATH=/usr/local/lib PGPORT=5432 make check
-}
-
-print_logs()
-{
- set +e
- for i in src/*/test-suite.log
- do
- echo "Printing ${i}"
- cat "$i"
- for FAILURE in $(grep '^FAIL:' ${i} | cut -d' ' -f2)
- do
- echo "Printing $(dirname $i)/${FAILURE}.log"
- cat "$(dirname $i)/${FAILURE}.log"
- done
- done
-}
-
-if ! check_command ; then
- print_logs
- exit 1
-fi
diff --git a/src/auditor/generate-auditor-basedb.sh
b/src/auditor/generate-auditor-basedb.sh
index fdd2ab5b3..9a7a27e28 100755
--- a/src/auditor/generate-auditor-basedb.sh
+++ b/src/auditor/generate-auditor-basedb.sh
@@ -47,9 +47,9 @@ curl --help >/dev/null </dev/null || exit_skip " MISSING"
echo " FOUND"
# reset database
-echo -n "Reset 'auditor-basedb' database at $PGHOST ..."
+echo -n "Reset 'auditor-basedb' database at ${PGHOST:-} ..."
dropdb --if-exists "auditor-basedb" > /dev/null 2> /dev/null || true
-createdb "auditor-basedb" || exit_skip "Could not create database '$BASEDB' at
$PGHOST"
+createdb "auditor-basedb" || exit_skip "Could not create database '$BASEDB' at
${PGHOST:-}"
echo " DONE"
# Launch exchange, merchant and bank.
diff --git a/src/auditor/test-auditor.sh b/src/auditor/test-auditor.sh
index 4679a9791..c4c35052e 100755
--- a/src/auditor/test-auditor.sh
+++ b/src/auditor/test-auditor.sh
@@ -402,10 +402,10 @@ function stop_auditor_httpd() {
# Do a full reload of the (original) database
function full_reload()
{
- echo -n "Doing full reload of the database (loading ${BASEDB}.sql into $DB
at $PGHOST)... "
+ echo -n "Doing full reload of the database (loading ${BASEDB}.sql into $DB
at ${PGHOST:-})... "
dropdb -f "$DB" &>> ${MY_TMP_DIR}/drop.log || true
createdb -T template0 "$DB" \
- || exit_skip "could not create database $DB (at $PGHOST)"
+ || exit_skip "could not create database $DB (at ${PGHOST:-})"
# Import pre-generated database, -q(ietly) using single (-1) transaction
psql -Aqt "$DB" \
-q \
@@ -2162,7 +2162,78 @@ function check_with_database()
# dropdb $DB
}
+# When the script is not run as root, setup a temporary directory for the
+# postgres database.
+# Sets PGHOST accordingly to the freshly created socket.
+function perform_initdb() {
+ # Available directly in path?
+ INITDB_BIN=$(command -v initdb) || true
+ if [[ -n "$INITDB_BIN" ]]; then
+ echo " FOUND (in path) at $INITDB_BIN"
+ else
+ HAVE_INITDB=$(find /usr -name "initdb" 2> /dev/null \
+ | head -1 2> /dev/null \
+ | grep postgres) \
+ || exit_skip " MISSING"
+ echo " FOUND at $(dirname "$HAVE_INITDB")"
+ INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres |
sort -n | tail -n1)
+ fi
+ POSTGRES_PATH=$(dirname "$INITDB_BIN")
+
+ TMPDIR="$MY_TMP_DIR/postgres"
+ mkdir -p "$TMPDIR"
+ echo -n "Setting up Postgres DB at $TMPDIR ..."
+ $INITDB_BIN \
+ --no-sync \
+ --auth=trust \
+ -D "${TMPDIR}" \
+ > "${MY_TMP_DIR}/postgres-dbinit.log" \
+ 2> "${MY_TMP_DIR}/postgres-dbinit.err" \
+ || {
+ echo "FAILED!"
+ echo "Last entries in ${MY_TMP_DIR}/postgres-dbinit.err:"
+ tail "${MY_TMP_DIR}/postgres-dbinit.err"
+ exit 1
+ }
+ echo "DONE"
+
+ # Once we move to PG16, we can use:
+ # --set listen_addresses='' \
+ # --set fsync=off \
+ # --set max_wal_senders=0 \
+ # --set synchronous_commit=off \
+ # --set wal_level=minimal \
+ # --set unix_socket_directories="${TMPDIR}/sockets" \
+
+
+ SOCKETDIR="${TMPDIR}/sockets"
+ mkdir "${SOCKETDIR}"
+
+ echo -n "Launching Postgres service"
+
+ cat - >> "$TMPDIR/postgresql.conf" <<EOF
+unix_socket_directories='${TMPDIR}/sockets'
+fsync=off
+max_wal_senders=0
+synchronous_commit=off
+wal_level=minimal
+listen_addresses=''
+EOF
+ grep -v host \
+ < "$TMPDIR/pg_hba.conf" \
+ > "$TMPDIR/pg_hba.conf.new"
+ mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
+ "${POSTGRES_PATH}/pg_ctl" \
+ -D "$TMPDIR" \
+ -l "${MY_TMP_DIR}/postgres.log" \
+ start \
+ > "${MY_TMP_DIR}/postgres-start.log" \
+ 2> "${MY_TMP_DIR}/postgres-start.err"
+ echo " DONE"
+ PGHOST="$TMPDIR/sockets"
+ export PGHOST
+}
# *************** Main logic starts here **************
@@ -2184,69 +2255,14 @@ taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null
|| exit_skip "taler-wallet
echo -n "Testing for Postgres"
-# Available directly in path?
-INITDB_BIN=$(command -v initdb) || true
-if [[ -n "$INITDB_BIN" ]]; then
- echo " FOUND (in path) at $INITDB_BIN"
-else
- HAVE_INITDB=$(find /usr -name "initdb" 2> /dev/null \
- | head -1 2> /dev/null \
- | grep postgres) \
- || exit_skip " MISSING"
- echo " FOUND at $(dirname "$HAVE_INITDB")"
- INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres | sort -n
| tail -n1)
-fi
-POSTGRES_PATH=$(dirname "$INITDB_BIN")
MY_TMP_DIR=$(mktemp -d /tmp/taler-auditor-basedbXXXXXX)
echo "Using $MY_TMP_DIR for logging and temporary data"
-TMPDIR="$MY_TMP_DIR/postgres"
-mkdir -p "$TMPDIR"
-echo -n "Setting up Postgres DB at $TMPDIR ..."
-$INITDB_BIN \
- --no-sync \
- --auth=trust \
- -D "${TMPDIR}" \
- > "${MY_TMP_DIR}/postgres-dbinit.log" \
- 2> "${MY_TMP_DIR}/postgres-dbinit.err"
-echo "DONE"
-
-# Once we move to PG16, we can use:
-# --set listen_addresses='' \
-# --set fsync=off \
-# --set max_wal_senders=0 \
-# --set synchronous_commit=off \
-# --set wal_level=minimal \
-# --set unix_socket_directories="${TMPDIR}/sockets" \
-
-
-SOCKETDIR="${TMPDIR}/sockets"
-mkdir "${SOCKETDIR}"
-
-echo -n "Launching Postgres service"
-
-cat - >> "$TMPDIR/postgresql.conf" <<EOF
-unix_socket_directories='${TMPDIR}/sockets'
-fsync=off
-max_wal_senders=0
-synchronous_commit=off
-wal_level=minimal
-listen_addresses=''
-EOF
-grep -v host \
- < "$TMPDIR/pg_hba.conf" \
- > "$TMPDIR/pg_hba.conf.new"
-mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
-"${POSTGRES_PATH}/pg_ctl" \
- -D "$TMPDIR" \
- -l "${MY_TMP_DIR}/postgres.log" \
- start \
- > "${MY_TMP_DIR}/postgres-start.log" \
- 2> "${MY_TMP_DIR}/postgres-start.err"
-echo " DONE"
-PGHOST="$TMPDIR/sockets"
-export PGHOST
+# If run as root, simply use the running postgres instance.
+# Otherwise create a temporary storage space for postgres.
+[ $(id -u) == 0 ] || perform_initdb
+
MYDIR="${MY_TMP_DIR}/basedb"
mkdir -p "${MYDIR}"
@@ -2256,9 +2272,9 @@ then
if faketime -f '-1 d' ./generate-auditor-basedb.sh -d "$MYDIR/$DB"
then
- echo -n "Reset 'auditor-basedb' database at $PGHOST ..."
+ echo -n "Reset 'auditor-basedb' database at ${PGHOST:-} ..."
dropdb --if-exists "auditor-basedb" > /dev/null 2> /dev/null || true
- createdb "auditor-basedb" || exit_skip "Could not create database
'$BASEDB' at $PGHOST"
+ createdb "auditor-basedb" || exit_skip "Could not create database
'$BASEDB' at ${PGHOST:-}"
echo " DONE"
else
echo "Generation failed"
diff --git a/src/auditor/test-kyc.sh b/src/auditor/test-kyc.sh
index 8efdc45b5..2a4c49986 100755
--- a/src/auditor/test-kyc.sh
+++ b/src/auditor/test-kyc.sh
@@ -355,10 +355,10 @@ function run_audit () {
# Do a full reload of the (original) database
function full_reload()
{
- echo -n "Doing full reload of the database (loading ${BASEDB}.sql into $DB
at $PGHOST)... "
+ echo -n "Doing full reload of the database (loading ${BASEDB}.sql into $DB
at ${PGHOST:-})... "
dropdb "$DB" 2> /dev/null || true
createdb -T template0 "$DB" \
- || exit_skip "could not create database $DB (at $PGHOST)"
+ || exit_skip "could not create database $DB (at ${PGHOST:-})"
# Import pre-generated database, -q(ietly) using single (-1) transaction
psql -Aqt "$DB" \
-q \
@@ -635,6 +635,59 @@ function check_with_database()
# dropdb $DB
}
+# If this script is not run as root, create the temporary
+# storage space for postgres.
+# Sets PGHOST accordingly
+function perform_initdb() {
+ # Available directly in path?
+ INITDB_BIN=$(command -v initdb) || true
+ if [[ -n "$INITDB_BIN" ]]; then
+ echo " FOUND (in path) at $INITDB_BIN"
+ else
+ HAVE_INITDB=$(find /usr -name "initdb" | head -1 2> /dev/null | grep
postgres) \
+ || exit_skip " MISSING"
+ echo " FOUND at $(dirname "$HAVE_INITDB")"
+ INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres |
sort -n | tail -n1)
+ fi
+ POSTGRES_PATH=$(dirname "$INITDB_BIN")
+
+ echo "Using $MY_TMP_DIR for logging and temporary data"
+ TMPDIR="$MY_TMP_DIR/postgres"
+ mkdir -p "$TMPDIR"
+ echo -n "Setting up Postgres DB at $TMPDIR ..."
+ $INITDB_BIN \
+ --no-sync \
+ --auth=trust \
+ -D "${TMPDIR}" \
+ > "${MY_TMP_DIR}/postgres-dbinit.log" \
+ 2> "${MY_TMP_DIR}/postgres-dbinit.err"
+ echo "DONE"
+ SOCKETDIR="${TMPDIR}/sockets"
+ mkdir "${SOCKETDIR}"
+ echo -n "Launching Postgres service"
+ cat - >> "$TMPDIR/postgresql.conf" <<EOF
+unix_socket_directories='${TMPDIR}/sockets'
+fsync=off
+max_wal_senders=0
+synchronous_commit=off
+wal_level=minimal
+listen_addresses=''
+EOF
+ grep -v host \
+ < "$TMPDIR/pg_hba.conf" \
+ > "$TMPDIR/pg_hba.conf.new"
+ mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
+ "${POSTGRES_PATH}/pg_ctl" \
+ -D "$TMPDIR" \
+ -l /dev/null \
+ start \
+ > "${MY_TMP_DIR}/postgres-start.log" \
+ 2> "${MY_TMP_DIR}/postgres-start.err"
+ echo " DONE"
+ PGHOST="$TMPDIR/sockets"
+ export PGHOST
+
+}
@@ -655,56 +708,10 @@ libeufin-bank --help >/dev/null 2> /dev/null </dev/null
|| exit_skip "libeufin-b
echo "Testing for taler-wallet-cli"
taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null || exit_skip
"taler-wallet-cli required"
+MY_TMP_DIR=$(mktemp -d /tmp/taler-auditor-basedbXXXXXX)
echo -n "Testing for Postgres"
-# Available directly in path?
-INITDB_BIN=$(command -v initdb) || true
-if [[ -n "$INITDB_BIN" ]]; then
- echo " FOUND (in path) at $INITDB_BIN"
-else
- HAVE_INITDB=$(find /usr -name "initdb" | head -1 2> /dev/null | grep
postgres) \
- || exit_skip " MISSING"
- echo " FOUND at $(dirname "$HAVE_INITDB")"
- INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres | sort -n
| tail -n1)
-fi
-POSTGRES_PATH=$(dirname "$INITDB_BIN")
-
-MY_TMP_DIR=$(mktemp -d /tmp/taler-auditor-basedbXXXXXX)
-echo "Using $MY_TMP_DIR for logging and temporary data"
-TMPDIR="$MY_TMP_DIR/postgres"
-mkdir -p "$TMPDIR"
-echo -n "Setting up Postgres DB at $TMPDIR ..."
-$INITDB_BIN \
- --no-sync \
- --auth=trust \
- -D "${TMPDIR}" \
- > "${MY_TMP_DIR}/postgres-dbinit.log" \
- 2> "${MY_TMP_DIR}/postgres-dbinit.err"
-echo "DONE"
-SOCKETDIR="${TMPDIR}/sockets"
-mkdir "${SOCKETDIR}"
-echo -n "Launching Postgres service"
-cat - >> "$TMPDIR/postgresql.conf" <<EOF
-unix_socket_directories='${TMPDIR}/sockets'
-fsync=off
-max_wal_senders=0
-synchronous_commit=off
-wal_level=minimal
-listen_addresses=''
-EOF
-grep -v host \
- < "$TMPDIR/pg_hba.conf" \
- > "$TMPDIR/pg_hba.conf.new"
-mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
-"${POSTGRES_PATH}/pg_ctl" \
- -D "$TMPDIR" \
- -l /dev/null \
- start \
- > "${MY_TMP_DIR}/postgres-start.log" \
- 2> "${MY_TMP_DIR}/postgres-start.err"
-echo " DONE"
-PGHOST="$TMPDIR/sockets"
-export PGHOST
+[ $(id -u) == 0 ] || perform_initdb
MYDIR="${MY_TMP_DIR}/basedb"
mkdir -p "${MYDIR}"
@@ -713,9 +720,9 @@ if faketime -f '-1 d' ./generate-auditor-basedb.sh \
-c generate-kyc-basedb.conf \
-d "$MYDIR/$DB"
then
- echo -n "Reset 'auditor-basedb' database at $PGHOST ..."
+ echo -n "Reset 'auditor-basedb' database at ${PGHOST:-} ..."
dropdb "auditor-basedb" >/dev/null 2>/dev/null || true
- createdb "auditor-basedb" || exit_skip "Could not create database
'$BASEDB' at $PGHOST"
+ createdb "auditor-basedb" || exit_skip "Could not create database
'$BASEDB' at ${PGHOST:-}"
echo " DONE"
check_with_database "$MYDIR/$DB"
if [ "$fail" != "0" ]
diff --git a/src/auditor/test-revocation.sh b/src/auditor/test-revocation.sh
index 310a4e14e..5d5ea7db5 100755
--- a/src/auditor/test-revocation.sh
+++ b/src/auditor/test-revocation.sh
@@ -271,7 +271,7 @@ function full_reload()
echo -n "Doing full reload of the database... "
dropdb "$DB" 2> /dev/null || true
createdb -T template0 "$DB" \
- || exit_skip "could not create database $DB (at $PGHOST)"
+ || exit_skip "could not create database $DB (at ${PGHOST:-})"
# Import pre-generated database, -q(ietly) using single (-1) transaction
psql -Aqt "$DB" \
-q \
@@ -638,6 +638,55 @@ function check_with_database()
dropdb "$DB"
}
+# If this script is not running as root, create
+# the temporary directory structure for storage for postgres
+# Will set PGHOST accordingly
+function perform_dbinit() {
+ # Available directly in path?
+ INITDB_BIN=$(command -v initdb) || true
+ if [[ -n "$INITDB_BIN" ]]; then
+ echo "FOUND (in path) at $INITDB_BIN"
+ else
+ HAVE_INITDB=$(find /usr -name "initdb" | head -1 2> /dev/null | grep
postgres) || exit_skip " MISSING"
+ echo "FOUND at " "$(dirname "$HAVE_INITDB")"
+ INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres |
sort -n | tail -n1)
+ fi
+ echo -n "Setting up Postgres DB"
+ POSTGRES_PATH=$(dirname "$INITDB_BIN")
+ TMPDIR="${MY_TMP_DIR}/postgres/"
+ mkdir -p "$TMPDIR"
+ echo -n "Setting up Postgres DB at $TMPDIR ..."
+ "$INITDB_BIN" \
+ --no-sync \
+ --auth=trust \
+ -D "${TMPDIR}" \
+ > "${MY_TMP_DIR}/postgres-dbinit.log" \
+ 2> "${MY_TMP_DIR}/postgres-dbinit.err"
+ echo " DONE"
+ mkdir "${TMPDIR}/sockets"
+ echo -n "Launching Postgres service at $POSTGRES_PATH"
+ cat - >> "$TMPDIR/postgresql.conf" <<EOF
+unix_socket_directories='${TMPDIR}/sockets'
+fsync=off
+max_wal_senders=0
+synchronous_commit=off
+wal_level=minimal
+listen_addresses=''
+EOF
+ grep -v host \
+ < "$TMPDIR/pg_hba.conf" \
+ > "$TMPDIR/pg_hba.conf.new"
+ mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
+ "${POSTGRES_PATH}/pg_ctl" \
+ -D "$TMPDIR" \
+ -l /dev/null \
+ start \
+ > "${MY_TMP_DIR}/postgres-start.log" \
+ 2> "${MY_TMP_DIR}/postgres-start.err"
+ echo " DONE"
+ PGHOST="$TMPDIR/sockets"
+ export PGHOST
+}
# *************** Main logic starts here **************
@@ -666,52 +715,11 @@ taler-wallet-cli -h \
2>/dev/null \
|| exit_skip "taler-wallet-cli required"
-echo -n "Testing for Postgres "
-# Available directly in path?
-INITDB_BIN=$(command -v initdb) || true
-if [[ -n "$INITDB_BIN" ]]; then
- echo "FOUND (in path) at $INITDB_BIN"
-else
- HAVE_INITDB=$(find /usr -name "initdb" | head -1 2> /dev/null | grep
postgres) || exit_skip " MISSING"
- echo "FOUND at " "$(dirname "$HAVE_INITDB")"
- INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres | sort -n
| tail -n1)
-fi
-echo -n "Setting up Postgres DB"
-POSTGRES_PATH=$(dirname "$INITDB_BIN")
MY_TMP_DIR=$(mktemp -d /tmp/taler-auditor-basedbXXXXXX)
-TMPDIR="${MY_TMP_DIR}/postgres/"
-mkdir -p "$TMPDIR"
-echo -n "Setting up Postgres DB at $TMPDIR ..."
-"$INITDB_BIN" \
- --no-sync \
- --auth=trust \
- -D "${TMPDIR}" \
- > "${MY_TMP_DIR}/postgres-dbinit.log" \
- 2> "${MY_TMP_DIR}/postgres-dbinit.err"
-echo " DONE"
-mkdir "${TMPDIR}/sockets"
-echo -n "Launching Postgres service at $POSTGRES_PATH"
-cat - >> "$TMPDIR/postgresql.conf" <<EOF
-unix_socket_directories='${TMPDIR}/sockets'
-fsync=off
-max_wal_senders=0
-synchronous_commit=off
-wal_level=minimal
-listen_addresses=''
-EOF
-grep -v host \
- < "$TMPDIR/pg_hba.conf" \
- > "$TMPDIR/pg_hba.conf.new"
-mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
-"${POSTGRES_PATH}/pg_ctl" \
- -D "$TMPDIR" \
- -l /dev/null \
- start \
- > "${MY_TMP_DIR}/postgres-start.log" \
- 2> "${MY_TMP_DIR}/postgres-start.err"
-echo " DONE"
-PGHOST="$TMPDIR/sockets"
-export PGHOST
+
+echo -n "Testing for Postgres "
+[ $(id -u) == 0 ] || perform_dbinit
+
echo "Generating fresh database at $MY_TMP_DIR"
if faketime -f '-1 d' ./generate-revoke-basedb.sh "$MY_TMP_DIR/$DB"
diff --git a/src/auditor/test-sync.sh b/src/auditor/test-sync.sh
index 60ea392eb..ed34d8651 100755
--- a/src/auditor/test-sync.sh
+++ b/src/auditor/test-sync.sh
@@ -46,6 +46,52 @@ function cleanup() {
# Install cleanup handler (except for kill -9)
trap cleanup EXIT
+# If this script is not run as root,
+# create the temporary storage space for postgres.
+# Will set PGHOST accordingly
+function perform_initdb() {
+ # Available directly in path?
+ INITDB_BIN=$(command -v initdb) || true
+ if [[ -n "$INITDB_BIN" ]]; then
+ echo " FOUND (in path) at $INITDB_BIN"
+ else
+ HAVE_INITDB=$(find /usr -name "initdb" | head -1 2> /dev/null | grep
postgres) || exit_skip " MISSING"
+ echo " FOUND at " "$(dirname "$HAVE_INITDB")"
+ INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres |
sort -n | tail -n1)
+ fi
+ echo -n "Setting up Postgres DB"
+ POSTGRES_PATH=$(dirname "$INITDB_BIN")
+ TMPDIR="$MYDIR/postgres/"
+ mkdir -p "$TMPDIR"
+ "$INITDB_BIN" --no-sync --auth=trust -D "${TMPDIR}" \
+ > "${MYDIR}/postgres-dbinit.log" \
+ 2> "${MYDIR}/postgres-dbinit.err"
+ echo " DONE"
+ mkdir "${TMPDIR}/sockets"
+ echo -n "Launching Postgres service"
+ cat - >> "$TMPDIR/postgresql.conf" <<EOF
+unix_socket_directories='${TMPDIR}/sockets'
+fsync=off
+max_wal_senders=0
+synchronous_commit=off
+wal_level=minimal
+listen_addresses=''
+EOF
+ grep -v host \
+ < "$TMPDIR/pg_hba.conf" \
+ > "$TMPDIR/pg_hba.conf.new"
+ mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
+ "${POSTGRES_PATH}/pg_ctl" \
+ -D "$TMPDIR" \
+ -l /dev/null \
+ start \
+ > "${MYDIR}/postgres-start.log" \
+ 2> "${MYDIR}/postgres-start.err"
+ echo " DONE"
+ PGHOST="$TMPDIR/sockets"
+ export PGHOST
+}
+
function check_with_database()
{
echo -n "Testing synchronization logic ..."
@@ -104,48 +150,10 @@ libeufin-bank --help >/dev/null </dev/null 2> /dev/null
|| exit_skip "libeufin-b
echo "Testing for taler-wallet-cli"
taler-wallet-cli -h >/dev/null </dev/null 2>/dev/null || exit_skip
"taler-wallet-cli required"
-echo -n "Testing for Postgres"
-# Available directly in path?
-INITDB_BIN=$(command -v initdb) || true
-if [[ -n "$INITDB_BIN" ]]; then
- echo " FOUND (in path) at $INITDB_BIN"
-else
- HAVE_INITDB=$(find /usr -name "initdb" | head -1 2> /dev/null | grep
postgres) || exit_skip " MISSING"
- echo " FOUND at " "$(dirname "$HAVE_INITDB")"
- INITDB_BIN=$(echo "$HAVE_INITDB" | grep bin/initdb | grep postgres | sort -n
| tail -n1)
-fi
-echo -n "Setting up Postgres DB"
-POSTGRES_PATH=$(dirname "$INITDB_BIN")
MYDIR=$(mktemp -d /tmp/taler-auditor-basedbXXXXXX)
-TMPDIR="$MYDIR/postgres/"
-mkdir -p "$TMPDIR"
-"$INITDB_BIN" --no-sync --auth=trust -D "${TMPDIR}" \
- > "${MYDIR}/postgres-dbinit.log" \
- 2> "${MYDIR}/postgres-dbinit.err"
-echo " DONE"
-mkdir "${TMPDIR}/sockets"
-echo -n "Launching Postgres service"
-cat - >> "$TMPDIR/postgresql.conf" <<EOF
-unix_socket_directories='${TMPDIR}/sockets'
-fsync=off
-max_wal_senders=0
-synchronous_commit=off
-wal_level=minimal
-listen_addresses=''
-EOF
-grep -v host \
- < "$TMPDIR/pg_hba.conf" \
- > "$TMPDIR/pg_hba.conf.new"
-mv "$TMPDIR/pg_hba.conf.new" "$TMPDIR/pg_hba.conf"
-"${POSTGRES_PATH}/pg_ctl" \
- -D "$TMPDIR" \
- -l /dev/null \
- start \
- > "${MYDIR}/postgres-start.log" \
- 2> "${MYDIR}/postgres-start.err"
-echo " DONE"
-PGHOST="$TMPDIR/sockets"
-export PGHOST
+
+echo -n "Testing for Postgres"
+[ $(id -u == 0) ] || perform_initdb
echo "Generating fresh database at $MYDIR"
if faketime -f '-1 d' ./generate-auditor-basedb.sh -d "$MYDIR/auditor-basedb"
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] branch master updated (6f4969cbc -> 9efa30cdd),
gnunet <=