timescaledb/test/perl/TimescaleNode.pm
Nikhil 768ff54ae2 Add perl module files to PG install
We have added additional functionality in timescaledb extension to
use in tap tests. Install these perl files in the PG installation
directory so that external modules (the current "forge_ext" extension
as an example) can use this functionality without having to have an
additional dependency on the timescaledb extension source code. Note
that these perl files should be installed only if PG installation has
the relevant "${PG_PKGLIBDIR}/pgxs/src/test/perl" subdirectory.

Also rejig the configuration directory variable that's used for the
tap tests so that external modules can specify their own locations by
using their own values for it (the current variable was tightly tied to
timescaledb source code location).
2021-07-21 14:09:28 +05:30

51 lines
1.3 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 parent qw(PostgresNode);
use TestLib qw(slurp_file);
use strict;
use warnings;
use Carp 'verbose';
$SIG{__DIE__} = \&Carp::confess;
sub create
{
my ($class, $name, %kwargs) = @_;
my $self = $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',
TestLib::slurp_file("$ENV{'CONFDIR'}/postgresql.conf"));
}
# 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);
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;