Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q5Zdw-0003u6-Bk for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Jun 2023 22:22:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q5Zcw-0005y4-Tj for pgsql-hackers@arkaria.postgresql.org; Sat, 03 Jun 2023 22:21:38 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q5Zcw-0005xv-44 for pgsql-hackers@lists.postgresql.org; Sat, 03 Jun 2023 22:21:38 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q5Zco-0002f9-Gr for pgsql-hackers@lists.postgresql.org; Sat, 03 Jun 2023 22:21:36 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 78DBD5C00A0; Sat, 3 Jun 2023 18:21:29 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sat, 03 Jun 2023 18:21:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1685830889; x=1685917289; bh=uS x8qfYKIjm6uPFz5L2l/YQy+m0Wqzf59RDgteiBtC4=; b=rH8dxmrRTZ0PKuyPW2 hWA/PHqkG4LBAaGZRmQJxcJ+CKDOflk7DqRSV+4+HOl5bxrtIdrUZ9lSTWab3llQ jlEObc+aC8NR1I+bt0nRedLADlgmHT82BWWDpuk5i9sG0GeqddCMhMiXYMUTpepB cvptoX+8xabsPCnpdeQ36MSte7EXV7skUWFgUwGahViBZDkNRT1xp7xB0A0nB2Pn R9VXIPH6K5fW21VEAGxdWSq3y7YVr69d5++dNo1yxrq4kteDEfxLQHmZiG87gkMF Z1jg9xA1LO71+R1dcVVkVuq9EMJFmLJDnqhW1b6pk8pijyJjhbPESmir+TNCeJtk cgDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1685830889; x=1685917289; bh=uSx8qfYKIjm6u PFz5L2l/YQy+m0Wqzf59RDgteiBtC4=; b=H+4wC68OB6Hcm4OavA7MGUKwdDNve vU/a3/hUEO1i8sTg4KC3KzgC4mFv+4WEaTcupbsgpXYzaMyOo5P1w3pqTFEWKCon SXAoOL2JwHZaIEeYtvvhkqmpD8Antlev4Kk7ZGG0popqHRPbPBd1oPUHMceJl3hH LJq7UzZFeoVItilStOnAmqPNdEl5L3+s3qZsU5HdnhlHH4yxB0ycAjs+BcyytLIu 1TMw4RJzZB/lU3bPw/OUeu5vorAgwLYM/VMcuj3T2I/lbGNtvHpLMjnAOmveEolD CgvB6pyAVbL7oZD9MIY/I1RMIAYdyjcV1J6ypsTDdM0RBmd+aCTNkkeZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeeliedguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 3 Jun 2023 18:21:28 -0400 (EDT) Date: Sat, 3 Jun 2023 18:21:27 -0400 From: Michael Paquier To: vignesh C Cc: Andrew Dunstan , Dagfinn Ilmari =?iso-8859-1?Q?Manns=E5ker?= , PostgreSQL Hackers Subject: Re: Implement generalized sub routine find_in_log for tap test Message-ID: References: <87cz2otiw3.fsf@wibble.ilmari.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r6ttGjIR2jTIgOvS" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --r6ttGjIR2jTIgOvS Content-Type: multipart/mixed; boundary="mIFOvauHbu/ZGCjk" Content-Disposition: inline --mIFOvauHbu/ZGCjk Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, May 29, 2023 at 07:49:52AM +0530, vignesh C wrote: > Thanks for the comment, the attached v3 version patch has the changes > for the same. -if (find_in_log( - $node, $log_offset, - qr/peer authentication is not supported on this platform/)) +if ($node->log_contains( + qr/peer authentication is not supported on this platform/), + $log_offset,) This looks like a typo to me, the log offset is eaten. Except of that, I am on board with log_contains(). There are two things that bugged me with the refactoring related to connect_ok and connect_fails: - check_connect_log_contents() is a name too complicated. While looking at that I have settled to a simpler log_check(), as we could perfectly use that for something else than connections as long as we want to check multiple patterns at once. - The refactoring of the documentation for the routines of Cluster.pm became incorrect. For example, the patch does not list anymore log_like and log_unlike for connect_ok. With all that in mind I have hacked a few adjustments in a 0003, though I agree with the separation between 0001 and 0002. 033_replay_tsp_drops and 019_replslot_limit are not new to v16, but 003_peer.pl and 035_standby_logical_decoding.pl, making the number of places where find_in_log() exists twice as much. So I would be tempted to refactor these tests in v16. Perhaps anybody from the RMT could comment? We've usually been quite flexible with the tests even in beta. Thoughts? -- Michael --mIFOvauHbu/ZGCjk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v4-0001-Remove-duplicate-find_in_log-sub-routines-from-ta.patch" Content-Transfer-Encoding: quoted-printable =46rom 49473ab523adf43e82fe71d7e33be478287ad2c8 Mon Sep 17 00:00:00 2001 =46rom: Vignesh C Date: Fri, 26 May 2023 20:07:30 +0530 Subject: [PATCH v4 1/3] Remove duplicate find_in_log sub routines from tap tests. Remove duplicate find_in_log sub routines from tap tests. --- src/test/authentication/t/003_peer.pl | 17 ++-------- src/test/perl/PostgreSQL/Test/Cluster.pm | 15 +++++++++ src/test/recovery/t/019_replslot_limit.pl | 33 +++++-------------- src/test/recovery/t/033_replay_tsp_drops.pl | 15 ++------- .../t/035_standby_logical_decoding.pl | 26 +++------------ 5 files changed, 32 insertions(+), 74 deletions(-) diff --git a/src/test/authentication/t/003_peer.pl b/src/test/authenticatio= n/t/003_peer.pl index 3272e52cae..2a035c2d0d 100644 --- a/src/test/authentication/t/003_peer.pl +++ b/src/test/authentication/t/003_peer.pl @@ -69,17 +69,6 @@ sub test_role } } =20 -# Find $pattern in log file of $node. -sub find_in_log -{ - my ($node, $offset, $pattern) =3D @_; - - my $log =3D PostgreSQL::Test::Utils::slurp_file($node->logfile, $offset); - return 0 if (length($log) <=3D 0); - - return $log =3D~ m/$pattern/; -} - my $node =3D PostgreSQL::Test::Cluster->new('node'); $node->init; $node->append_conf('postgresql.conf', "log_connections =3D on\n"); @@ -91,9 +80,9 @@ reset_pg_hba($node, 'peer'); # Check if peer authentication is supported on this platform. my $log_offset =3D -s $node->logfile; $node->psql('postgres'); -if (find_in_log( - $node, $log_offset, - qr/peer authentication is not supported on this platform/)) +if ($node->log_contains( + qr/peer authentication is not supported on this platform/), + $log_offset,) { plan skip_all =3D> 'peer authentication is not supported on this platform= '; } diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/Postg= reSQL/Test/Cluster.pm index baea0fcd1c..4df7dd4dec 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -2536,6 +2536,21 @@ sub log_content } =20 =20 +=3Dpod + +=3Ditem log_contains(pattern, offset) + +Find pattern in logfile of node after offset byte. + +=3Dcut + +sub log_contains +{ + my ($self, $pattern, $offset) =3D @_; + + return PostgreSQL::Test::Utils::slurp_file($self->logfile, $offset) =3D~ = m/$pattern/; +} + =3Dpod =20 =3Ditem $node->run_log(...) diff --git a/src/test/recovery/t/019_replslot_limit.pl b/src/test/recovery/= t/019_replslot_limit.pl index a1aba16e14..95acf9e357 100644 --- a/src/test/recovery/t/019_replslot_limit.pl +++ b/src/test/recovery/t/019_replslot_limit.pl @@ -161,8 +161,7 @@ $node_primary->wait_for_catchup($node_standby); =20 $node_standby->stop; =20 -ok( !find_in_log( - $node_standby, +ok( !$node_standby->log_contains( "requested WAL segment [0-9A-F]+ has already been removed"), 'check that required WAL segments are still available'); =20 @@ -184,8 +183,8 @@ $node_primary->safe_psql('postgres', "CHECKPOINT;"); my $invalidated =3D 0; for (my $i =3D 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i+= +) { - if (find_in_log( - $node_primary, 'invalidating obsolete replication slot "rep1"', + if ($node_primary->log_contains( + 'invalidating obsolete replication slot "rep1"', $logstart)) { $invalidated =3D 1; @@ -207,7 +206,7 @@ is($result, "rep1|f|t|lost|", my $checkpoint_ended =3D 0; for (my $i =3D 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i+= +) { - if (find_in_log($node_primary, "checkpoint complete: ", $logstart)) + if ($node_primary->log_contains("checkpoint complete: ", $logstart)) { $checkpoint_ended =3D 1; last; @@ -237,8 +236,7 @@ $node_standby->start; my $failed =3D 0; for (my $i =3D 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i+= +) { - if (find_in_log( - $node_standby, + if ($node_standby->log_contains( "requested WAL segment [0-9A-F]+ has already been removed", $logstart)) { @@ -381,8 +379,7 @@ my $msg_logged =3D 0; my $max_attempts =3D $PostgreSQL::Test::Utils::timeout_default; while ($max_attempts-- >=3D 0) { - if (find_in_log( - $node_primary3, + if ($node_primary3->log_contains( "terminating process $senderpid to release replication slot \"rep3\"", $logstart)) { @@ -406,8 +403,8 @@ $msg_logged =3D 0; $max_attempts =3D $PostgreSQL::Test::Utils::timeout_default; while ($max_attempts-- >=3D 0) { - if (find_in_log( - $node_primary3, 'invalidating obsolete replication slot "rep3"', + if ($node_primary3->log_contains( + 'invalidating obsolete replication slot "rep3"', $logstart)) { $msg_logged =3D 1; @@ -446,18 +443,4 @@ sub get_log_size return (stat $node->logfile)[7]; } =20 -# find $pat in logfile of $node after $off-th byte -sub find_in_log -{ - my ($node, $pat, $off) =3D @_; - - $off =3D 0 unless defined $off; - my $log =3D PostgreSQL::Test::Utils::slurp_file($node->logfile); - return 0 if (length($log) <=3D $off); - - $log =3D substr($log, $off); - - return $log =3D~ m/$pat/; -} - done_testing(); diff --git a/src/test/recovery/t/033_replay_tsp_drops.pl b/src/test/recover= y/t/033_replay_tsp_drops.pl index 0a35a7bda6..307c30bc6b 100644 --- a/src/test/recovery/t/033_replay_tsp_drops.pl +++ b/src/test/recovery/t/033_replay_tsp_drops.pl @@ -135,22 +135,11 @@ while ($max_attempts-- >=3D 0) { last if ( - find_in_log( - $node_standby, + $node_standby->log_contains( qr!WARNING: ( [A-Z0-9]+:)? creating missing directory: pg_tblspc/!, $logstart)); usleep(100_000); } ok($max_attempts > 0, "invalid directory creation is detected"); =20 -done_testing(); - -# find $pat in logfile of $node after $off-th byte -sub find_in_log -{ - my ($node, $pat, $off) =3D @_; - - my $log =3D PostgreSQL::Test::Utils::slurp_file($node->logfile, $off); - - return $log =3D~ m/$pat/; -} +done_testing(); \ No newline at end of file diff --git a/src/test/recovery/t/035_standby_logical_decoding.pl b/src/test= /recovery/t/035_standby_logical_decoding.pl index 64beec4bd3..480e6d6caa 100644 --- a/src/test/recovery/t/035_standby_logical_decoding.pl +++ b/src/test/recovery/t/035_standby_logical_decoding.pl @@ -28,20 +28,6 @@ my $res; my $primary_slotname =3D 'primary_physical'; my $standby_physical_slotname =3D 'standby_physical'; =20 -# find $pat in logfile of $node after $off-th byte -sub find_in_log -{ - my ($node, $pat, $off) =3D @_; - - $off =3D 0 unless defined $off; - my $log =3D PostgreSQL::Test::Utils::slurp_file($node->logfile); - return 0 if (length($log) <=3D $off); - - $log =3D substr($log, $off); - - return $log =3D~ m/$pat/; -} - # Fetch xmin columns from slot's pg_replication_slots row, after waiting f= or # given boolean condition to be true to ensure we've reached a quiescent s= tate. sub wait_for_xmins @@ -235,14 +221,12 @@ sub check_for_invalidation my $inactive_slot =3D $slot_prefix . 'inactiveslot'; =20 # message should be issued - ok( find_in_log( - $node_standby, + ok( $node_standby->log_contains( "invalidating obsolete replication slot \"$inactive_slot\"", $log_start), "inactiveslot slot invalidation is logged $test_name"); =20 - ok( find_in_log( - $node_standby, + ok( $node_standby->log_contains( "invalidating obsolete replication slot \"$active_slot\"", $log_start), "activeslot slot invalidation is logged $test_name"); @@ -657,14 +641,12 @@ $node_primary->safe_psql( $node_primary->wait_for_replay_catchup($node_standby); =20 # message should not be issued -ok( !find_in_log( - $node_standby, +ok( !$node_standby->log_contains( "invalidating obsolete slot \"no_conflict_inactiveslot\"", $logstart), 'inactiveslot slot invalidation is not logged with vacuum on conflict_tes= t' ); =20 -ok( !find_in_log( - $node_standby, +ok( !$node_standby->log_contains( "invalidating obsolete slot \"no_conflict_activeslot\"", $logstart), 'activeslot slot invalidation is not logged with vacuum on conflict_test' ); --=20 2.40.1 --mIFOvauHbu/ZGCjk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v4-0002-Move-common-connection-log-content-verification-c.patch" Content-Transfer-Encoding: quoted-printable =46rom 966ea0c337a187522bcabc877214761d9818b58a Mon Sep 17 00:00:00 2001 =46rom: Vignesh C Date: Sat, 27 May 2023 05:36:34 +0530 Subject: [PATCH v4 2/3] Move common connection log content verification code to a common function. Move common connection log content verification code to a common function. --- src/test/perl/PostgreSQL/Test/Cluster.pm | 130 +++++++++++------------ 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/Postg= reSQL/Test/Cluster.pm index 4df7dd4dec..912892e28b 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -2168,6 +2168,68 @@ sub pgbench =20 =3Dpod =20 +=3Ditem $node->check_connect_log_contents($offset, $test_name, %parameters) + +Check connection log contents. + +=3Dover + +=3Ditem $test_name + +Name of test for error messages. + +=3Ditem $offset + +Offset of the log file. + +=3Ditem log_like =3D> [ qr/required message/ ] + +If given, it must be an array reference containing a list of regular +expressions that must match against the server log, using +C. + +=3Ditem log_unlike =3D> [ qr/prohibited message/ ] + +If given, it must be an array reference containing a list of regular +expressions that must NOT match against the server log. They will be +passed to C. + +=3Dback + +=3Dcut + +sub check_connect_log_contents +{ + my ($self, $test_name, $offset, %params) =3D @_; + + my (@log_like, @log_unlike); + if (defined($params{log_like})) + { + @log_like =3D @{ $params{log_like} }; + } + if (defined($params{log_unlike})) + { + @log_unlike =3D @{ $params{log_unlike} }; + } + + if (@log_like or @log_unlike) + { + my $log_contents =3D + PostgreSQL::Test::Utils::slurp_file($self->logfile, $offset); + + while (my $regex =3D shift @log_like) + { + like($log_contents, $regex, "$test_name: log matches"); + } + while (my $regex =3D shift @log_unlike) + { + unlike($log_contents, $regex, "$test_name: log does not match"); + } + } +} + +=3Dpod + =3Ditem $node->connect_ok($connstr, $test_name, %params) =20 Attempt a connection with a custom connection string. This is expected @@ -2184,18 +2246,6 @@ instead of the default. =20 If this regular expression is set, matches it with the output generated. =20 -=3Ditem log_like =3D> [ qr/required message/ ] - -If given, it must be an array reference containing a list of regular -expressions that must match against the server log, using -C. - -=3Ditem log_unlike =3D> [ qr/prohibited message/ ] - -If given, it must be an array reference containing a list of regular -expressions that must NOT match against the server log. They will be -passed to C. - =3Dback =20 =3Dcut @@ -2215,16 +2265,6 @@ sub connect_ok $sql =3D "SELECT \$\$connected with $connstr\$\$"; } =20 - my (@log_like, @log_unlike); - if (defined($params{log_like})) - { - @log_like =3D @{ $params{log_like} }; - } - if (defined($params{log_unlike})) - { - @log_unlike =3D @{ $params{log_unlike} }; - } - my $log_location =3D -s $self->logfile; =20 # Never prompt for a password, any callers of this routine should @@ -2245,20 +2285,7 @@ sub connect_ok =20 is($stderr, "", "$test_name: no stderr"); =20 - if (@log_like or @log_unlike) - { - my $log_contents =3D - PostgreSQL::Test::Utils::slurp_file($self->logfile, $log_location); - - while (my $regex =3D shift @log_like) - { - like($log_contents, $regex, "$test_name: log matches"); - } - while (my $regex =3D shift @log_unlike) - { - unlike($log_contents, $regex, "$test_name: log does not match"); - } - } + $self->check_connect_log_contents($test_name, $log_location, %params); } =20 =3Dpod @@ -2274,12 +2301,6 @@ to fail. =20 If this regular expression is set, matches it with the output generated. =20 -=3Ditem log_like =3D> [ qr/required message/ ] - -=3Ditem log_unlike =3D> [ qr/prohibited message/ ] - -See C, above. - =3Dback =20 =3Dcut @@ -2289,16 +2310,6 @@ sub connect_fails local $Test::Builder::Level =3D $Test::Builder::Level + 1; my ($self, $connstr, $test_name, %params) =3D @_; =20 - my (@log_like, @log_unlike); - if (defined($params{log_like})) - { - @log_like =3D @{ $params{log_like} }; - } - if (defined($params{log_unlike})) - { - @log_unlike =3D @{ $params{log_unlike} }; - } - my $log_location =3D -s $self->logfile; =20 # Never prompt for a password, any callers of this routine should @@ -2316,20 +2327,7 @@ sub connect_fails like($stderr, $params{expected_stderr}, "$test_name: matches"); } =20 - if (@log_like or @log_unlike) - { - my $log_contents =3D - PostgreSQL::Test::Utils::slurp_file($self->logfile, $log_location); - - while (my $regex =3D shift @log_like) - { - like($log_contents, $regex, "$test_name: log matches"); - } - while (my $regex =3D shift @log_unlike) - { - unlike($log_contents, $regex, "$test_name: log does not match"); - } - } + $self->check_connect_log_contents($test_name, $log_location, %params); } =20 =3Dpod --=20 2.40.1 --mIFOvauHbu/ZGCjk Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v4-0003-Adjust-a-bit-previous-patches.patch" Content-Transfer-Encoding: quoted-printable =46rom fce041c5223d14b8bc654461e344f098df95c52a Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier Date: Sat, 3 Jun 2023 18:15:42 -0400 Subject: [PATCH v4 3/3] Adjust a bit previous patches ;) --- src/test/authentication/t/003_peer.pl | 4 +- src/test/perl/PostgreSQL/Test/Cluster.pm | 139 +++++++++++--------- src/test/recovery/t/033_replay_tsp_drops.pl | 2 +- 3 files changed, 78 insertions(+), 67 deletions(-) diff --git a/src/test/authentication/t/003_peer.pl b/src/test/authenticatio= n/t/003_peer.pl index 2a035c2d0d..d8e4976072 100644 --- a/src/test/authentication/t/003_peer.pl +++ b/src/test/authentication/t/003_peer.pl @@ -81,8 +81,8 @@ reset_pg_hba($node, 'peer'); my $log_offset =3D -s $node->logfile; $node->psql('postgres'); if ($node->log_contains( - qr/peer authentication is not supported on this platform/), - $log_offset,) + qr/peer authentication is not supported on this platform/, + $log_offset)) { plan skip_all =3D> 'peer authentication is not supported on this platform= '; } diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/Postg= reSQL/Test/Cluster.pm index 912892e28b..19cbc46390 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -2168,68 +2168,6 @@ sub pgbench =20 =3Dpod =20 -=3Ditem $node->check_connect_log_contents($offset, $test_name, %parameters) - -Check connection log contents. - -=3Dover - -=3Ditem $test_name - -Name of test for error messages. - -=3Ditem $offset - -Offset of the log file. - -=3Ditem log_like =3D> [ qr/required message/ ] - -If given, it must be an array reference containing a list of regular -expressions that must match against the server log, using -C. - -=3Ditem log_unlike =3D> [ qr/prohibited message/ ] - -If given, it must be an array reference containing a list of regular -expressions that must NOT match against the server log. They will be -passed to C. - -=3Dback - -=3Dcut - -sub check_connect_log_contents -{ - my ($self, $test_name, $offset, %params) =3D @_; - - my (@log_like, @log_unlike); - if (defined($params{log_like})) - { - @log_like =3D @{ $params{log_like} }; - } - if (defined($params{log_unlike})) - { - @log_unlike =3D @{ $params{log_unlike} }; - } - - if (@log_like or @log_unlike) - { - my $log_contents =3D - PostgreSQL::Test::Utils::slurp_file($self->logfile, $offset); - - while (my $regex =3D shift @log_like) - { - like($log_contents, $regex, "$test_name: log matches"); - } - while (my $regex =3D shift @log_unlike) - { - unlike($log_contents, $regex, "$test_name: log does not match"); - } - } -} - -=3Dpod - =3Ditem $node->connect_ok($connstr, $test_name, %params) =20 Attempt a connection with a custom connection string. This is expected @@ -2246,6 +2184,12 @@ instead of the default. =20 If this regular expression is set, matches it with the output generated. =20 +=3Ditem log_like =3D> [ qr/required message/ ] + +=3Ditem log_unlike =3D> [ qr/prohibited message/ ] + +See C. + =3Dback =20 =3Dcut @@ -2285,7 +2229,7 @@ sub connect_ok =20 is($stderr, "", "$test_name: no stderr"); =20 - $self->check_connect_log_contents($test_name, $log_location, %params); + $self->log_check($test_name, $log_location, %params); } =20 =3Dpod @@ -2301,6 +2245,12 @@ to fail. =20 If this regular expression is set, matches it with the output generated. =20 +=3Ditem log_like =3D> [ qr/required message/ ] + +=3Ditem log_unlike =3D> [ qr/prohibited message/ ] + +See C. + =3Dback =20 =3Dcut @@ -2327,7 +2277,7 @@ sub connect_fails like($stderr, $params{expected_stderr}, "$test_name: matches"); } =20 - $self->check_connect_log_contents($test_name, $log_location, %params); + $self->log_check($test_name, $log_location, %params); } =20 =3Dpod @@ -2533,6 +2483,67 @@ sub log_content return PostgreSQL::Test::Utils::slurp_file($self->logfile); } =20 +=3Dpod + +=3Ditem $node->log_check($offset, $test_name, %parameters) + +Check contents of server logs. + +=3Dover + +=3Ditem $test_name + +Name of test for error messages. + +=3Ditem $offset + +Offset of the log file. + +=3Ditem log_like =3D> [ qr/required message/ ] + +If given, it must be an array reference containing a list of regular +expressions that must match against the server log, using +C. + +=3Ditem log_unlike =3D> [ qr/prohibited message/ ] + +If given, it must be an array reference containing a list of regular +expressions that must NOT match against the server log. They will be +passed to C. + +=3Dback + +=3Dcut + +sub log_check +{ + my ($self, $test_name, $offset, %params) =3D @_; + + my (@log_like, @log_unlike); + if (defined($params{log_like})) + { + @log_like =3D @{ $params{log_like} }; + } + if (defined($params{log_unlike})) + { + @log_unlike =3D @{ $params{log_unlike} }; + } + + if (@log_like or @log_unlike) + { + my $log_contents =3D + PostgreSQL::Test::Utils::slurp_file($self->logfile, $offset); + + while (my $regex =3D shift @log_like) + { + like($log_contents, $regex, "$test_name: log matches"); + } + while (my $regex =3D shift @log_unlike) + { + unlike($log_contents, $regex, "$test_name: log does not match"); + } + } +} =20 =3Dpod =20 diff --git a/src/test/recovery/t/033_replay_tsp_drops.pl b/src/test/recover= y/t/033_replay_tsp_drops.pl index 307c30bc6b..af97ed9f70 100644 --- a/src/test/recovery/t/033_replay_tsp_drops.pl +++ b/src/test/recovery/t/033_replay_tsp_drops.pl @@ -142,4 +142,4 @@ while ($max_attempts-- >=3D 0) } ok($max_attempts > 0, "invalid directory creation is detected"); =20 -done_testing(); \ No newline at end of file +done_testing(); --=20 2.40.1 --mIFOvauHbu/ZGCjk-- --r6ttGjIR2jTIgOvS Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmR7vOcACgkQnvQgOdby QH3EVRAAotT7MhYFyJu9054YkF5fAfnwSn53i7tklxFy2OJ1XsE5O/Ljm86+Jy9A nBIEnNQmuZKBBhdAsYW3vOQV61dpZVLLfuGdba2QWqCx8WzZPanRUOpc6l/I7WUq knbmS3KM6ARnX6lnFaLDkW6yr/AeLb8/T2vdHnGuyv/by+CmxVTTudYYgu14188w 2yHOR4M0Mfzj6W4zj4RHZxNMxDOH2d3zrUJZrvuvybTNkOWd34rXnhQ1fsREdypz w5EHTSCxN6pPh3hgDBYFUpEfsrhnrfYDB8ayouxADiE7LTdVT3lFQv5e9wgMaDo7 w3lUvLtaw5PQGMD9syVh5hkevJFLl58OWr3j21QMgJxAYQhrpru1F3Mx9EYX6Dgs 0HRuzotPj6AA8/xf+XFA7j71bpTStMUe5f14uODJoYDeamCreqUO4jwbmU2pZNRx aUswqQh4HStterzNgRH6kUtae/aALcUF97atG4Z81xtW7VEOIycxtnsZ+yBe86Z2 HC4CLyI9LRc+IBdYxTJ+uc5p2HFBubTERk/HGk27XhrrBzSrqDJhnnzHMQQ54+xl 6e3oykjGaUiZ84beJ7sYqr/baNoBk7NFtSwBfVUKL4z8gQrBfpo5tePCK6iZit/g 9m9nwEF2TgCnDbVts24dmYe7NwTn95QeYw6ShH6soB+/TorK5R4= =P5co -----END PGP SIGNATURE----- --r6ttGjIR2jTIgOvS--