mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-22 13:33:23 +02:00
The five modules in our TAP test framework all had names in the top level namespace. This is unwise because, even though we're not exporting them to CPAN, the names can leak, for example if they are exported by the RPM build process. We therefore move the modules to the PostgreSQL::Test namespace. In the process PostgresNode is renamed to Cluster, and TestLib is renamed to Utils. PostgresVersion becomes simply PostgreSQL::Version, to avoid possible confusion about what it's the version of. Discussion: https://postgr.es/m/aede93a4-7d92-ef26-398f-5094944c2504@dunslane.net Reviewed by Erik Rijkers and Michael Paquier
56 lines
1.4 KiB
Perl
56 lines
1.4 KiB
Perl
|
|
# Copyright (c) 2021, PostgreSQL Global Development Group
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use PostgreSQL::Test::Cluster;
|
|
use PostgreSQL::Test::Utils;
|
|
use Test::More tests => 4;
|
|
|
|
my $node = PostgreSQL::Test::Cluster->new('main');
|
|
$node->init;
|
|
$node->append_conf('postgresql.conf',
|
|
"shared_preload_libraries = 'auto_explain'");
|
|
$node->append_conf('postgresql.conf', "auto_explain.log_min_duration = 0");
|
|
$node->append_conf('postgresql.conf', "auto_explain.log_analyze = on");
|
|
$node->start;
|
|
|
|
# run a couple of queries
|
|
$node->safe_psql("postgres", "SELECT * FROM pg_class;");
|
|
$node->safe_psql("postgres",
|
|
"SELECT * FROM pg_proc WHERE proname = 'int4pl';");
|
|
|
|
# emit some json too
|
|
$node->append_conf('postgresql.conf', "auto_explain.log_format = json");
|
|
$node->reload;
|
|
$node->safe_psql("postgres", "SELECT * FROM pg_proc;");
|
|
$node->safe_psql("postgres",
|
|
"SELECT * FROM pg_class WHERE relname = 'pg_class';");
|
|
|
|
$node->stop('fast');
|
|
|
|
my $log = $node->logfile();
|
|
|
|
my $log_contents = slurp_file($log);
|
|
|
|
like(
|
|
$log_contents,
|
|
qr/Seq Scan on pg_class/,
|
|
"sequential scan logged, text mode");
|
|
|
|
like(
|
|
$log_contents,
|
|
qr/Index Scan using pg_proc_proname_args_nsp_index on pg_proc/,
|
|
"index scan logged, text mode");
|
|
|
|
like(
|
|
$log_contents,
|
|
qr/"Node Type": "Seq Scan"[^}]*"Relation Name": "pg_proc"/s,
|
|
"sequential scan logged, json mode");
|
|
|
|
like(
|
|
$log_contents,
|
|
qr/"Node Type": "Index Scan"[^}]*"Index Name": "pg_class_relname_nsp_index"/s,
|
|
"index scan logged, json mode");
|