debian/tests/unittest
author Philippe Pepiot <ph@itsalwaysdns.eu>
Mon, 30 Mar 2020 15:45:40 +0200
changeset 12962 fa0cd558d829
parent 12684 d464495452aa
permissions -rw-r--r--
[server] implement dynamic database pooler Opening too much database connection has a cost at startup and also PostgreSQL as a maximum number of connection (100 by default). This get worse when starting multiple wsgi processes, since each process has its own database pool. Instead of opening `connections-pool-size` connections to the database at startup, just open one and open more only when needed.

#!/bin/sh

set -e
set -x

### Setup tests

find cubicweb -type d -name 'test' -a '!' -wholename 'cubicweb/skeleton/*' | while read dir; do
	mkdir -p "$AUTOPKGTEST_TMP"/$(dirname "$dir")
	cp -r "$dir" "$AUTOPKGTEST_TMP/$dir"
	cp tox.ini "$AUTOPKGTEST_TMP"
done
chown -R nobody:nogroup "$AUTOPKGTEST_TMP"

### Find PostgreSQL binaries

POSTGRESQL_BINDIR=$(find /usr/lib/postgresql -type f -name 'initdb' -printf "%h\n" | head -n 1)
test "$POSTGRESQL_BINDIR" || { echo "Unable to find 'initdb'" >&2; exit 1; }

### Run tests

for py in $(py3versions -r 2>/dev/null); do
	cd "$AUTOPKGTEST_TMP"
	echo "Testing with $py:"
	su nobody --shell /bin/sh \
		-c "env PATH='$PATH:$POSTGRESQL_BINDIR' $py -m pytest -v"
done