Skip to content

Commit

Permalink
Improve PostgreSQL specs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andyone committed Sep 26, 2023
1 parent 3bf957e commit ffcb7e3
Show file tree
Hide file tree
Showing 15 changed files with 298 additions and 14 deletions.
4 changes: 2 additions & 2 deletions specs/postgresql-10/postgresql-10.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions specs/postgresql-11/postgresql-11.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions specs/postgresql-12/postgresql-12.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions specs/postgresql-13/postgresql-13.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions specs/postgresql-14/postgresql-14.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions specs/postgresql-15/postgresql-15.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
4 changes: 2 additions & 2 deletions specs/postgresql-16/postgresql-16.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}

Expand Down
5 changes: 5 additions & 0 deletions tests/postgresql/postgresql10.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions tests/postgresql/postgresql11.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions tests/postgresql/postgresql12.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions tests/postgresql/postgresql13.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions tests/postgresql/postgresql14.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions tests/postgresql/postgresql15.recipe
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down
54 changes: 54 additions & 0 deletions tests/postgresql/postgresql16-libs.recipe
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit ffcb7e3

Please sign in to comment.