-
Notifications
You must be signed in to change notification settings - Fork 940
Strip whitespace when checking query results in TAP tests #8048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,4 +56,19 @@ sub psql_is | |||||
"$testname: psql output check"); | ||||||
} | ||||||
|
||||||
# remove leading and trailing whitespace | ||||||
sub strip | ||||||
{ | ||||||
my ($self, $str) = @_; | ||||||
$str =~ s/^\s+|\s+$//g; | ||||||
return $str; | ||||||
} | ||||||
|
||||||
sub safe_psql | ||||||
{ | ||||||
my ($self, $db, $query) = @_; | ||||||
my $psql_out = $self->SUPER::safe_psql($db, $query); | ||||||
return $self->strip($psql_out); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you remove
Suggested change
|
||||||
} | ||||||
|
||||||
1; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,15 +27,14 @@ | |
temperature double precision null); | ||
} | ||
); | ||
is($result, '', 'create table'); | ||
|
||
# Create hypertable | ||
$result = $node->safe_psql( | ||
'postgres', q{ | ||
SELECT FROM create_hypertable('sensor_data','time', chunk_time_interval => INTERVAL '1 month'); | ||
SELECT table_name FROM create_hypertable('sensor_data','time', chunk_time_interval => INTERVAL '1 month'); | ||
} | ||
); | ||
is($result, '', 'create hypertable'); | ||
is($result, 'sensor_data', 'create hypertable'); | ||
|
||
# Insert data | ||
$result = $node->safe_psql( | ||
|
@@ -52,7 +51,6 @@ | |
ORDER BY time; | ||
} | ||
); | ||
is($result, '', 'insert data'); | ||
|
||
# Define count query | ||
my $count_query = "SELECT count(*) FROM sensor_data;"; | ||
|
@@ -72,7 +70,6 @@ | |
ALTER TABLE sensor_data SET (timescaledb.compress, timescaledb.compress_segmentby = 'sensor_id'); | ||
} | ||
); | ||
is($result, '', 'enable compression'); | ||
|
||
# Get number of chunks | ||
my $n_chunks = $node->safe_psql( | ||
|
@@ -87,7 +84,6 @@ | |
# SET session 1 behaviour to `truncate_or_delete` | ||
$result = $s1->query_safe( | ||
"SET timescaledb.compress_truncate_behaviour TO truncate_or_delete;"); | ||
isnt($result, '', "session 1: set truncate_or_delete"); | ||
|
||
# Run tests | ||
|
||
|
@@ -97,10 +93,8 @@ | |
|
||
# Begin txns in both sessions | ||
$result = $s1->query_safe("BEGIN"); | ||
isnt($result, '', "session 1: begin"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why removing those There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. isnt empty string is not a meaningful test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: statement isn't a query, so we should probably use |
||
|
||
$result = $s2->query_safe("BEGIN"); | ||
isnt($result, '', "session 2: begin"); | ||
|
||
# The aggregation query takes an AccessShareLock on the chunk, preventing truncate | ||
$result = $s2->query_safe($count_query); | ||
|
@@ -123,7 +117,6 @@ | |
is($result, $num_rows, "session 2: validate row count again"); | ||
|
||
$result = $s2->query_safe("COMMIT"); | ||
isnt($result, '', "session 2: commit"); | ||
|
||
# No AccessExclusiveLock on the uncompressed chunk | ||
$result = $s1->query_safe( | ||
|
@@ -134,7 +127,6 @@ | |
|
||
|
||
$result = $s1->query_safe("ROLLBACK"); | ||
isnt($result, '', "session 1: rollback"); | ||
|
||
########################################################################## | ||
|
||
|
@@ -143,10 +135,8 @@ | |
|
||
# Begin txns in both sessions | ||
$result = $s1->query_safe("BEGIN"); | ||
isnt($result, '', "session 1: begin"); | ||
|
||
$result = $s2->query_safe("BEGIN"); | ||
isnt($result, '', "session 2: begin"); | ||
|
||
$result = $s2->query_safe($count_query); | ||
is($result, $num_rows, "session 2: validate row count"); | ||
|
@@ -157,7 +147,6 @@ | |
|
||
# Session 2 immediately commits, releasing the AccessShareLock on the table | ||
$result = $s2->query_safe("COMMIT"); | ||
isnt($result, '', "session 2: commit"); | ||
|
||
# The result from the previous query_until() is returned with the next query | ||
# so perform a dummy query on s1 to discard the result | ||
|
@@ -179,7 +168,6 @@ | |
is($result, $expected, "verify AccessExclusiveLock was taken"); | ||
|
||
$result = $s1->query_safe("ROLLBACK"); | ||
isnt($result, '', "session 1: rollback"); | ||
|
||
$s1->quit(); | ||
$s2->quit(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This is so simple that I'm not sure a function is needed, but whatever. Also, indentation makes it look like it is an
if
, and$self
is never used. Maybe just skip the$self
and use it as a plain function similar to how they are defined in https://perlmaven.com/trim.