mirror of https://github.com/hashicorp/boundary
Mount the benchmark dump directory when running the test database and create a new script for creating templates from the dumps. This makes it easy to create pre-populated databases for benchmark tests. Fixes https://hashicorp.atlassian.net/browse/ICU-4040pull/2049/head
parent
9e424db0a3
commit
5d042c7ec7
@ -1,6 +1,7 @@
|
||||
FROM postgres:11-alpine
|
||||
|
||||
ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh
|
||||
ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh
|
||||
ADD postgresql.conf /etc/postgresql/postgresql.conf
|
||||
|
||||
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
FROM postgres:12-alpine
|
||||
|
||||
ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh
|
||||
ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh
|
||||
ADD postgresql.conf /etc/postgresql/postgresql.conf
|
||||
|
||||
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
FROM postgres:13-alpine
|
||||
|
||||
ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh
|
||||
ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh
|
||||
ADD postgresql.conf /etc/postgresql/postgresql.conf
|
||||
|
||||
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
FROM postgres:alpine
|
||||
|
||||
ADD init-db.sh /docker-entrypoint-initdb.d/00-init-db.sh
|
||||
ADD restore-benchmark-dumps.sh /docker-entrypoint-initdb.d/01-restore-benchmark-dumps.sh
|
||||
ADD postgresql.conf /etc/postgresql/postgresql.conf
|
||||
|
||||
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
shopt -s globstar
|
||||
|
||||
for file in $(ls -v /benchmark_dumps/*.dump); do
|
||||
echo "Creating template database based on: ${file}"
|
||||
db_name="boundary_$(basename ${file} .dump)_template"
|
||||
psql -v "ON_ERROR_STOP=1" --username "$POSTGRES_USER" --dbname "${POSTGRES_DB}" -q <<EOSQL
|
||||
create database ${db_name} owner ${POSTGRES_USER};
|
||||
EOSQL
|
||||
echo "Restoring ${file} into ${db_name}"
|
||||
pg_restore -j $(nproc) --username "${POSTGRES_USER}" --dbname ${db_name} "${file}"
|
||||
psql -v "ON_ERROR_STOP=1" --username "${POSTGRES_USER}" --dbname "${POSTGRES_DB}" -q <<EOSQL
|
||||
update pg_database set datistemplate = true, datallowconn = false where datname = '${db_name}';
|
||||
EOSQL
|
||||
done
|
||||
Loading…
Reference in new issue