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 @@ -27,6 +27,7 @@ our @EXPORT = qw(
27
27
system_log
28
28
run_log
29
29
run_command
30
+ pump_until
30
31
31
32
command_ok
32
33
command_fails
Original file line number Diff line number Diff line change @@ -2561,6 +2561,41 @@ sub wait_for_slot_catchup
2561
2561
2562
2562
=pod
2563
2563
2564
+ =item $node->wait_for_log(regexp, offset)
2565
+
2566
+ Waits for the contents of the server log file, starting at the given offset, to
2567
+ match the supplied regular expression. Checks the entire log if no offset is
2568
+ given. Times out after $TestLib::timeout_default seconds.
2569
+
2570
+ If successful, returns the length of the entire log file, in bytes.
2571
+
2572
+ =cut
2573
+
2574
+ sub wait_for_log
2575
+ {
2576
+ my ($self , $regexp , $offset ) = @_ ;
2577
+ $offset = 0 unless defined $offset ;
2578
+
2579
+ my $max_attempts = 10 * $TestLib::timeout_default ;
2580
+ my $attempts = 0;
2581
+
2582
+ while ($attempts < $max_attempts )
2583
+ {
2584
+ my $log = TestLib::slurp_file($self -> logfile, $offset );
2585
+
2586
+ return $offset +length ($log ) if ($log =~ m /$regexp / );
2587
+
2588
+ # Wait 0.1 second before retrying.
2589
+ usleep(100_000);
2590
+
2591
+ $attempts ++;
2592
+ }
2593
+
2594
+ croak " timed out waiting for match: $regexp " ;
2595
+ }
2596
+
2597
+ =pod
2598
+
2564
2599
=item $node->query_hash($dbname, $query, @columns)
2565
2600
2566
2601
Execute $query on $dbname, replacing any appearance of the string __COLUMNS__
Original file line number Diff line number Diff line change @@ -74,6 +74,7 @@ our @EXPORT = qw(
74
74
system_log
75
75
run_log
76
76
run_command
77
+ pump_until
77
78
78
79
command_ok
79
80
command_fails
@@ -393,6 +394,36 @@ sub run_command
393
394
394
395
=pod
395
396
397
+ =item pump_until(proc, timeout, stream, until)
398
+
399
+ Pump until string is matched on the specified stream, or timeout occurs.
400
+
401
+ =cut
402
+
403
+ sub pump_until
404
+ {
405
+ my ($proc , $timeout , $stream , $until ) = @_ ;
406
+ $proc -> pump_nb();
407
+ while (1)
408
+ {
409
+ last if $$stream =~ / $until / ;
410
+ if ($timeout -> is_expired)
411
+ {
412
+ diag(" pump_until: timeout expired when searching for \" $until \" with stream: \" $$stream \" " );
413
+ return 0;
414
+ }
415
+ if (not $proc -> pumpable())
416
+ {
417
+ diag(" pump_until: process terminated unexpectedly when searching for \" $until \" with stream: \" $$stream \" " );
418
+ return 0;
419
+ }
420
+ $proc -> pump();
421
+ }
422
+ return 1;
423
+ }
424
+
425
+ =pod
426
+
396
427
=item generate_ascii_string(from_char, to_char)
397
428
398
429
Generate a string made of the given range of ASCII characters.
You can’t perform that action at this time.
0 commit comments