Add support for BENCHMARTK_CONNSTR

This commit is contained in:
Alexey Masterov
2025-04-01 15:12:27 +02:00
parent 3f775d2df1
commit 4b4ce9e60a

29
docker-compose/run-tests.sh Normal file → Executable file
View File

@@ -1,12 +1,29 @@
#!/bin/bash
set -x
if [[ -v BENCHMARK_CONNSTR ]] && [[ ${BENCHMARK_CONNSTR} =~ ^postgres(ql)?:\/\/([^:]+):([^@]+)@([^:/]+):?([0-9]*)\/(.+)$ ]]; then
export PGUSER="${BASH_REMATCH[2]}"
export PGPASSWORD="${BASH_REMATCH[3]}"
export PGHOST="${BASH_REMATCH[4]}"
export PGPORT="${BASH_REMATCH[5]:-5432}"
export PGDATABASE="${BASH_REMATCH[6]}"
if [[ -v BENCHMARK_CONNSTR ]]; then
uri_no_proto="${BENCHMARK_CONNSTR#postgres://}"
uri_no_proto="${uri_no_proto#postgresql://}"
if [[ $uri_no_proto == *\?* ]]; then
base="${uri_no_proto%%\?*}" # before '?'
else
base="$uri_no_proto"
fi
if [[ $base =~ ^([^:]+):([^@]+)@([^:/]+):?([0-9]*)/(.+)$ ]]; then
export PGUSER="${BASH_REMATCH[1]}"
export PGPASSWORD="${BASH_REMATCH[2]}"
export PGHOST="${BASH_REMATCH[3]}"
export PGPORT="${BASH_REMATCH[4]:-5432}"
export PGDATABASE="${BASH_REMATCH[5]}"
echo export PGUSER="${BASH_REMATCH[1]}"
echo export PGPASSWORD="${BASH_REMATCH[2]}"
echo export PGHOST="${BASH_REMATCH[3]}"
echo export PGPORT="${BASH_REMATCH[4]:-5432}"
echo export PGDATABASE="${BASH_REMATCH[5]}"
else
echo "Invalid PostgreSQL base URI"
exit 1
fi
fi
extdir=${1}