($INBOX_DIR/description missing)  
help / color / mirror / Atom feed
From: Bertrand Drouvot <[email protected]>
Subject: [PATCH v3] Adding wait_for_injection_point helper
Date: Thu, 29 Feb 2024 08:31:28 +0000

---
 src/test/perl/PostgreSQL/Test/Cluster.pm      | 36 +++++++++++++++++++
 .../recovery/t/041_checkpoint_at_promote.pl   |  8 +----
 2 files changed, 37 insertions(+), 7 deletions(-)
  65.3% src/test/perl/PostgreSQL/Test/
  34.6% src/test/recovery/t/

diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm
index 44c1bb5afd..8d92eb3858 100644
--- a/src/test/perl/PostgreSQL/Test/Cluster.pm
+++ b/src/test/perl/PostgreSQL/Test/Cluster.pm
@@ -2742,6 +2742,42 @@ sub lsn
 
 =pod
 
+=item $node->wait_for_injection_point(injection_name, backend_type)
+
+Wait for the backend_type to wait for the injection point name.
+
+=cut
+
+sub wait_for_injection_point
+{
+	my ($self, $injection_name, $backend_type) = @_;
+	my $die_message;
+
+	if (defined($backend_type))
+	{
+		$backend_type = qq('$backend_type');
+		$die_message = "the backend type $backend_type";
+	}
+	else
+	{
+		$backend_type = 'backend_type';
+		$die_message = 'one backend';
+
+	}
+
+	$self->poll_query_until(
+		'postgres', qq[
+		SELECT count(*) > 0 FROM pg_stat_activity
+		WHERE backend_type = $backend_type AND wait_event = '$injection_name'
+	])
+	  or die
+	  qq(timed out waiting for $die_message to wait for the injection point '$injection_name');
+
+	return;
+}
+
+=pod
+
 =item $node->wait_for_catchup(standby_name, mode, target_lsn)
 
 Wait for the replication connection with application_name standby_name until
diff --git a/src/test/recovery/t/041_checkpoint_at_promote.pl b/src/test/recovery/t/041_checkpoint_at_promote.pl
index 47381a2c82..3d6faabc0b 100644
--- a/src/test/recovery/t/041_checkpoint_at_promote.pl
+++ b/src/test/recovery/t/041_checkpoint_at_promote.pl
@@ -79,13 +79,7 @@ $node_primary->wait_for_replay_catchup($node_standby);
 # Wait until the checkpointer is in the middle of the restart point
 # processing, relying on the custom wait event generated in the
 # wait callback used in the injection point previously attached.
-ok( $node_standby->poll_query_until(
-		'postgres',
-		qq[SELECT count(*) FROM pg_stat_activity
-           WHERE backend_type = 'checkpointer' AND wait_event = 'CreateRestartPoint' ;],
-		'1'),
-	'checkpointer is waiting in restart point'
-) or die "Timed out while waiting for checkpointer to run restart point";
+$node_standby->wait_for_injection_point('CreateRestartPoint','checkpointer');
 
 # Check the logs that the restart point has started on standby.  This is
 # optional, but let's be sure.
-- 
2.34.1


--4OZRU1j/VeNd8/tm--





view thread (23+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v3] Adding wait_for_injection_point helper
  In-Reply-To: <no-message-id-1858076@localhost>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox