timescaledb/test/test-defs.cmake
Alexander Kuzmenkov d93aa5c8c1
Log internal program errors to CI database (#6598)
SQLSmith finds many internal program errors (`elog`, code `XX000`).
Normally these errors shouldn't be triggered by user actions and
indicate a bug in the program (like `variable not found in subplan
targetlist`). We don't have a capacity to fix all of them currently,
especially since some of them seem to be the upstream ones. This commit
adds logging for these errors so that we at least can study the current
situation.
2024-02-09 13:28:54 +01:00

173 lines
6.3 KiB
CMake

set(TEST_ROLE_SUPERUSER super_user)
set(TEST_ROLE_CLUSTER_SUPERUSER cluster_super_user)
set(TEST_ROLE_DEFAULT_PERM_USER default_perm_user)
set(TEST_ROLE_DEFAULT_PERM_USER_2 default_perm_user_2)
set(TEST_ROLE_1 test_role_1)
set(TEST_ROLE_2 test_role_2)
set(TEST_ROLE_3 test_role_3)
set(TEST_ROLE_4 test_role_4)
set(TEST_ROLE_READ_ONLY test_role_read_only)
# TEST_ROLE_2 has password in passfile
set(TEST_ROLE_2_PASS pass)
# TEST_ROLE_3 does not have password in passfile
set(TEST_ROLE_3_PASS pass)
# TEST_ROLE_4 does not have password in passfile
set(TEST_ROLE_4_PASS pass)
set(TEST_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(TEST_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(TEST_CLUSTER ${TEST_OUTPUT_DIR}/testcluster)
# Basic connection info for test instance
set(TEST_PGPORT_LOCAL
5432
CACHE STRING "The port of a running PostgreSQL instance")
set(TEST_PGHOST
localhost
CACHE STRING "The hostname of a running PostgreSQL instance")
set(TEST_PGUSER
${TEST_ROLE_DEFAULT_PERM_USER}
CACHE STRING "The PostgreSQL test user")
set(TEST_DBNAME
single
CACHE STRING "The database name to use for tests")
set(TEST_PGPORT_TEMP_INSTANCE
55432
CACHE STRING "The port to run a temporary test PostgreSQL instance on")
set(TEST_SCHEDULE ${CMAKE_CURRENT_BINARY_DIR}/test_schedule)
set(TEST_SCHEDULE_SHARED
${CMAKE_CURRENT_BINARY_DIR}/shared/test_schedule_shared)
set(ISOLATION_TEST_SCHEDULE ${CMAKE_CURRENT_BINARY_DIR}/isolation_test_schedule)
set(TEST_PASSFILE ${TEST_OUTPUT_DIR}/pgpass.conf)
# Windows does not support local connections (unix domain sockets)
if(WIN32)
set(TEST_HBA_LOCAL "#local")
else()
set(TEST_HBA_LOCAL "local")
endif()
configure_file(${PRIMARY_TEST_DIR}/pg_hba.conf.in pg_hba.conf)
set(TEST_PG_HBA_FILE ${TEST_OUTPUT_DIR}/pg_hba.conf)
# Enable json logs that are supported since PG15, to get additional information
# about errors from them for CI database.
if(PG_VERSION_MAJOR LESS 15)
set(TEST_PG_LOG_DESTINATION stderr)
else()
set(TEST_PG_LOG_DESTINATION jsonlog,stderr)
endif()
# This variable is set differently in CI. We use it to save the logs outside the
# tmp instance, because it is deleted by pg_regress on successful test
# completion, and we want to run some additional checks on the logs in any case.
option(TEST_PG_LOG_DIRECTORY "Log directory for regression tests" "log")
if(USE_TELEMETRY)
set(TELEMETRY_DEFAULT_SETTING "timescaledb.telemetry_level=off")
else()
set(TELEMETRY_DEFAULT_SETTING)
endif()
configure_file(postgresql.conf.in postgresql.conf)
configure_file(${PRIMARY_TEST_DIR}/pgtest.conf.in pgtest.conf)
# pgpass file requires chmod 0600
configure_file(${PRIMARY_TEST_DIR}/pgpass.conf.in
${TEST_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/pgpass.conf)
file(
COPY ${TEST_OUTPUT_DIR}${CMAKE_FILES_DIRECTORY}/pgpass.conf
DESTINATION ${TEST_OUTPUT_DIR}
NO_SOURCE_PERMISSIONS
FILE_PERMISSIONS OWNER_READ OWNER_WRITE)
set(PG_REGRESS_OPTS_BASE --host=${TEST_PGHOST}
--dlpath=${PROJECT_BINARY_DIR}/src)
set(PG_REGRESS_OPTS_EXTRA
--create-role=${TEST_ROLE_SUPERUSER},${TEST_ROLE_DEFAULT_PERM_USER},${TEST_ROLE_DEFAULT_PERM_USER_2},${TEST_ROLE_CLUSTER_SUPERUSER},${TEST_ROLE_1},${TEST_ROLE_2},${TEST_ROLE_3},${TEST_ROLE_4},${TEST_ROLE_READ_ONLY}
--dbname=${TEST_DBNAME}
--launcher=${PRIMARY_TEST_DIR}/runner.sh)
set(PG_REGRESS_SHARED_OPTS_EXTRA
--create-role=${TEST_ROLE_SUPERUSER},${TEST_ROLE_DEFAULT_PERM_USER},${TEST_ROLE_DEFAULT_PERM_USER_2}
--dbname=${TEST_DBNAME}
--launcher=${PRIMARY_TEST_DIR}/runner_shared.sh)
set(PG_ISOLATION_REGRESS_OPTS_EXTRA
--create-role=${TEST_ROLE_SUPERUSER},${TEST_ROLE_DEFAULT_PERM_USER},${TEST_ROLE_DEFAULT_PERM_USER_2},${TEST_ROLE_CLUSTER_SUPERUSER},${TEST_ROLE_1},${TEST_ROLE_2},${TEST_ROLE_3},${TEST_ROLE_READ_ONLY}
--dbname=${TEST_DBNAME}
--launcher=${PRIMARY_TEST_DIR}/runner_isolation.sh)
set(PG_REGRESS_OPTS_INOUT --inputdir=${TEST_INPUT_DIR}
--outputdir=${TEST_OUTPUT_DIR})
set(PG_REGRESS_SHARED_OPTS_INOUT
--inputdir=${TEST_INPUT_DIR}/shared --outputdir=${TEST_OUTPUT_DIR}/shared
--load-extension=timescaledb)
set(PG_ISOLATION_REGRESS_OPTS_INOUT
--inputdir=${TEST_INPUT_DIR}/isolation
--outputdir=${TEST_OUTPUT_DIR}/isolation --load-extension=timescaledb)
set(PG_REGRESS_OPTS_TEMP_INSTANCE
--port=${TEST_PGPORT_TEMP_INSTANCE} --temp-instance=${TEST_CLUSTER}
--temp-config=${TEST_OUTPUT_DIR}/postgresql.conf)
set(PG_REGRESS_OPTS_TEMP_INSTANCE_PGTEST
--port=${TEST_PGPORT_TEMP_INSTANCE} --temp-instance=${TEST_CLUSTER}
--temp-config=${TEST_OUTPUT_DIR}/pgtest.conf)
set(PG_REGRESS_OPTS_LOCAL_INSTANCE --port=${TEST_PGPORT_LOCAL})
if(PG_REGRESS)
set(PG_REGRESS_ENV
TEST_PGUSER=${TEST_PGUSER}
TEST_PGHOST=${TEST_PGHOST}
TEST_ROLE_SUPERUSER=${TEST_ROLE_SUPERUSER}
TEST_ROLE_DEFAULT_PERM_USER=${TEST_ROLE_DEFAULT_PERM_USER}
TEST_ROLE_DEFAULT_PERM_USER_2=${TEST_ROLE_DEFAULT_PERM_USER_2}
TEST_ROLE_CLUSTER_SUPERUSER=${TEST_ROLE_CLUSTER_SUPERUSER}
TEST_ROLE_1=${TEST_ROLE_1}
TEST_ROLE_2=${TEST_ROLE_2}
TEST_ROLE_3=${TEST_ROLE_3}
TEST_ROLE_READ_ONLY=${TEST_ROLE_READ_ONLY}
TEST_ROLE_2_PASS=${TEST_ROLE_2_PASS}
TEST_ROLE_3_PASS=${TEST_ROLE_3_PASS}
TEST_ROLE_4_PASS=${TEST_ROLE_4_PASS}
TEST_DBNAME=${TEST_DBNAME}
TEST_INPUT_DIR=${TEST_INPUT_DIR}
TEST_OUTPUT_DIR=${TEST_OUTPUT_DIR}
TEST_SCHEDULE=${TEST_SCHEDULE}
PG_BINDIR=${PG_BINDIR}
PG_REGRESS=${PG_REGRESS})
endif()
if(PG_ISOLATION_REGRESS)
set(PG_ISOLATION_REGRESS_ENV
TEST_PGUSER=${TEST_PGUSER}
TEST_ROLE_SUPERUSER=${TEST_ROLE_SUPERUSER}
TEST_ROLE_DEFAULT_PERM_USER=${TEST_ROLE_DEFAULT_PERM_USER}
TEST_ROLE_DEFAULT_PERM_USER_2=${TEST_ROLE_DEFAULT_PERM_USER_2}
TEST_ROLE_CLUSTER_SUPERUSER=${TEST_ROLE_CLUSTER_SUPERUSER}
TEST_ROLE_1=${TEST_ROLE_1}
TEST_ROLE_2=${TEST_ROLE_2}
TEST_ROLE_3=${TEST_ROLE_3}
TEST_ROLE_2_PASS=${TEST_2_PASS}
TEST_ROLE_3_PASS=${TEST_3_PASS}
TEST_ROLE_READ_ONLY=${TEST_ROLE_READ_ONLY}
TEST_DBNAME=${TEST_DBNAME}
TEST_INPUT_DIR=${TEST_INPUT_DIR}
TEST_OUTPUT_DIR=${TEST_OUTPUT_DIR}
TEST_SCHEDULE=${ISOLATION_TEST_SCHEDULE}
PG_REGRESS=${PG_ISOLATION_REGRESS})
endif()
set(TEST_VERSION_SUFFIX ${PG_VERSION_MAJOR})
if(APACHE_ONLY)
set(TEST_LICENSE_SUFFIX "oss")
else()
set(TEST_LICENSE_SUFFIX "tsl")
endif()