Обсуждение: pg_regress restart cluster?

Поиск
Список
Период
Сортировка

pg_regress restart cluster?

От
Jeremy Finzel
Дата:
Hello!

I am using the basic extension building infrastructure with sql and expected files, but what I want to test is changing a config setting and then restarting the cluster with shared_preload_libraries in place. Is there a canonical way to do this or does anyone have any examples of this? I appreciate it very much!

Thanks,

Jeremy

Re: pg_regress restart cluster?

От
Michael Paquier
Дата:
On Fri, Sep 06, 2019 at 11:55:43AM -0500, Jeremy Finzel wrote:
> I am using the basic extension building infrastructure with sql and
> expected files, but what I want to test is changing a config setting and
> then restarting the cluster with shared_preload_libraries in place. Is
> there a canonical way to do this or does anyone have any examples of this?
> I appreciate it very much!

With an extension out of core using PGXS for compilation, "check" is
not support, only "installcheck" is.  With "check", we use
REGRESS_OPTS with --temp-config to start up the cluster with a custom
configuration file.  You can use that by copying your extension into
the core code tree.  Also, depending on the extension type, you may be
able to test it without shared_preload_libraries.  Most hooks, like
the password one, can be loaded in a session.  If you use the shared
memory initialization hook that's of course not possible.

For an external extension, I think that you could just use TAP to test
any kind of system configurations you would like to test.  One thing
to remember is that you need to set the environment variable
PG_REGRESS in the context of the test, one trick for example I have
used is that:
my $stdout = run_simple_command(['pg_config', '--libdir'],
       "fetch library directory using pg_config");
print "LIBDIR path found as $stdout\n";
$ENV{PG_REGRESS} = "$stdout/pgxs/src/test/regress/pg_regress";

This proves to be enough to control the routines of PostgresNode.pm to
control a cluster, and even start your own pg_regress command with
the SQL-based tests part of your extension.
--
Michael

Вложения

Re: pg_regress restart cluster?

От
Tom Lane
Дата:
Jeremy Finzel <finzelj@gmail.com> writes:
> I am using the basic extension building infrastructure with sql and
> expected files, but what I want to test is changing a config setting and
> then restarting the cluster with shared_preload_libraries in place. Is
> there a canonical way to do this or does anyone have any examples of this?
> I appreciate it very much!

pg_regress doesn't have any support for that, but you can do it pretty
easily in the context of a TAP test.  There are a bunch of examples
in the existing TAP tests --- look around for uses of append_conf().

            regards, tom lane