Skip to content

Commit 29836df

Browse files
committed
pgbench: Add TAP tests to check consistency of data generated
The tables created by pgbench rely on a few assumptions for TPC-B, where the "filler" attribute is used to comply with this benchmark's rules as well as pgbencn historical behavior. The data generated for each table uses this filler in a different way: - pgbench_accounts uses it as a blank-padded empty string. - pgbench_tellers and pgbench_branches use it as a NULL value. There were no checks done about the consistency of the data initialized, and this has showed up while discussing a patch that changes the logic in charge of the client-side data generation (pgbench documents all that already in its comments). This commit adds some checks on the data generated for both the server-side and client-side logic. Reviewed-by: Tristan Partin Discussion: https://postgr.es/m/ZLik4oKnqRmVCM3t@paquier.xyz
1 parent bda97e4 commit 29836df

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,35 @@
88
use PostgreSQL::Test::Utils;
99
use Test::More;
1010

11+
# Check the initial state of the data generated. Tables for tellers and
12+
# branches use NULL for their filler attribute. The table accounts uses
13+
# a non-NULL filler. The history table should have no data.
14+
sub check_data_state
15+
{
16+
local $Test::Builder::Level = $Test::Builder::Level + 1;
17+
my $node = shift;
18+
my $type = shift;
19+
20+
my $sql_result = $node->safe_psql('postgres',
21+
'SELECT count(*) AS null_count FROM pgbench_accounts WHERE filler IS NULL LIMIT 10;'
22+
);
23+
is($sql_result, '0',
24+
"$type: filler column of pgbench_accounts has no NULL data");
25+
$sql_result = $node->safe_psql('postgres',
26+
'SELECT count(*) AS null_count FROM pgbench_branches WHERE filler IS NULL;'
27+
);
28+
is($sql_result, '1',
29+
"$type: filler column of pgbench_branches has only NULL data");
30+
$sql_result = $node->safe_psql('postgres',
31+
'SELECT count(*) AS null_count FROM pgbench_tellers WHERE filler IS NULL;'
32+
);
33+
is($sql_result, '10',
34+
"$type: filler column of pgbench_tellers has only NULL data");
35+
$sql_result = $node->safe_psql('postgres',
36+
'SELECT count(*) AS data_count FROM pgbench_history;');
37+
is($sql_result, '0', "$type: pgbench_history has no data");
38+
}
39+
1140
# start a pgbench specific server
1241
my $node = PostgreSQL::Test::Cluster->new('main');
1342
# Set to untranslated messages, to be able to compare program output with
@@ -67,6 +96,9 @@
6796
],
6897
'pgbench scale 1 initialization',);
6998

99+
# Check data state, after client-side data generation.
100+
check_data_state($node, 'client-side');
101+
70102
# Again, with all possible options
71103
$node->pgbench(
72104
'--initialize --init-steps=dtpvg --scale=1 --unlogged-tables --fillfactor=98 --foreign-keys --quiet --tablespace=regress_pgbench_tap_1_ts --index-tablespace=regress_pgbench_tap_1_ts --partitions=2 --partition-method=hash',
@@ -101,6 +133,9 @@
101133
],
102134
'pgbench --init-steps');
103135

136+
# Check data state, after server-side data generation.
137+
check_data_state($node, 'server-side');
138+
104139
# Run all builtin scripts, for a few transactions each
105140
$node->pgbench(
106141
'--transactions=5 -Dfoo=bla --client=2 --protocol=simple --builtin=t'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy