From 80304f40d1ee135d454dbc222d4098e09fe0a20f Mon Sep 17 00:00:00 2001 From: James Campbell Date: Sun, 1 Jun 2025 00:11:44 -0400 Subject: [PATCH] Revise the versions on a few queries, improve query tests * Add ability to specify the sslmode parameter when connecting to PostgreSQL * Fix min versions for replication queries * Add query-tests target to main Makefile --- Makefile | 13 +++++++++++-- sample-config/pgmon-metrics.yml | 10 +++++----- tests/docker-compose.yml | 2 +- tests/test-config.yml | 5 +++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 8f98594..7606715 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ SUPPORTED := ubuntu-20.04 \ # These targets are the main ones to use for most things. ## -.PHONY: all clean tgz test install +.PHONY: all clean tgz test query-tests install # Build all packages @@ -64,6 +64,10 @@ clean: test: cd src ; python3 -m unittest +# Run query tests +query-tests: + cd tests ; ./run-tests.sh + # Install the script at the specified base directory install: # Set up directories @@ -92,7 +96,7 @@ install: # Run all of the install tests -.PHONY: install-tests debian-%-install-test rockylinux-%-install-test ubuntu-%-install-test +.PHONY: install-tests debian-%-install-test rockylinux-%-install-test ubuntu-%-install-test gentoo-install-test install-tests: $(foreach distro_release, $(SUPPORTED), $(distro_release)-install-test) @@ -124,6 +128,11 @@ oraclelinux-%-install-test: oraclelinux:7 \ bash -c 'yum makecache && yum install -y /output/$(PACKAGE_NAME)-$(VERSION)-1.el7.noarch.rpm' +# Run a Gentoo install test +gentoo-install-test: + # May impliment this in the future, but would require additional headaches to set up a repo + true + ## # Container targets # diff --git a/sample-config/pgmon-metrics.yml b/sample-config/pgmon-metrics.yml index 6bb7753..60e428e 100644 --- a/sample-config/pgmon-metrics.yml +++ b/sample-config/pgmon-metrics.yml @@ -11,7 +11,7 @@ metrics: discover_slots: type: set query: - 0: SELECT slot_name, plugin, slot_type, database, false as temporary, active FROM pg_replication_slots + 90400: SELECT slot_name, plugin, slot_type, database, false as temporary, active FROM pg_replication_slots 100000: SELECT slot_name, plugin, slot_type, database, temporary, active FROM pg_replication_slots # cluster-wide metrics @@ -20,9 +20,9 @@ metrics: query: 0: SHOW server_version_num max_frozen_age: - type: value + type: row query: - 0: SELECT max(age(datfrozenxid)) FROM pg_database + 0: SELECT max(age(datfrozenxid)), max(mxid_age(datminmxid)) FROM pg_database # Per-database metrics db_stats: @@ -43,7 +43,7 @@ metrics: rep_stats: type: row query: - 0: SELECT * FROM pg_stat_replication WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}' + 90400: SELECT * FROM pg_stat_replication WHERE client_addr || '_' || regexp_replace(application_name, '[ ,]', '_', 'g') = '{repid}' test_args: repid: 127.0.0.1_test_rep @@ -57,7 +57,7 @@ metrics: slot_stats: type: row query: - 0: SELECT active_pid, xmin, pg_xlog_location_diff(pg_current_xlog_location(), restart_lsn) AS restart_bytes, pg_xlog_location_diff(pg_current_xlog_location(), confirmed_flush_lsn) AS confirmed_flush_bytes FROM pg_replication_slots WHERE slot_name = '{slot}' + 90400: SELECT active_pid, xmin, pg_xlog_location_diff(pg_current_xlog_location(), restart_lsn) AS restart_bytes, pg_xlog_location_diff(pg_current_xlog_location(), confirmed_flush_lsn) AS confirmed_flush_bytes FROM pg_replication_slots WHERE slot_name = '{slot}' 100000: SELECT active_pid, xmin, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) AS restart_bytes, pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn) AS confirmed_flush_bytes FROM pg_replication_slots WHERE slot_name = '{slot}' test_args: slot: test_slot diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index deeecd2..ae9b5f6 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -23,7 +23,7 @@ services: test: [ "CMD-SHELL", "pg_controldata /var/lib/postgresql/data/ | grep -q 'in production'" ] interval: 5s timeout: 2s - retries: 10 + retries: 20 command: > postgres -c ssl=on -c ssl_cert_file='/etc/ssl/certs/ssl-cert-snakeoil.pem' diff --git a/tests/test-config.yml b/tests/test-config.yml index 8bf863b..7a17cdb 100644 --- a/tests/test-config.yml +++ b/tests/test-config.yml @@ -8,8 +8,9 @@ dbhost: db dbport: 5432 dbuser: postgres -# Allow some insecure SSL parameters for the 9.2 test -ssl_ciphers: DEFAULT@SECLEVEL=1 +# The SSL cipher parameters are too old in the 9.2 container, so we allow the tests +# to be run without encryption +ssl_mode: prefer # Pull in the standard metrics include: