Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0efd2a1

Browse files
committed
Fix pattern matching logic for logs in TAP tests of pgbench
The logic checking for the format of per-thread logs used grep() withdirectly "$re", which would cause the test to consider all the logs asa match without caring about their format at all. Using "/$re/" makesgrep() perform a regex test, which is what we want here.While on it, improve some of the tests to be more picky with thepatterns expected and add more comments to describe the tests.Issue discovered while digging into a separate patch.Author: Fabien Coelho, Michael PaquierDiscussion:https://postgr.es/m/YNPsPAUoVDCpPOGk@paquier.xyzBackpatch-through: 11
1 parentc6cb62f commit0efd2a1

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

‎src/bin/pgbench/t/001_pgbench_with_server.pl

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,12 @@ sub list_files
816816
returnmap {$dir .'/' .$_ }@files;
817817
}
818818

819-
# check log contents and cleanup
819+
# Check log contents and clean them up:
820+
# $dir: directory holding logs
821+
# $prefix: file prefix for per-thread logs
822+
# $nb: number of expected files
823+
# $min/$max: minimum and maximum number of lines in log files
824+
# $re: regular expression each log line has to match
820825
subcheck_pgbench_logs
821826
{
822827
my ($dir,$prefix,$nb,$min,$max,$re) =@_;
@@ -835,7 +840,7 @@ sub check_pgbench_logs
835840
my$clen =@contents;
836841
ok($min <=$clen &&$clen <=$max,
837842
"transaction count for$log ($clen)");
838-
ok(grep($re,@contents) ==$clen,
843+
ok(grep(/$re/,@contents) ==$clen,
839844
"transaction format for$prefix");
840845
close$fhordie"$@";
841846
};
@@ -846,7 +851,7 @@ sub check_pgbench_logs
846851

847852
my$bdir =$node->basedir;
848853

849-
# with sampling rate
854+
#Runwith sampling rate, 2 clients with 50 transactions each.
850855
pgbench(
851856
"-n -S -t 50 -c 2 --log --sampling-rate=0.5",
852857
0,
@@ -855,19 +860,19 @@ sub check_pgbench_logs
855860
'pgbench logs',
856861
undef,
857862
"--log-prefix=$bdir/001_pgbench_log_2");
858-
863+
# The IDs of the clients (1st field) in the logs should be either 0 or 1.
859864
check_pgbench_logs($bdir,'001_pgbench_log_2', 1, 8, 92,
860-
qr{^0\d{1,2}\d+\d\d+\d+$});
865+
qr{^[01]\d{1,2}\d+\d\d+\d+$});
861866

862-
#check log file in some detail
867+
#Run with different read-only option pattern, 1 client with 10 transactions.
863868
pgbench(
864-
"-n -bse -t 10 -l",
865-
0,[qr{select only},qr{processed: 10/10} ], [qr{^$}],
869+
"-n -bselect-only -t 10 -l", 0,
870+
[qr{select only},qr{processed: 10/10} ], [qr{^$}],
866871
'pgbench logs contents',undef,
867872
"--log-prefix=$bdir/001_pgbench_log_3");
868-
873+
# The ID of a single client (1st field) should match 0.
869874
check_pgbench_logs($bdir,'001_pgbench_log_3', 1, 10, 10,
870-
qr{^\d\d{1,2}\d+\d\d+\d+$});
875+
qr{^0\d{1,2}\d+\d\d+\d+$});
871876

872877
# done
873878
$node->stop;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp