File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ our @EXPORT = qw(
26
26
system_log
27
27
run_log
28
28
run_command
29
+ pump_until
29
30
30
31
command_ok
31
32
command_fails
Original file line number Diff line number Diff line change @@ -2075,6 +2075,41 @@ sub wait_for_slot_catchup
2075
2075
2076
2076
=pod
2077
2077
2078
+ =item $node->wait_for_log(regexp, offset)
2079
+
2080
+ Waits for the contents of the server log file, starting at the given offset, to
2081
+ match the supplied regular expression. Checks the entire log if no offset is
2082
+ given. Times out after $TestLib::timeout_default seconds.
2083
+
2084
+ If successful, returns the length of the entire log file, in bytes.
2085
+
2086
+ =cut
2087
+
2088
+ sub wait_for_log
2089
+ {
2090
+ my ($self , $regexp , $offset ) = @_ ;
2091
+ $offset = 0 unless defined $offset ;
2092
+
2093
+ my $max_attempts = 10 * $TestLib::timeout_default ;
2094
+ my $attempts = 0;
2095
+
2096
+ while ($attempts < $max_attempts )
2097
+ {
2098
+ my $log = TestLib::slurp_file($self -> logfile, $offset );
2099
+
2100
+ return $offset +length ($log ) if ($log =~ m /$regexp / );
2101
+
2102
+ # Wait 0.1 second before retrying.
2103
+ usleep(100_000);
2104
+
2105
+ $attempts ++;
2106
+ }
2107
+
2108
+ croak " timed out waiting for match: $regexp " ;
2109
+ }
2110
+
2111
+ =pod
2112
+
2078
2113
=item $node->query_hash($dbname, $query, @columns)
2079
2114
2080
2115
Execute $query on $dbname, replacing any appearance of the string __COLUMNS__
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ our @EXPORT = qw(
37
37
system_log
38
38
run_log
39
39
run_command
40
+ pump_until
40
41
41
42
command_ok
42
43
command_fails
@@ -251,6 +252,36 @@ sub run_command
251
252
return ($stdout , $stderr );
252
253
}
253
254
255
+ =pod
256
+
257
+ =item pump_until(proc, timeout, stream, until)
258
+
259
+ Pump until string is matched on the specified stream, or timeout occurs.
260
+
261
+ =cut
262
+
263
+ sub pump_until
264
+ {
265
+ my ($proc , $timeout , $stream , $until ) = @_ ;
266
+ $proc -> pump_nb();
267
+ while (1)
268
+ {
269
+ last if $$stream =~ / $until / ;
270
+ if ($timeout -> is_expired)
271
+ {
272
+ diag(" pump_until: timeout expired when searching for \" $until \" with stream: \" $$stream \" " );
273
+ return 0;
274
+ }
275
+ if (not $proc -> pumpable())
276
+ {
277
+ diag(" pump_until: process terminated unexpectedly when searching for \" $until \" with stream: \" $$stream \" " );
278
+ return 0;
279
+ }
280
+ $proc -> pump();
281
+ }
282
+ return 1;
283
+ }
284
+
254
285
# Generate a string made of the given range of ASCII characters
255
286
sub generate_ascii_string
256
287
{
You can’t perform that action at this time.
0 commit comments