From ffcb7e3c6106adf50578358d5985a5b5fa5934ce Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Tue, 26 Sep 2023 21:36:01 +0300 Subject: [PATCH] Improve PostgreSQL specs and tests --- specs/postgresql-10/postgresql-10.spec | 4 +- specs/postgresql-11/postgresql-11.spec | 4 +- specs/postgresql-12/postgresql-12.spec | 4 +- specs/postgresql-13/postgresql-13.spec | 4 +- specs/postgresql-14/postgresql-14.spec | 4 +- specs/postgresql-15/postgresql-15.spec | 4 +- specs/postgresql-16/postgresql-16.spec | 4 +- tests/postgresql/postgresql10.recipe | 5 + tests/postgresql/postgresql11.recipe | 5 + tests/postgresql/postgresql12.recipe | 5 + tests/postgresql/postgresql13.recipe | 5 + tests/postgresql/postgresql14.recipe | 5 + tests/postgresql/postgresql15.recipe | 5 + tests/postgresql/postgresql16-libs.recipe | 54 ++++++ tests/postgresql/postgresql16.recipe | 200 ++++++++++++++++++++++ 15 files changed, 298 insertions(+), 14 deletions(-) create mode 100644 tests/postgresql/postgresql16-libs.recipe create mode 100644 tests/postgresql/postgresql16.recipe diff --git a/specs/postgresql-10/postgresql-10.spec b/specs/postgresql-10/postgresql-10.spec index b489b4247..baf95f2c3 100644 --- a/specs/postgresql-10/postgresql-10.spec +++ b/specs/postgresql-10/postgresql-10.spec @@ -124,7 +124,7 @@ BuildRequires: openldap-devel BuildRequires: systemd systemd-devel -Requires: /sbin/ldconfig initscripts +Requires: %{_sbindir}/ldconfig initscripts Requires: %{name}-libs = %{version} Requires(post): systemd @@ -176,10 +176,10 @@ to a PostgreSQL server. Summary: The programs needed to create and run a PostgreSQL server Group: Applications/Databases -Requires: useradd chkconfig Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} Requires: glibc kaosv >= 2.16 numactl +Requires: %{_sbindir}/useradd %{_sbindir}/chkconfig Provides: %{realname}-server = %{version}-%{release} diff --git a/specs/postgresql-11/postgresql-11.spec b/specs/postgresql-11/postgresql-11.spec index cac49be3a..78aa37929 100644 --- a/specs/postgresql-11/postgresql-11.spec +++ b/specs/postgresql-11/postgresql-11.spec @@ -134,7 +134,7 @@ BuildRequires: llvm5.0-devel >= 5.0 llvm-toolset-7-clang >= 4.0.1 BuildRequires: systemd systemd-devel -Requires: /sbin/ldconfig initscripts +Requires: %{_sbindir}/ldconfig initscripts Requires: %{name}-libs = %{version} Requires(post): systemd @@ -186,10 +186,10 @@ to a PostgreSQL server. Summary: The programs needed to create and run a PostgreSQL server Group: Applications/Databases -Requires: useradd chkconfig Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} Requires: glibc kaosv >= 2.16 numactl +Requires: %{_sbindir}/useradd %{_sbindir}/chkconfig Provides: %{realname}-server = %{version}-%{release} diff --git a/specs/postgresql-12/postgresql-12.spec b/specs/postgresql-12/postgresql-12.spec index 40a3cfbcd..af13ebc32 100644 --- a/specs/postgresql-12/postgresql-12.spec +++ b/specs/postgresql-12/postgresql-12.spec @@ -134,7 +134,7 @@ BuildRequires: llvm5.0-devel >= 5.0 llvm-toolset-7-clang >= 4.0.1 BuildRequires: systemd systemd-devel -Requires: /sbin/ldconfig initscripts +Requires: %{_sbindir}/ldconfig initscripts Requires: %{name}-libs = %{version} Requires(post): systemd @@ -186,10 +186,10 @@ to a PostgreSQL server. Summary: The programs needed to create and run a PostgreSQL server Group: Applications/Databases -Requires: useradd chkconfig Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} Requires: glibc kaosv >= 2.16 numactl +Requires: %{_sbindir}/useradd %{_sbindir}/chkconfig Provides: %{realname}-server = %{version}-%{release} diff --git a/specs/postgresql-13/postgresql-13.spec b/specs/postgresql-13/postgresql-13.spec index b30c06483..433dc5571 100644 --- a/specs/postgresql-13/postgresql-13.spec +++ b/specs/postgresql-13/postgresql-13.spec @@ -134,7 +134,7 @@ BuildRequires: llvm5.0-devel >= 5.0 llvm-toolset-7-clang >= 4.0.1 BuildRequires: systemd systemd-devel -Requires: /sbin/ldconfig initscripts +Requires: %{_sbindir}/ldconfig initscripts Requires: %{name}-libs = %{version} Requires(post): systemd @@ -186,10 +186,10 @@ to a PostgreSQL server. Summary: The programs needed to create and run a PostgreSQL server Group: Applications/Databases -Requires: useradd chkconfig Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} Requires: glibc kaosv >= 2.16 numactl +Requires: %{_sbindir}/useradd %{_sbindir}/chkconfig Provides: %{realname}-server = %{version}-%{release} diff --git a/specs/postgresql-14/postgresql-14.spec b/specs/postgresql-14/postgresql-14.spec index 99a4d6ae2..dd869ee4b 100644 --- a/specs/postgresql-14/postgresql-14.spec +++ b/specs/postgresql-14/postgresql-14.spec @@ -134,7 +134,7 @@ BuildRequires: llvm5.0-devel >= 5.0 llvm-toolset-7-clang >= 4.0.1 BuildRequires: systemd systemd-devel -Requires: /sbin/ldconfig initscripts +Requires: %{_sbindir}/ldconfig initscripts Requires: %{name}-libs = %{version} Requires(post): systemd @@ -186,10 +186,10 @@ to a PostgreSQL server. Summary: The programs needed to create and run a PostgreSQL server Group: Applications/Databases -Requires: useradd chkconfig Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} Requires: glibc kaosv >= 2.16 numactl +Requires: %{_sbindir}/useradd %{_sbindir}/chkconfig Provides: %{realname}-server = %{version}-%{release} diff --git a/specs/postgresql-15/postgresql-15.spec b/specs/postgresql-15/postgresql-15.spec index c46226c14..995fa9d36 100644 --- a/specs/postgresql-15/postgresql-15.spec +++ b/specs/postgresql-15/postgresql-15.spec @@ -140,7 +140,7 @@ Requires: libzstd > 1.4.0 BuildRequires: systemd systemd-devel -Requires: /sbin/ldconfig initscripts +Requires: %{_sbindir}/ldconfig initscripts Requires: %{name}-libs = %{version} Requires(post): systemd @@ -192,10 +192,10 @@ to a PostgreSQL server. Summary: The programs needed to create and run a PostgreSQL server Group: Applications/Databases -Requires: useradd chkconfig Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} Requires: glibc kaosv >= 2.16 numactl util-linux +Requires: %{_sbindir}/useradd %{_sbindir}/chkconfig Provides: %{realname}-server = %{version}-%{release} diff --git a/specs/postgresql-16/postgresql-16.spec b/specs/postgresql-16/postgresql-16.spec index b1a15cd07..86c897566 100644 --- a/specs/postgresql-16/postgresql-16.spec +++ b/specs/postgresql-16/postgresql-16.spec @@ -140,7 +140,7 @@ Requires: libzstd > 1.4.0 BuildRequires: systemd systemd-devel -Requires: /sbin/ldconfig initscripts +Requires: %{_sbindir}/ldconfig initscripts Requires: %{name}-libs = %{version} Requires(post): systemd @@ -192,10 +192,10 @@ to a PostgreSQL server. Summary: The programs needed to create and run a PostgreSQL server Group: Applications/Databases -Requires: useradd chkconfig Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} Requires: glibc kaosv >= 2.16 numactl util-linux +Requires: %{_sbindir}/useradd %{_sbindir}/chkconfig Provides: %{realname}-server = %{version}-%{release} diff --git a/tests/postgresql/postgresql10.recipe b/tests/postgresql/postgresql10.recipe index 302ec06fd..aff02e568 100644 --- a/tests/postgresql/postgresql10.recipe +++ b/tests/postgresql/postgresql10.recipe @@ -17,6 +17,8 @@ var data_dir {state_dir}/{version} var pid_file /var/run/postgresql{version}.pid var port 5432 +var cmd_pause 1 + var python3_lib libpython{PYTHON3_VERSION}* var perl_lib libperl.* var tcl_lib libtcl8.* @@ -156,6 +158,7 @@ command "service {service_name} initdb" "Database initialization" owner {data_dir}/data/postgresql.conf {service_user} command "systemctl start {service_name}" "Start PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} @@ -169,12 +172,14 @@ command "{service_user}:{install_dir}/bin/psql -t -c 'select version();'" "Check output-contains "PostgreSQL {version}" command "systemctl restart {service_name}" "Restart PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} !checksum {pid_file} {pid_sha} command "systemctl stop {service_name}" "Stop PostgreSQL server" + wait {cmd_pause} !wait-fs {data_dir}/data/postmaster.pid !service-works {service_name} !connect tcp :{port} diff --git a/tests/postgresql/postgresql11.recipe b/tests/postgresql/postgresql11.recipe index 299024104..a271051c1 100644 --- a/tests/postgresql/postgresql11.recipe +++ b/tests/postgresql/postgresql11.recipe @@ -17,6 +17,8 @@ var data_dir {state_dir}/{version} var pid_file /var/run/postgresql{version}.pid var port 5432 +var cmd_pause 1 + var python3_lib libpython{PYTHON3_VERSION}* var perl_lib libperl.* var tcl_lib libtcl8.* @@ -165,6 +167,7 @@ command "service {service_name} initdb" "Database initialization" owner {data_dir}/data/postgresql.conf {service_user} command "systemctl start {service_name}" "Start PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} @@ -178,12 +181,14 @@ command "{service_user}:{install_dir}/bin/psql -t -c 'select version();'" "Check output-contains "PostgreSQL {version}" command "systemctl restart {service_name}" "Restart PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} !checksum {pid_file} {pid_sha} command "systemctl stop {service_name}" "Stop PostgreSQL server" + wait {cmd_pause} !wait-fs {data_dir}/data/postmaster.pid !service-works {service_name} !connect tcp :{port} diff --git a/tests/postgresql/postgresql12.recipe b/tests/postgresql/postgresql12.recipe index b77cb9fb1..8e2af6961 100644 --- a/tests/postgresql/postgresql12.recipe +++ b/tests/postgresql/postgresql12.recipe @@ -17,6 +17,8 @@ var data_dir {state_dir}/{version} var pid_file /var/run/postgresql{version}.pid var port 5432 +var cmd_pause 1 + var python3_lib libpython{PYTHON3_VERSION}* var perl_lib libperl.* var tcl_lib libtcl8.* @@ -165,6 +167,7 @@ command "service {service_name} initdb" "Database initialization" owner {data_dir}/data/postgresql.conf {service_user} command "systemctl start {service_name}" "Start PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} @@ -178,12 +181,14 @@ command "{service_user}:{install_dir}/bin/psql -t -c 'select version();'" "Check output-contains "PostgreSQL {version}" command "systemctl restart {service_name}" "Restart PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} !checksum {pid_file} {pid_sha} command "systemctl stop {service_name}" "Stop PostgreSQL server" + wait {cmd_pause} !wait-fs {data_dir}/data/postmaster.pid !service-works {service_name} !connect tcp :{port} diff --git a/tests/postgresql/postgresql13.recipe b/tests/postgresql/postgresql13.recipe index 840422d84..c14acd55d 100644 --- a/tests/postgresql/postgresql13.recipe +++ b/tests/postgresql/postgresql13.recipe @@ -17,6 +17,8 @@ var data_dir {state_dir}/{version} var pid_file /var/run/postgresql{version}.pid var port 5432 +var cmd_pause 1 + var python3_lib libpython{PYTHON3_VERSION}* var perl_lib libperl.* var tcl_lib libtcl8.* @@ -167,6 +169,7 @@ command "service {service_name} initdb" "Database initialization" owner {data_dir}/data/postgresql.conf {service_user} command "systemctl start {service_name}" "Start PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} @@ -180,12 +183,14 @@ command "{service_user}:{install_dir}/bin/psql -t -c 'select version();'" "Check output-contains "PostgreSQL {version}" command "systemctl restart {service_name}" "Restart PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} !checksum {pid_file} {pid_sha} command "systemctl stop {service_name}" "Stop PostgreSQL server" + wait {cmd_pause} !wait-fs {data_dir}/data/postmaster.pid !service-works {service_name} !connect tcp :{port} diff --git a/tests/postgresql/postgresql14.recipe b/tests/postgresql/postgresql14.recipe index 51800b099..b12457be5 100644 --- a/tests/postgresql/postgresql14.recipe +++ b/tests/postgresql/postgresql14.recipe @@ -17,6 +17,8 @@ var data_dir {state_dir}/{version} var pid_file /var/run/postgresql{version}.pid var port 5432 +var cmd_pause 1 + var python3_lib libpython{PYTHON3_VERSION}* var perl_lib libperl.* var tcl_lib libtcl8.* @@ -167,6 +169,7 @@ command "service {service_name} initdb" "Database initialization" owner {data_dir}/data/postgresql.conf {service_user} command "systemctl start {service_name}" "Start PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} @@ -180,12 +183,14 @@ command "{service_user}:{install_dir}/bin/psql -t -c 'select version();'" "Check output-contains "PostgreSQL {version}" command "systemctl restart {service_name}" "Restart PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} !checksum {pid_file} {pid_sha} command "systemctl stop {service_name}" "Stop PostgreSQL server" + wait {cmd_pause} !wait-fs {data_dir}/data/postmaster.pid !service-works {service_name} !connect tcp :{port} diff --git a/tests/postgresql/postgresql15.recipe b/tests/postgresql/postgresql15.recipe index e8e110979..31ac98795 100644 --- a/tests/postgresql/postgresql15.recipe +++ b/tests/postgresql/postgresql15.recipe @@ -17,6 +17,8 @@ var data_dir {state_dir}/{version} var pid_file /var/run/postgresql{version}.pid var port 5432 +var cmd_pause 1 + var python3_lib libpython{PYTHON3_VERSION}* var perl_lib libperl.* var tcl_lib libtcl8.* @@ -167,6 +169,7 @@ command "service {service_name} initdb" "Database initialization" owner {data_dir}/data/postgresql.conf {service_user} command "systemctl start {service_name}" "Start PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} @@ -180,12 +183,14 @@ command "{service_user}:{install_dir}/bin/psql -t -c 'select version();'" "Check output-contains "PostgreSQL {version}" command "systemctl restart {service_name}" "Restart PostgreSQL server" + wait {cmd_pause} wait-fs {data_dir}/data/postmaster.pid service-works {service_name} connect tcp :{port} !checksum {pid_file} {pid_sha} command "systemctl stop {service_name}" "Stop PostgreSQL server" + wait {cmd_pause} !wait-fs {data_dir}/data/postmaster.pid !service-works {service_name} !connect tcp :{port} diff --git a/tests/postgresql/postgresql16-libs.recipe b/tests/postgresql/postgresql16-libs.recipe new file mode 100644 index 000000000..16297684a --- /dev/null +++ b/tests/postgresql/postgresql16-libs.recipe @@ -0,0 +1,54 @@ +# Bibop recipe for PostgreSQL 16 Libraries +# See more: https://kaos.sh/bibop + +pkg gcc postgresql16-devel postgresql16-libs + +var version 16 +var install_dir /usr/pgsql-{version} +var lib_dir {install_dir}/lib +var include_dir {install_dir}/include + +var libpq_linking_flags "-lpq" +var libpgtypes_linking_flags "-lpgtypes" +var libecpg_linking_flags "-lecpg" +var libecpg_compat_linking_flags "-lecpg_compat" + +command "-" "Check development environment" + lib-loaded libecpg.so.* + lib-loaded libecpg_compat.so.* + lib-loaded libpgtypes.so.* + lib-loaded libpq.so.* + lib-loaded libpqwalreceiver.so + + lib-config libecpg_compat + lib-config libecpg + lib-config libpgtypes + lib-config libpq + +command "gcc -o test_libpq_bin -I {include_dir} -L {lib_dir} {libpq_linking_flags} test_libpq.c" "Compile binary with libpq" + exit 0 + exist test_libpq_bin + ++command "./test_libpq_bin" "Execute built binary" + exit 0 + +command "gcc -o test_libpgtypes_bin -I {include_dir} -L {lib_dir} {libpgtypes_linking_flags} test_libpgtypes.c" "Compile binary with libpgtypes" + exit 0 + exist test_libpgtypes_bin + ++command "./test_libpgtypes_bin" "Execute built binary" + exit 0 + +command "gcc -o test_libecpg_bin -I {include_dir} -L {lib_dir} {libecpg_linking_flags} test_libecpg.c" "Compile binary with libecpg" + exit 0 + exist test_libecpg_bin + ++command "./test_libecpg_bin" "Execute built binary" + exit 0 + +command "gcc -o test_libecpg_compat_bin -I {include_dir} -L {lib_dir} {libecpg_compat_linking_flags} test_libecpg_compat.c" "Compile binary with libecpg_compat" + exit 0 + exist test_libecpg_compat_bin + ++command "./test_libecpg_compat_bin" "Execute built binary" + exit 0 diff --git a/tests/postgresql/postgresql16.recipe b/tests/postgresql/postgresql16.recipe new file mode 100644 index 000000000..9ecd14916 --- /dev/null +++ b/tests/postgresql/postgresql16.recipe @@ -0,0 +1,200 @@ +# Bibop recipe for PostgreSQL 16 +# See more: https://kaos.sh/bibop + +pkg postgresql16-contrib postgresql16-devel postgresql16-docs postgresql16-libs postgresql16-llvmjit postgresql16-plperl postgresql16-plpython3 postgresql16-pltcl postgresql16-server postgresql16-test + +require-root yes +unsafe-actions yes + +var version 16 +var service_name postgresql-{version} +var service_user postgres +var service_group postgres +var install_dir /usr/pgsql-{version} +var lib_dir {install_dir}/lib +var state_dir /var/lib/pgsql +var data_dir {state_dir}/{version} +var pid_file /var/run/postgresql{version}.pid +var port 5432 + +var cmd_pause 1 + +var python3_lib libpython{PYTHON3_VERSION}* +var perl_lib libperl.* +var tcl_lib libtcl8.* + +## ENVIRONMENT ################################################################# + +command "-" "Check environment" + app psql + app pg_dump + app pg_config + + service-present {service_name} + + user-exist {service_user} + user-id {service_user} 26 + group-exist {service_group} + + exist /etc/sysconfig/{service_name} + mode /etc/sysconfig/{service_name} 644 + exist /etc/init.d/{service_name} + mode /etc/init.d/{service_name} 755 + +command "-" "Check configuration files for external systems" + exist /etc/pam.d/postgresql{version} + mode /etc/pam.d/postgresql{version} 644 + + exist /usr/lib/tmpfiles.d/postgresql-{version}.conf + mode /usr/lib/tmpfiles.d/postgresql-{version}.conf 644 + +command "-" "Check data directory" + exist {data_dir}/backups + exist {data_dir}/data + owner {data_dir}/data {service_user} + mode {data_dir}/data 700 + +command "-" "Check binaries" + exist {install_dir}/bin/createdb + exist {install_dir}/bin/createuser + exist {install_dir}/bin/dropdb + exist {install_dir}/bin/dropuser + exist {install_dir}/bin/initdb + exist {install_dir}/bin/pg_config + exist {install_dir}/bin/pg_ctl + exist {install_dir}/bin/pg_dump + exist {install_dir}/bin/pg_dumpall + exist {install_dir}/bin/pg_restore + exist {install_dir}/bin/postgres + exist {install_dir}/bin/psql + + mode {install_dir}/bin/createdb 755 + mode {install_dir}/bin/createuser 755 + mode {install_dir}/bin/dropdb 755 + mode {install_dir}/bin/dropuser 755 + mode {install_dir}/bin/initdb 755 + mode {install_dir}/bin/pg_config 755 + mode {install_dir}/bin/pg_ctl 755 + mode {install_dir}/bin/pg_dump 755 + mode {install_dir}/bin/pg_dumpall 755 + mode {install_dir}/bin/pg_restore 755 + mode {install_dir}/bin/postgres 755 + mode {install_dir}/bin/psql 755 + +command "-" "Check bash_profile" + exist {install_dir}/share/bash_profile + mode {install_dir}/share/bash_profile 700 + owner {install_dir}/share/bash_profile {service_user}:{service_group} + + link {state_dir}/.bash_profile {install_dir}/share/bash_profile + +command "-" "Check development environment" + exist {install_dir}/include/libpq-fe.h + exist {install_dir}/include/pgtypes.h + + lib-loaded libecpg.so.* + lib-loaded libecpg_compat.so.* + lib-loaded libpgtypes.so.* + lib-loaded libpq.so.* + lib-loaded libpqwalreceiver.so + + lib-config libecpg_compat + lib-config libecpg + lib-config libpgtypes + lib-config libpq + +command "-" "Check symlinks linker and pkgconfig configs" + exist /etc/ld.so.conf.d/postgresql-pgdg-libs.conf + exist {LIBDIR}/pkgconfig/libecpg_compat.pc + exist {LIBDIR}/pkgconfig/libecpg.pc + exist {LIBDIR}/pkgconfig/libpgtypes.pc + exist {LIBDIR}/pkgconfig/libpq.pc + + link /etc/ld.so.conf.d/postgresql-pgdg-libs.conf {install_dir}/share/postgresql-{version}-libs.conf + link {LIBDIR}/pkgconfig/libecpg_compat.pc {install_dir}/lib/pkgconfig/libecpg_compat.pc + link {LIBDIR}/pkgconfig/libecpg.pc {install_dir}/lib/pkgconfig/libecpg.pc + link {LIBDIR}/pkgconfig/libpgtypes.pc {install_dir}/lib/pkgconfig/libpgtypes.pc + link {LIBDIR}/pkgconfig/libpq.pc {install_dir}/lib/pkgconfig/libpq.pc + +command "-" "Check LLVM Bitcode" + exist {lib_dir}/bitcode + exist {lib_dir}/llvmjit.so + + dir {lib_dir}/bitcode + !empty-dir {lib_dir}/bitcode + +command "-" "Check PL/Python3U" + exist {lib_dir}/hstore_plpython3.so + exist {lib_dir}/jsonb_plpython3.so + exist {lib_dir}/ltree_plpython3.so + exist {lib_dir}/plpython3.so + + lib-linked {lib_dir}/hstore_plpython3.so {python3_lib} + lib-linked {lib_dir}/jsonb_plpython3.so {python3_lib} + lib-linked {lib_dir}/ltree_plpython3.so {python3_lib} + lib-linked {lib_dir}/plpython3.so {python3_lib} + +command "-" "Check PL/PerlU" + exist {lib_dir}/bool_plperl.so + exist {lib_dir}/hstore_plperl.so + exist {lib_dir}/plperl.so + + lib-linked {lib_dir}/bool_plperl.so {perl_lib} + lib-linked {lib_dir}/hstore_plperl.so {perl_lib} + lib-linked {lib_dir}/plperl.so {perl_lib} + +command "-" "Check PL/PerlU" + exist {lib_dir}/pltcl.so + + lib-linked {lib_dir}/pltcl.so {tcl_lib} + +## SERVER ###################################################################### + +command "service {service_name} initdb" "Database initialization" + exit 0 + exist {data_dir}/data/PG_VERSION + exist {data_dir}/data/pg_hba.conf + exist {data_dir}/data/pg_ident.conf + exist {data_dir}/data/postgresql.conf + exist {data_dir}/data/pg_wal + mode {data_dir}/data/pg_hba.conf 600 + mode {data_dir}/data/pg_ident.conf 600 + mode {data_dir}/data/postgresql.conf 600 + mode {data_dir}/data/pg_wal 700 + !empty {data_dir}/data/pg_hba.conf + !empty {data_dir}/data/pg_ident.conf + !empty {data_dir}/data/postgresql.conf + owner {data_dir}/data/pg_hba.conf {service_user} + owner {data_dir}/data/pg_ident.conf {service_user} + owner {data_dir}/data/postgresql.conf {service_user} + +command "systemctl start {service_name}" "Start PostgreSQL server" + wait {cmd_pause} + wait-fs {data_dir}/data/postmaster.pid + service-works {service_name} + connect tcp :{port} + checksum-read {pid_file} pid_sha + +command "systemctl status {service_name}" "Check status of PostgreSQL server" + expect "active (running)" + +command "{service_user}:{install_dir}/bin/psql -t -c 'select version();'" "Check PostgreSQL version" + exit 0 + output-contains "PostgreSQL {version}" + +command "systemctl restart {service_name}" "Restart PostgreSQL server" + wait {cmd_pause} + wait-fs {data_dir}/data/postmaster.pid + service-works {service_name} + connect tcp :{port} + !checksum {pid_file} {pid_sha} + +command "systemctl stop {service_name}" "Stop PostgreSQL server" + wait {cmd_pause} + !wait-fs {data_dir}/data/postmaster.pid + !service-works {service_name} + !connect tcp :{port} + +command:teardown "-" "Data cleanup" + cleanup {data_dir}/data + cleanup {data_dir}/backups