timescaledb/test/perl/TimescaleNode.pm
Alexander Kuzmenkov 7758f5959c Update .clang-format for version 14
The only configuration we're missing is the newline for braces after
case labels. The rest of the differences looks like bugs/omissions of
the version 8 that we use now.

Require clang-format-14 in cmake and use it in the CI check. We can't
support versions earlier than 14 because they have some
formatting differences that can't be configured.
2022-10-10 17:12:36 +03:00

69 lines
2.0 KiB
Perl

# This file and its contents are licensed under the Timescale License.
# Please see the included NOTICE for copyright information and
# LICENSE-TIMESCALE for a copy of the license.
# This class extends PostgresNode with Timescale-specific
# routines for setup.
package TimescaleNode;
use if $ENV{PG_VERSION_MAJOR} >= 15, 'parent', qw(PostgreSQL::Test::Cluster);
use if $ENV{PG_VERSION_MAJOR} < 15, 'parent', qw(PostgresNode);
use
if $ENV{PG_VERSION_MAJOR} >= 15, 'PostgreSQL::Test::Utils', qw(slurp_file);
use if $ENV{PG_VERSION_MAJOR} < 15, 'TestLib', qw(slurp_file);
use strict;
use warnings;
use Carp 'verbose';
$SIG{__DIE__} = \&Carp::confess;
sub create
{
my ($class, $name, %kwargs) = @_;
my $self =
($ENV{PG_VERSION_MAJOR} >= 15)
? $class->new($name)
: $class->get_new_node($name);
$self->init(%kwargs);
$self->start(%kwargs);
$self->safe_psql('postgres', 'CREATE EXTENSION timescaledb');
return $self;
}
# initialize the data directory and add TS specific parameters
sub init
{
my ($self, %kwargs) = @_;
$self->SUPER::init(%kwargs);
# append into postgresql.conf from Timescale
# template config file
$self->append_conf('postgresql.conf',
slurp_file("$ENV{'CONFDIR'}/postgresql.conf"));
$self->append_conf('postgresql.conf', 'datestyle=ISO');
}
# helper function to check output from PSQL for a query
sub psql_is
{
my ($self, $db, $query, $expected_stdout, $testname) = @_;
my ($psql_rc, $psql_out, $psql_err) = $self->SUPER::psql($db, $query);
if (($ENV{PG_VERSION_MAJOR} >= 15))
{
PostgreSQL::Test::Cluster::ok(!$psql_rc, "$testname: err_code check");
PostgreSQL::Test::Cluster::is($psql_err, '',
"$testname: error_msg check");
PostgreSQL::Test::Cluster::is($psql_out, $expected_stdout,
"$testname: psql output check");
}
else
{
PostgresNode::ok(!$psql_rc, "$testname: err_code check");
PostgresNode::is($psql_err, '', "$testname: error_msg check");
PostgresNode::is($psql_out, $expected_stdout,
"$testname: psql output check");
}
}
1;