mirror of
git://git.openembedded.org/meta-openembedded
synced 2026-04-02 02:49:12 +00:00
postgresql: add ptest support
Add ptest infrastructure to run the PostgreSQL standard regression test suite (pg_regress) on the target system. Test logs: root@qemux86-64:~# ptest-runner postgresql START: ptest-runner 2026-03-24T02:42 BEGIN: /usr/lib64/postgresql/ptest ..... **if all pass ** PASS: - event_trigger_login 1901 ms PASS: - fast_default 9459 ms PASS: - tablespace 16542 ms PASS: all tests passed **if have fail** FAIL: create_type 1763 ms PASS: create_schema 2123 ms PASS: - tablespace 23226 ms FAIL: some tests failed waiting for server to shut down.... done server stopped DURATION: 853 END: /usr/lib64/postgresql/ptest 2026-03-24T02:56 STOP: ptest-runner TOTAL: 1 FAIL: 0 Signed-off-by: Guocai He <guocai.he.cn@windriver.com> Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
parent
c4c6915cba
commit
4fe575d155
@ -77,6 +77,7 @@ PTESTS_SLOW_META_OE = "\
|
||||
fftw \
|
||||
libusb-compat \
|
||||
mariadb \
|
||||
postgresql \
|
||||
re2 \
|
||||
rocksdb \
|
||||
"
|
||||
|
||||
65
meta-oe/recipes-dbs/postgresql/files/run-ptest
Normal file
65
meta-oe/recipes-dbs/postgresql/files/run-ptest
Normal file
@ -0,0 +1,65 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# PostgreSQL regression test runner for ptest
|
||||
#
|
||||
# This script initializes a temporary PostgreSQL database cluster,
|
||||
# starts a server instance, and executes the standard regression test
|
||||
# suite via pg_regress against the installed PostgreSQL binaries.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
PGDATA=/tmp/ptest_pgdata
|
||||
PTEST_PATH=$(dirname "$(readlink -f "$0")")
|
||||
TESTDIR="${PTEST_PATH}/test"
|
||||
PGBIN=$(pg_config --bindir)
|
||||
PKGLIBDIR=$(pg_config --pkglibdir)
|
||||
|
||||
cleanup() {
|
||||
su - postgres -c "pg_ctl -D ${PGDATA} stop -m immediate" 2>/dev/null || true
|
||||
rm -rf "${PGDATA}"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Initialize the database cluster
|
||||
rm -rf "${PGDATA}"
|
||||
su - postgres -c "${PGBIN}/initdb -D ${PGDATA} --no-locale" || exit 1
|
||||
|
||||
# Start the server
|
||||
su - postgres -c "pg_ctl -D ${PGDATA} -l ${PGDATA}/logfile start -w -t 120" || exit 1
|
||||
|
||||
# Ensure the test directory is writable by the postgres user for
|
||||
# regression output files (regression.out, regression.diffs, results/).
|
||||
chown -R postgres:postgres "${TESTDIR}"
|
||||
|
||||
# Prepare the tablespace test directory
|
||||
mkdir -p "${TESTDIR}/testtablespace"
|
||||
chmod 0700 "${TESTDIR}/testtablespace"
|
||||
chown postgres:postgres "${TESTDIR}/testtablespace"
|
||||
|
||||
# Disable set -e before the pipe so we can capture PIPESTATUS
|
||||
set +e
|
||||
|
||||
# Run the regression tests.
|
||||
# --dlpath points to the standard PostgreSQL package library directory
|
||||
# where regress.so and contrib modules (autoinc.so, refint.so, etc.)
|
||||
# are installed, so that CREATE FUNCTION ... AS tests can locate them.
|
||||
su - postgres -c "cd ${TESTDIR} && \
|
||||
${TESTDIR}/pg_regress \
|
||||
--inputdir=. \
|
||||
--bindir=${PGBIN} \
|
||||
--dlpath=${PKGLIBDIR} \
|
||||
--max-concurrent-tests=20 \
|
||||
--schedule=parallel_schedule" 2>&1 | \
|
||||
stdbuf -oL sed -n \
|
||||
-e 's/^ok [0-9]\+\s\+[+* ]\?\s*/PASS: /p' \
|
||||
-e 's/^not ok [0-9]\+\s\+[+* ]\?\s*/FAIL: /p'
|
||||
RESULT=${PIPESTATUS[0]}
|
||||
|
||||
if [ "${RESULT}" = "0" ]; then
|
||||
echo "PASS: all tests passed"
|
||||
else
|
||||
echo "FAIL: some tests failed"
|
||||
fi
|
||||
|
||||
exit ${RESULT}
|
||||
@ -29,6 +29,7 @@ SRC_URI = "https://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
|
||||
file://postgresql.pam \
|
||||
file://postgresql-setup \
|
||||
file://postgresql.service \
|
||||
file://run-ptest \
|
||||
"
|
||||
|
||||
LEAD_SONAME = "libpq.so"
|
||||
@ -37,7 +38,7 @@ LEAD_SONAME = "libpq.so"
|
||||
export LDFLAGS_SL = "${LDFLAGS}"
|
||||
export LDFLAGS_EX_BE = "-Wl,--export-dynamic"
|
||||
|
||||
inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header
|
||||
inherit autotools pkgconfig perlnative python3native python3targetconfig useradd update-rc.d systemd gettext perl-version multilib_header ptest
|
||||
|
||||
CFLAGS += "-I${STAGING_INCDIR}/${PYTHON_DIR}"
|
||||
|
||||
@ -184,6 +185,45 @@ do_compile:append() {
|
||||
done
|
||||
}
|
||||
|
||||
do_compile_ptest() {
|
||||
oe_runmake -C src/test/regress all
|
||||
}
|
||||
|
||||
do_install_ptest() {
|
||||
mkdir -p ${D}${PTEST_PATH}/test
|
||||
|
||||
# Install pg_regress binary
|
||||
install -m 0755 ${B}/src/test/regress/pg_regress ${D}${PTEST_PATH}/test/
|
||||
|
||||
# Install test schedules and resultmap
|
||||
for f in parallel_schedule serial_schedule resultmap; do
|
||||
[ -f ${S}/src/test/regress/$f ] && install -m 0644 ${S}/src/test/regress/$f ${D}${PTEST_PATH}/test/
|
||||
done
|
||||
|
||||
# Install SQL, expected, input, output, and data files
|
||||
for d in sql expected input output data; do
|
||||
if [ -d ${S}/src/test/regress/$d ]; then
|
||||
cp -r ${S}/src/test/regress/$d ${D}${PTEST_PATH}/test/
|
||||
fi
|
||||
done
|
||||
|
||||
# Install the regress test shared library into the standard PostgreSQL
|
||||
# package library directory (PKGLIBDIR) alongside contrib modules such
|
||||
# as autoinc.so and refint.so. This allows pg_regress --dlpath to
|
||||
# resolve all required shared libraries from a single location.
|
||||
install -d ${D}${libdir}/${BPN}
|
||||
install -m 0755 ${B}/src/test/regress/regress.so ${D}${libdir}/${BPN}/
|
||||
|
||||
# Install run-ptest
|
||||
install -m 0755 ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/
|
||||
|
||||
# Set ownership to postgres user for running tests
|
||||
chown -R postgres:postgres ${D}${PTEST_PATH}
|
||||
}
|
||||
|
||||
RDEPENDS:${PN}-ptest += "${PN}-client ${PN}-contrib perl"
|
||||
FILES:${PN}-ptest += "${libdir}/${BPN}/regress.so"
|
||||
|
||||
# server needs to configure user and group
|
||||
usernum = "28"
|
||||
groupnum = "28"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user