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
This commit is contained in:
parent
bda97e47af
commit
29836df323
@ -8,6 +8,35 @@ use PostgreSQL::Test::Cluster;
|
|||||||
use PostgreSQL::Test::Utils;
|
use PostgreSQL::Test::Utils;
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
|
||||||
|
# Check the initial state of the data generated. Tables for tellers and
|
||||||
|
# branches use NULL for their filler attribute. The table accounts uses
|
||||||
|
# a non-NULL filler. The history table should have no data.
|
||||||
|
sub check_data_state
|
||||||
|
{
|
||||||
|
local $Test::Builder::Level = $Test::Builder::Level + 1;
|
||||||
|
my $node = shift;
|
||||||
|
my $type = shift;
|
||||||
|
|
||||||
|
my $sql_result = $node->safe_psql('postgres',
|
||||||
|
'SELECT count(*) AS null_count FROM pgbench_accounts WHERE filler IS NULL LIMIT 10;'
|
||||||
|
);
|
||||||
|
is($sql_result, '0',
|
||||||
|
"$type: filler column of pgbench_accounts has no NULL data");
|
||||||
|
$sql_result = $node->safe_psql('postgres',
|
||||||
|
'SELECT count(*) AS null_count FROM pgbench_branches WHERE filler IS NULL;'
|
||||||
|
);
|
||||||
|
is($sql_result, '1',
|
||||||
|
"$type: filler column of pgbench_branches has only NULL data");
|
||||||
|
$sql_result = $node->safe_psql('postgres',
|
||||||
|
'SELECT count(*) AS null_count FROM pgbench_tellers WHERE filler IS NULL;'
|
||||||
|
);
|
||||||
|
is($sql_result, '10',
|
||||||
|
"$type: filler column of pgbench_tellers has only NULL data");
|
||||||
|
$sql_result = $node->safe_psql('postgres',
|
||||||
|
'SELECT count(*) AS data_count FROM pgbench_history;');
|
||||||
|
is($sql_result, '0', "$type: pgbench_history has no data");
|
||||||
|
}
|
||||||
|
|
||||||
# start a pgbench specific server
|
# start a pgbench specific server
|
||||||
my $node = PostgreSQL::Test::Cluster->new('main');
|
my $node = PostgreSQL::Test::Cluster->new('main');
|
||||||
# Set to untranslated messages, to be able to compare program output with
|
# Set to untranslated messages, to be able to compare program output with
|
||||||
@ -67,6 +96,9 @@ $node->pgbench(
|
|||||||
],
|
],
|
||||||
'pgbench scale 1 initialization',);
|
'pgbench scale 1 initialization',);
|
||||||
|
|
||||||
|
# Check data state, after client-side data generation.
|
||||||
|
check_data_state($node, 'client-side');
|
||||||
|
|
||||||
# Again, with all possible options
|
# Again, with all possible options
|
||||||
$node->pgbench(
|
$node->pgbench(
|
||||||
'--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',
|
'--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 @@ $node->pgbench(
|
|||||||
],
|
],
|
||||||
'pgbench --init-steps');
|
'pgbench --init-steps');
|
||||||
|
|
||||||
|
# Check data state, after server-side data generation.
|
||||||
|
check_data_state($node, 'server-side');
|
||||||
|
|
||||||
# Run all builtin scripts, for a few transactions each
|
# Run all builtin scripts, for a few transactions each
|
||||||
$node->pgbench(
|
$node->pgbench(
|
||||||
'--transactions=5 -Dfoo=bla --client=2 --protocol=simple --builtin=t'
|
'--transactions=5 -Dfoo=bla --client=2 --protocol=simple --builtin=t'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user