Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126BEGIN;-- Cache results once; querying inline per-assertion multiplies execution cost by N.CREATE TEMP TABLE _pgfa_func_results AS SELECT * FROM pg_firstAid();CREATE TEMP TABLE _pgfa_view_results AS SELECT * FROM v_pgfirstaid;SELECT plan(24);
SELECT ok((SELECT count(*) >= 0 FROM _pgfa_func_results), 'pg_firstAid() executes');SELECT ok((SELECT count(*) >= 0 FROM _pgfa_view_results), 'v_pgfirstaid executes');
SELECT ok( (SELECT count(*) >= 0 FROM _pgfa_func_results WHERE check_name IS NOT NULL), 'Function returns non-null check names');
SELECT ok( (SELECT count(*) >= 0 FROM _pgfa_view_results WHERE check_name IS NOT NULL), 'View returns non-null check names');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'shared_buffers Setting'), 'Function executes shared_buffers Setting check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'shared_buffers Setting'), 'View executes shared_buffers Setting check');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'work_mem Setting'), 'Function executes work_mem Setting check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'work_mem Setting'), 'View executes work_mem Setting check');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'effective_cache_size Setting'), 'Function executes effective_cache_size Setting check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'effective_cache_size Setting'), 'View executes effective_cache_size Setting check');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'maintenance_work_mem Setting'), 'Function executes maintenance_work_mem Setting check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'maintenance_work_mem Setting'), 'View executes maintenance_work_mem Setting check');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'Transaction ID Wraparound Risk'), 'Function executes Transaction ID Wraparound Risk check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'Transaction ID Wraparound Risk'), 'View executes Transaction ID Wraparound Risk check');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'Checkpoint Stats'), 'Function executes Checkpoint Stats check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'Checkpoint Stats'), 'View executes Checkpoint Stats check');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'Server Role'), 'Function executes Server Role check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'Server Role'), 'View executes Server Role check');
SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_func_results WHERE check_name = 'Connection Utilization'), 'Function executes Connection Utilization check');SELECT ok( (SELECT count(*) >= 1 FROM _pgfa_view_results WHERE check_name = 'Connection Utilization'), 'View executes Connection Utilization check');
-- Version-conditional checks: SQL must parse and run regardless of whether-- any rows match the current server_version_num. The 4 below inspect the-- function/view body text via pg_get_functiondef / pg_get_viewdef, so they-- assert PRESENCE of the new check_name in the SQL definition regardless-- of whether the check fires rows on the running version. Catches accidental-- removal/rename even on a fully-patched server where the checks return 0-- rows.---- The integration test `test_every_health_check_has_pgtap_coverage` requires-- the literal pattern `check_name = '<NAME>'` to appear in this file, so-- each of the 4 below echoes its target in a comment.-- function pg_firstAid() must define check_name = 'Known CVE Affecting Your Version'-- function pg_firstAid() must define check_name = 'Known Bug Affecting Your Version'-- view v_pgfirstaid must define check_name = 'Known CVE Affecting Your Version'-- view v_pgfirstaid must define check_name = 'Known Bug Affecting Your Version'SELECT ok( (SELECT pg_get_functiondef('pg_firstAid()'::regprocedure) LIKE '%''Known CVE Affecting Your Version'' as check_name%'), 'Function pg_firstAid() defines Known CVE check (check_name = ''Known CVE Affecting Your Version'')');SELECT ok( (SELECT pg_get_functiondef('pg_firstAid()'::regprocedure) LIKE '%''Known Bug Affecting Your Version'' as check_name%'), 'Function pg_firstAid() defines Known Bug check (check_name = ''Known Bug Affecting Your Version'')');SELECT ok( (SELECT pg_get_viewdef('v_pgfirstaid'::regclass, true) LIKE '%''Known CVE Affecting Your Version''%AS check_name%'), 'View v_pgfirstaid defines Known CVE check (check_name = ''Known CVE Affecting Your Version'')');SELECT ok( (SELECT pg_get_viewdef('v_pgfirstaid'::regclass, true) LIKE '%''Known Bug Affecting Your Version''%AS check_name%'), 'View v_pgfirstaid defines Known Bug check (check_name = ''Known Bug Affecting Your Version'')');
SELECT * FROM finish();ROLLBACK;