-View ouput of check-compatibility.sh
+View ouput of check_compatibility.sh
+Examining postgres:15
+######################
+Available PostGIS versions : 3
+Running on Debian GNU/Linux 11 (bullseye)
+
Examining postgres:14
######################
Available PostGIS versions : 3
@@ -99,21 +104,40 @@ Running on Debian GNU/Linux 11 (bullseye)
Examining postgres:11
######################
+applying apt-archive.postgres.org patch
Available PostGIS versions : 2.5 3
Running on Debian GNU/Linux 9 (stretch)
+Examining postgres:11-bullseye
+######################
+Available PostGIS versions : 3
+Running on Debian GNU/Linux 11 (bullseye)
+
Examining postgres:10
######################
+applying apt-archive.postgres.org patch
Available PostGIS versions : 2.4 2.5 3
Running on Debian GNU/Linux 9 (stretch)
+Examining postgres:10-bullseye
+######################
+Available PostGIS versions : 3
+Running on Debian GNU/Linux 11 (bullseye)
+
Examining postgres:9.6
######################
+applying apt-archive.postgres.org patch
Available PostGIS versions : 2.3 2.4 2.5 3
Running on Debian GNU/Linux 9 (stretch)
+Examining postgres:9.6-bullseye
+######################
+Available PostGIS versions : 3
+Running on Debian GNU/Linux 11 (bullseye)
+
Examining postgres:9.5
######################
+applying apt-archive.postgres.org patch
Available PostGIS versions : 2.3 2.4 2.5 3
Running on Debian GNU/Linux 9 (stretch)
@@ -174,9 +198,9 @@ checkpoint_completion_target = 0.9
### Using PGTuned images directly from Docker hub
-This project builds a small number of versions of the PGTuned image and deploy them to [Docker Hub](https://hub.docker.com/r/esgn/pgtuned) using the following tags :
-* `latest` corresponds to PostgreSQL 14
-* `postgis-latest` corresponds to PostgreSQL 14 and PostGIS 3
+This project builds a number of versions of the PGTuned image and deploy them to [Docker Hub](https://hub.docker.com/r/esgn/pgtuned) using the following tags :
+* `latest` corresponds to PostgreSQL 15
+* `postgis-latest` corresponds to PostgreSQL 15 and PostGIS 3
* `POSTGRES_VERSION` corresponds to a specific PostgreSQL image version (e.g. 12) without PostGIS
* `POSTGRES_VERSION-POSTGIS_VERSION` corresponds to a specific PostgreSQL image version including a specific PostGIS version (e.g. 12-3)
diff --git a/apt_archive_patch.sh b/apt_archive_patch.sh
new file mode 100644
index 0000000..1722042
--- /dev/null
+++ b/apt_archive_patch.sh
@@ -0,0 +1,17 @@
+#!/usr/bin/env bash
+
+# This script updates the pgdg.list source file present in Debian stretch images
+# in order to use apt-archive.postgres.org. This is necessary to apt update as stretch
+# has been cycled out and to get access to older versions of PostGIS
+
+codename=$(source /etc/os-release && echo -n $VERSION_CODENAME)
+
+if [ "$codename" = "stretch" ]
+then
+ cd /etc/apt/sources.list.d/
+ mv pgdg.list pgdg.list.backup
+ apt-get -qq update
+ apt-get install apt-transport-https -y
+ sed -i "s/http\:\/\/apt\.postgres/https\:\/\/apt-archive\.postgres/" pgdg.list.backup
+ mv pgdg.list.backup pgdg.list
+fi
diff --git a/check-compatibility.sh b/check-compatibility.sh
deleted file mode 100644
index fc6b972..0000000
--- a/check-compatibility.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env bash
-
-# This script runs official PostgreSQL Docker images
-# and gets the available PostGIS version for each of them.
-# Also ouputs the distribution used for each image.
-
-pg_versions="14 13 12 11 10 9.6 9.5"
-
-for v in $pg_versions
-do
- echo "Examining postgres:$v"
- echo "######################"
- docker run -d -e POSTGRES_PASSWORD=secret --name pg$v postgres:$v >/dev/null 2>&1
- c="apt update >/dev/null 2>&1 && apt-cache search $v-postgis | grep -Po '(?<=postgresql-$v-postgis-)([0-9\.]*)' | uniq | xargs "
- versions=$(docker exec -ti pg$v bash -c "$c")
- distrib=$(docker exec -ti pg$v bash -c 'cat /etc/os-release' | grep -Po '(?<=PRETTY_NAME=")(.*)(?=")')
- echo "Available PostGIS versions : "$versions
- echo "Running on "$distrib
- docker rm -f pg$v >/dev/null 2>&1
- echo
-done
diff --git a/pgtune.sh b/pgtune.sh
index 89bc5bc..2c767ee 100644
--- a/pgtune.sh
+++ b/pgtune.sh
@@ -13,8 +13,8 @@ It produces a postgresql.conf file based on supplied parameters.
-h display this help and exit
-v PG_VERSION (optional) PostgreSQL version
- accepted values: 9.5, 9.6, 10, 11, 12, 13, 14
- default value: 14
+ accepted values: 9.5, 9.6, 10, 11, 12, 13, 14, 15
+ default value: 15
-t DB_TYPE (optional) For what type of application is PostgreSQL used
accepted values: web, oltp, dw, desktop, mixed
default value: web
@@ -51,7 +51,7 @@ _error() {
get_total_ram () {
local total_ram=$(cat /proc/meminfo | grep -i 'memtotal' | grep -o '[[:digit:]]*')
- if [[ ! $total_ram ]]
+ if [[ -z $total_ram ]] || [[ "$total_ram" -eq "0" ]]
then
_error "cannot detect total memory size, terminating script. Please supply -m TOTAL_MEM."
fi
@@ -60,15 +60,18 @@ get_total_ram () {
get_cpu_count () {
local cpu_count=$(nproc --all)
- if [[ ! $cpu_count ]]
+ if [[ -z $cpu_count ]] || [[ "$cpu_count" -eq "0" ]]
then
_error "cannot detect cpu count, terminating script. Please supply -u CPU_COUNT."
fi
echo $cpu_count
}
-get_disk_type () {
- local disk_type_clue=$(cat /sys/block/sda/queue/rotational 2>/dev/null)
+get_disk_type () {
+ # PGDATA should always be defined in base postgres image
+ # findmnt should also be installed by default
+ local disk_name=$(basename $(findmnt -v -n -o SOURCE --target $PGDATA 2>/dev/null) 2>/dev/null)
+ local disk_type_clue=$(cat /sys/block/$disk_name/queue/rotational 2>/dev/null)
case "$disk_type_clue" in
"0")
disk_type="ssd"
@@ -93,7 +96,7 @@ set_db_default_values() {
max_worker_processes=8
max_parallel_workers_per_gather=0
;;
- "10" | "11" | "12" | "13" | "14")
+ "10" | "11" | "12" | "13" | "14" | "15")
max_worker_processes=8
max_parallel_workers_per_gather=2
max_parallel_workers=8
@@ -413,7 +416,7 @@ cpu_num=$(get_cpu_count) || exit $?
storage_type=$(get_disk_type)
conn_nb=0
db_type="web"
-db_version=14
+db_version=15
while getopts "hv:t:m:u:c:s:" opt; do
case $opt in
@@ -429,7 +432,8 @@ while getopts "hv:t:m:u:c:s:" opt; do
[ $v != "11" ] && \
[ $v != "12" ] && \
[ $v != "13" ] && \
- [ $v != "14" ]
+ [ $v != "14" ] && \
+ [ $v != "15" ]
then
_input_error "$v is not a valid PostgreSQL version number"
fi
@@ -568,6 +572,5 @@ if [ ! -z ${checkpoint_segments+x}]
then
echo "checkpoint_segments = "$checkpoint_segments
fi
-echo
unset set_parallel_settings
diff --git a/test_files/10_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/10_linux_web_8GB_8_1000_hdd.txt
similarity index 100%
rename from test_files/10_linux_web_8GB_8_1000_hdd.txt
rename to test/expected_results/10_linux_web_8GB_8_1000_hdd.txt
index 47f5b36..92e38d6 100644
--- a/test_files/10_linux_web_8GB_8_1000_hdd.txt
+++ b/test/expected_results/10_linux_web_8GB_8_1000_hdd.txt
@@ -19,5 +19,5 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
+max_parallel_workers_per_gather = 4
diff --git a/test_files/10_linux_web_8GB_8_1000_san.txt b/test/expected_results/10_linux_web_8GB_8_1000_san.txt
similarity index 100%
rename from test_files/10_linux_web_8GB_8_1000_san.txt
rename to test/expected_results/10_linux_web_8GB_8_1000_san.txt
index b05417e..51fd1bd 100644
--- a/test_files/10_linux_web_8GB_8_1000_san.txt
+++ b/test/expected_results/10_linux_web_8GB_8_1000_san.txt
@@ -19,5 +19,5 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
+max_parallel_workers_per_gather = 4
diff --git a/test_files/10_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/10_linux_web_8GB_8_1000_ssd.txt
similarity index 100%
rename from test_files/10_linux_web_8GB_8_1000_ssd.txt
rename to test/expected_results/10_linux_web_8GB_8_1000_ssd.txt
index f752792..f8f97ec 100644
--- a/test_files/10_linux_web_8GB_8_1000_ssd.txt
+++ b/test/expected_results/10_linux_web_8GB_8_1000_ssd.txt
@@ -19,5 +19,5 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
+max_parallel_workers_per_gather = 4
diff --git a/test_files/11_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/11_linux_web_8GB_8_1000_hdd.txt
similarity index 100%
rename from test_files/11_linux_web_8GB_8_1000_hdd.txt
rename to test/expected_results/11_linux_web_8GB_8_1000_hdd.txt
index a5d68a1..e60a407 100644
--- a/test_files/11_linux_web_8GB_8_1000_hdd.txt
+++ b/test/expected_results/11_linux_web_8GB_8_1000_hdd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/11_linux_web_8GB_8_1000_san.txt b/test/expected_results/11_linux_web_8GB_8_1000_san.txt
similarity index 93%
rename from test_files/11_linux_web_8GB_8_1000_san.txt
rename to test/expected_results/11_linux_web_8GB_8_1000_san.txt
index b5cf298..4d1e461 100644
--- a/test_files/11_linux_web_8GB_8_1000_san.txt
+++ b/test/expected_results/11_linux_web_8GB_8_1000_san.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
-max_parallel_maintenance_workers = 4
\ No newline at end of file
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/11_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/11_linux_web_8GB_8_1000_ssd.txt
similarity index 100%
rename from test_files/11_linux_web_8GB_8_1000_ssd.txt
rename to test/expected_results/11_linux_web_8GB_8_1000_ssd.txt
index 126d21f..e6d8329 100644
--- a/test_files/11_linux_web_8GB_8_1000_ssd.txt
+++ b/test/expected_results/11_linux_web_8GB_8_1000_ssd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/12_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/12_linux_web_8GB_8_1000_hdd.txt
similarity index 100%
rename from test_files/12_linux_web_8GB_8_1000_hdd.txt
rename to test/expected_results/12_linux_web_8GB_8_1000_hdd.txt
index 02b497b..62680a6 100644
--- a/test_files/12_linux_web_8GB_8_1000_hdd.txt
+++ b/test/expected_results/12_linux_web_8GB_8_1000_hdd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/12_linux_web_8GB_8_1000_san.txt b/test/expected_results/12_linux_web_8GB_8_1000_san.txt
similarity index 93%
rename from test_files/12_linux_web_8GB_8_1000_san.txt
rename to test/expected_results/12_linux_web_8GB_8_1000_san.txt
index c6932ad..5370a44 100644
--- a/test_files/12_linux_web_8GB_8_1000_san.txt
+++ b/test/expected_results/12_linux_web_8GB_8_1000_san.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
-max_parallel_maintenance_workers = 4
\ No newline at end of file
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/12_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/12_linux_web_8GB_8_1000_ssd.txt
similarity index 100%
rename from test_files/12_linux_web_8GB_8_1000_ssd.txt
rename to test/expected_results/12_linux_web_8GB_8_1000_ssd.txt
index 995f9ca..994fb82 100644
--- a/test_files/12_linux_web_8GB_8_1000_ssd.txt
+++ b/test/expected_results/12_linux_web_8GB_8_1000_ssd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/13_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/13_linux_web_8GB_8_1000_hdd.txt
similarity index 100%
rename from test_files/13_linux_web_8GB_8_1000_hdd.txt
rename to test/expected_results/13_linux_web_8GB_8_1000_hdd.txt
index 468d3d4..e69ee5a 100644
--- a/test_files/13_linux_web_8GB_8_1000_hdd.txt
+++ b/test/expected_results/13_linux_web_8GB_8_1000_hdd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/13_linux_web_8GB_8_1000_san.txt b/test/expected_results/13_linux_web_8GB_8_1000_san.txt
similarity index 93%
rename from test_files/13_linux_web_8GB_8_1000_san.txt
rename to test/expected_results/13_linux_web_8GB_8_1000_san.txt
index 8788245..f34648e 100644
--- a/test_files/13_linux_web_8GB_8_1000_san.txt
+++ b/test/expected_results/13_linux_web_8GB_8_1000_san.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
-max_parallel_maintenance_workers = 4
\ No newline at end of file
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/13_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/13_linux_web_8GB_8_1000_ssd.txt
similarity index 100%
rename from test_files/13_linux_web_8GB_8_1000_ssd.txt
rename to test/expected_results/13_linux_web_8GB_8_1000_ssd.txt
index 68723bf..08a9c48 100644
--- a/test_files/13_linux_web_8GB_8_1000_ssd.txt
+++ b/test/expected_results/13_linux_web_8GB_8_1000_ssd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/14_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/14_linux_web_8GB_8_1000_hdd.txt
similarity index 93%
rename from test_files/14_linux_web_8GB_8_1000_hdd.txt
rename to test/expected_results/14_linux_web_8GB_8_1000_hdd.txt
index 11f0658..cae331e 100644
--- a/test_files/14_linux_web_8GB_8_1000_hdd.txt
+++ b/test/expected_results/14_linux_web_8GB_8_1000_hdd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
-max_parallel_maintenance_workers = 4
\ No newline at end of file
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/14_linux_web_8GB_8_1000_san.txt b/test/expected_results/14_linux_web_8GB_8_1000_san.txt
similarity index 93%
rename from test_files/14_linux_web_8GB_8_1000_san.txt
rename to test/expected_results/14_linux_web_8GB_8_1000_san.txt
index f85ed56..ddf738b 100644
--- a/test_files/14_linux_web_8GB_8_1000_san.txt
+++ b/test/expected_results/14_linux_web_8GB_8_1000_san.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
-max_parallel_maintenance_workers = 4
\ No newline at end of file
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/14_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/14_linux_web_8GB_8_1000_ssd.txt
similarity index 100%
rename from test_files/14_linux_web_8GB_8_1000_ssd.txt
rename to test/expected_results/14_linux_web_8GB_8_1000_ssd.txt
index 428e03d..f88a45c 100644
--- a/test_files/14_linux_web_8GB_8_1000_ssd.txt
+++ b/test/expected_results/14_linux_web_8GB_8_1000_ssd.txt
@@ -19,6 +19,6 @@ work_mem = 524kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
-max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test/expected_results/15_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/15_linux_web_8GB_8_1000_hdd.txt
new file mode 100644
index 0000000..6ae554a
--- /dev/null
+++ b/test/expected_results/15_linux_web_8GB_8_1000_hdd.txt
@@ -0,0 +1,24 @@
+# DB Version: 15
+# OS Type: linux
+# DB Type: web
+# Total Memory (RAM): 8 GB
+# CPUs num: 8
+# Connections num: 1000
+# Data Storage: hdd
+
+max_connections = 1000
+shared_buffers = 2GB
+effective_cache_size = 6GB
+maintenance_work_mem = 512MB
+checkpoint_completion_target = 0.9
+wal_buffers = 16MB
+default_statistics_target = 100
+random_page_cost = 4
+effective_io_concurrency = 2
+work_mem = 524kB
+min_wal_size = 1GB
+max_wal_size = 4GB
+max_worker_processes = 8
+max_parallel_workers = 8
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test/expected_results/15_linux_web_8GB_8_1000_san.txt b/test/expected_results/15_linux_web_8GB_8_1000_san.txt
new file mode 100644
index 0000000..4e6b3de
--- /dev/null
+++ b/test/expected_results/15_linux_web_8GB_8_1000_san.txt
@@ -0,0 +1,24 @@
+# DB Version: 15
+# OS Type: linux
+# DB Type: web
+# Total Memory (RAM): 8 GB
+# CPUs num: 8
+# Connections num: 1000
+# Data Storage: san
+
+max_connections = 1000
+shared_buffers = 2GB
+effective_cache_size = 6GB
+maintenance_work_mem = 512MB
+checkpoint_completion_target = 0.9
+wal_buffers = 16MB
+default_statistics_target = 100
+random_page_cost = 1.1
+effective_io_concurrency = 300
+work_mem = 524kB
+min_wal_size = 1GB
+max_wal_size = 4GB
+max_worker_processes = 8
+max_parallel_workers = 8
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test/expected_results/15_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/15_linux_web_8GB_8_1000_ssd.txt
new file mode 100644
index 0000000..e7f5203
--- /dev/null
+++ b/test/expected_results/15_linux_web_8GB_8_1000_ssd.txt
@@ -0,0 +1,24 @@
+# DB Version: 15
+# OS Type: linux
+# DB Type: web
+# Total Memory (RAM): 8 GB
+# CPUs num: 8
+# Connections num: 1000
+# Data Storage: ssd
+
+max_connections = 1000
+shared_buffers = 2GB
+effective_cache_size = 6GB
+maintenance_work_mem = 512MB
+checkpoint_completion_target = 0.9
+wal_buffers = 16MB
+default_statistics_target = 100
+random_page_cost = 1.1
+effective_io_concurrency = 200
+work_mem = 524kB
+min_wal_size = 1GB
+max_wal_size = 4GB
+max_worker_processes = 8
+max_parallel_workers = 8
+max_parallel_maintenance_workers = 4
+max_parallel_workers_per_gather = 4
diff --git a/test_files/9.5_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/9.5_linux_web_8GB_8_1000_hdd.txt
similarity index 100%
rename from test_files/9.5_linux_web_8GB_8_1000_hdd.txt
rename to test/expected_results/9.5_linux_web_8GB_8_1000_hdd.txt
diff --git a/test_files/9.5_linux_web_8GB_8_1000_san.txt b/test/expected_results/9.5_linux_web_8GB_8_1000_san.txt
similarity index 100%
rename from test_files/9.5_linux_web_8GB_8_1000_san.txt
rename to test/expected_results/9.5_linux_web_8GB_8_1000_san.txt
diff --git a/test_files/9.5_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/9.5_linux_web_8GB_8_1000_ssd.txt
similarity index 100%
rename from test_files/9.5_linux_web_8GB_8_1000_ssd.txt
rename to test/expected_results/9.5_linux_web_8GB_8_1000_ssd.txt
diff --git a/test_files/9.6_linux_web_8GB_8_1000_hdd.txt b/test/expected_results/9.6_linux_web_8GB_8_1000_hdd.txt
similarity index 100%
rename from test_files/9.6_linux_web_8GB_8_1000_hdd.txt
rename to test/expected_results/9.6_linux_web_8GB_8_1000_hdd.txt
diff --git a/test_files/9.6_linux_web_8GB_8_1000_san.txt b/test/expected_results/9.6_linux_web_8GB_8_1000_san.txt
similarity index 100%
rename from test_files/9.6_linux_web_8GB_8_1000_san.txt
rename to test/expected_results/9.6_linux_web_8GB_8_1000_san.txt
diff --git a/test_files/9.6_linux_web_8GB_8_1000_ssd.txt b/test/expected_results/9.6_linux_web_8GB_8_1000_ssd.txt
similarity index 100%
rename from test_files/9.6_linux_web_8GB_8_1000_ssd.txt
rename to test/expected_results/9.6_linux_web_8GB_8_1000_ssd.txt
diff --git a/test/scripts/build_run_images.sh b/test/scripts/build_run_images.sh
new file mode 100644
index 0000000..3117de4
--- /dev/null
+++ b/test/scripts/build_run_images.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+# This scripts build all possible Debian combination
+# of PostgreSQL + PostGIS and outputs PostgreSQL
+# configuration file for checking
+
+declare -a arr=("15|3"
+ "14|3"
+ "13|3"
+ "12|3"
+ "11-bullseye|3"
+ "11|2.5"
+ "10-bullseye|3"
+ "10|2.5"
+ "10|2.4"
+ "9.6-bullseye|3"
+ "9.6|2.5"
+ "9.6|2.4"
+ "9.6|2.3"
+ "9.5|3"
+ "9.5|2.5"
+ "9.5|2.4"
+ "9.5|2.3"
+ )
+
+IFS='|'
+for i in "${arr[@]}"
+do
+ read -ra ADDR <<< "$i"
+ pg_version="${ADDR[0]}"
+ postgis_version="${ADDR[1]}"
+ docker build --no-cache --build-arg POSTGRES_VERSION=$pg_version --build-arg POSTGIS_VERSION=$postgis_version . -t pg$pg_version-$postgis_version
+ docker run -d -e POSTGRES_PASSWORD=secret --name pg$pg_version-$postgis_version pg$pg_version-$postgis_version
+ docker exec -ti pg$pg_version-$postgis_version bash -c "until pg_isready -q; do sleep 5; done"
+ docker exec -ti pg$pg_version-$postgis_version bash -c "cat /etc/apt/sources.list.d/pgdg.list"
+ docker exec -ti pg$pg_version-$postgis_version bash -c "cat /var/lib/postgresql/data/postgresql.conf" > pg$pg_version-$postgis_version.txt
+ docker stop pg$pg_version-$postgis_version && docker rm pg$pg_version-$postgis_version
+done
diff --git a/test/scripts/check_compatibility.sh b/test/scripts/check_compatibility.sh
new file mode 100644
index 0000000..9b7a72f
--- /dev/null
+++ b/test/scripts/check_compatibility.sh
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+# This script runs official PostgreSQL Docker images
+# and gets the available PostGIS version for each of them.
+# Also ouputs the distribution used for each image.
+
+pg_versions="15 14 13 12 11 11-bullseye 10 10-bullseye 9.6 9.6-bullseye 9.5"
+
+for v in $pg_versions
+do
+ echo "Examining postgres:$v"
+ echo "######################"
+ docker run -d -e POSTGRES_PASSWORD=secret --name pg$v postgres:$v >/dev/null 2>&1
+ codename=$(docker exec -ti pg$v bash -c "source /etc/os-release && echo -n \$VERSION_CODENAME")
+ id=$(docker exec -ti pg$v bash -c "source /etc/os-release && echo -n \$ID")
+ if [ "$id" = "debian" ]
+ then
+ if [ "$codename" = "stretch" ]
+ then
+ echo "applying apt-archive.postgres.org patch"
+ c="cd /etc/apt/sources.list.d/ && mv pgdg.list pgdg.list.backup"
+ docker exec -ti pg$v bash -c "$c"
+ c="apt-get -qq update && DEBCONF_NOWARNINGS='yes' apt-get install apt-transport-https -y > /dev/null"
+ docker exec -ti pg$v bash -c "$c"
+ c="cd /etc/apt/sources.list.d/ && mv pgdg.list.backup pgdg.list"
+ docker exec -ti pg$v bash -c "$c"
+ c="sed -i 's/http\:\/\/apt\.postgres/https\:\/\/apt-archive\.postgres/' /etc/apt/sources.list.d/pgdg.list"
+ docker exec -ti pg$v bash -c "$c"
+ c="apt-get -qq update"
+ docker exec -ti pg$v bash -c "$c"
+ fi
+ c="apt update >/dev/null 2>&1 && apt-cache search \$PG_MAJOR-postgis | grep -Po \"(?<=postgresql-\$PG_MAJOR-postgis-)([0-9\.]*)\" | uniq | xargs "
+ versions=$(docker exec -ti pg$v bash -c "$c")
+ fi
+ echo "Available PostGIS versions : "$versions
+ distrib=$(docker exec -ti pg$v bash -c "source /etc/os-release && echo -n \$PRETTY_NAME")
+ echo "Running on "$distrib
+ docker rm -f pg$v >/dev/null 2>&1
+ echo
+done
diff --git a/test/scripts/pull_testing_images.sh b/test/scripts/pull_testing_images.sh
new file mode 100644
index 0000000..9722d49
--- /dev/null
+++ b/test/scripts/pull_testing_images.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+# This script pulls images from Docker Hub and run them
+# to do a simple check of PostgreSQL configuration
+
+testing_image="esgn/pgtuned-testing"
+
+tags=$(curl "https://registry.hub.docker.com/v2/repositories/$testing_image/tags?page_size=32" 2>/dev/null | jq -r '.results | .[] | .name')
+for tag in $tags
+do
+ image_name=$testing_image":"$tag
+ docker rmi $image_name &> /dev/null
+ docker pull -q $image_name
+ docker run -d -e POSTGRES_PASSWORD=secret --name pg-testing$tag $image_name
+ docker exec -ti pg-testing$tag bash -c "until pg_isready -q; do sleep 5; done"
+ docker exec -ti pg-testing$tag bash -c "cat /etc/apt/sources.list.d/pgdg.list"
+ docker exec -ti pg-testing$tag bash -c "cat /var/lib/postgresql/data/postgresql.conf" > pg-testing$tag".txt"
+ docker stop pg-testing$tag &> /dev/null && docker rm pg-testing$tag &> /dev/null
+done
diff --git a/test.sh b/test/scripts/test_pgtune.sh
similarity index 78%
rename from test.sh
rename to test/scripts/test_pgtune.sh
index 3acc679..c5f1e2a 100644
--- a/test.sh
+++ b/test/scripts/test_pgtune.sh
@@ -1,7 +1,11 @@
#!/usr/bin/env bash
-test_files_dir="test_files/"
-pg_versions="14 13 12 11 10 9.6 9.5"
+# This scripts runs pgtune.sh and compare its results
+# to expected results (see /expected_results directory)
+
+test_files_dir="../expected_results/"
+pgtuned_script="../../pgtune.sh"
+pg_versions="15 14 13 12 11 10 9.6 9.5"
db_types="web oltp dw desktop mixed"
total_mem=8GB
cpu_count=8
@@ -23,7 +27,7 @@ do
echo "= stge_type: "$stge_type
echo "====================================="
output_file=$pg_version$db_type$total_mem$cpu_count$max_conn$stge_type".txt"
- bash pgtune.sh -v $pg_version -t $db_type -m $total_mem -u $cpu_count -c $max_conn -s $stge_type > $output_file
+ bash $pgtuned_script -v $pg_version -t $db_type -m $total_mem -u $cpu_count -c $max_conn -s $stge_type > $output_file
test_file=$pg_version"_linux_"$db_type"_"$total_mem"_"$cpu_count"_"$max_conn"_"$stge_type".txt"
if [ ! -f "$test_files_dir$test_file" ]
then