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 @@ -2184,6 +2184,41 @@ sub wait_for_slot_catchup
2184
2184
2185
2185
=pod
2186
2186
2187
+ =item $node->wait_for_log(regexp, offset)
2188
+
2189
+ Waits for the contents of the server log file, starting at the given offset, to
2190
+ match the supplied regular expression. Checks the entire log if no offset is
2191
+ given. Times out after $TestLib::timeout_default seconds.
2192
+
2193
+ If successful, returns the length of the entire log file, in bytes.
2194
+
2195
+ =cut
2196
+
2197
+ sub wait_for_log
2198
+ {
2199
+ my ($self , $regexp , $offset ) = @_ ;
2200
+ $offset = 0 unless defined $offset ;
2201
+
2202
+ my $max_attempts = 10 * $TestLib::timeout_default ;
2203
+ my $attempts = 0;
2204
+
2205
+ while ($attempts < $max_attempts )
2206
+ {
2207
+ my $log = TestLib::slurp_file($self -> logfile, $offset );
2208
+
2209
+ return $offset +length ($log ) if ($log =~ m /$regexp / );
2210
+
2211
+ # Wait 0.1 second before retrying.
2212
+ usleep(100_000);
2213
+
2214
+ $attempts ++;
2215
+ }
2216
+
2217
+ croak " timed out waiting for match: $regexp " ;
2218
+ }
2219
+
2220
+ =pod
2221
+
2187
2222
=item $node->query_hash($dbname, $query, @columns)
2188
2223
2189
2224
Execute $query on $dbname, replacing any appearance of the string __COLUMNS__
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ our @EXPORT = qw(
70
70
system_log
71
71
run_log
72
72
run_command
73
+ pump_until
73
74
74
75
command_ok
75
76
command_fails
@@ -377,6 +378,36 @@ sub run_command
377
378
378
379
=pod
379
380
381
+ =item pump_until(proc, timeout, stream, until)
382
+
383
+ Pump until string is matched on the specified stream, or timeout occurs.
384
+
385
+ =cut
386
+
387
+ sub pump_until
388
+ {
389
+ my ($proc , $timeout , $stream , $until ) = @_ ;
390
+ $proc -> pump_nb();
391
+ while (1)
392
+ {
393
+ last if $$stream =~ / $until / ;
394
+ if ($timeout -> is_expired)
395
+ {
396
+ diag(" pump_until: timeout expired when searching for \" $until \" with stream: \" $$stream \" " );
397
+ return 0;
398
+ }
399
+ if (not $proc -> pumpable())
400
+ {
401
+ diag(" pump_until: process terminated unexpectedly when searching for \" $until \" with stream: \" $$stream \" " );
402
+ return 0;
403
+ }
404
+ $proc -> pump();
405
+ }
406
+ return 1;
407
+ }
408
+
409
+ =pod
410
+
380
411
=item generate_ascii_string(from_char, to_char)
381
412
382
413
Generate a string made of the given range of ASCII characters.
You can’t perform that action at this time.
0 commit comments