<title>Custom Server Settings</title>
<para>
- Custom server settings to use when running a regression test suite can be
+ There are several ways to use custom server settings when running a test
+ suite. This can be useful to enable additional logging, adjust resource
+ limits, or enable extra run-time checks such as <xref
+ linkend="guc-debug-discard-caches"/>. But note that not all tests can be
+ expected to pass cleanly with arbitrary settings.
+ </para>
+
+ <para>
+ Extra options can be passed to the various <command>initdb</command>
+ commands that are run internally during test setup using the environment
+ variable <envar>PG_TEST_INITDB_EXTRA_OPTS</envar>. For example, to run a
+ test with checksums enabled and a custom WAL segment size and
+ <varname>work_mem</varname> setting, use:
+<screen>
+make check PG_TEST_INITDB_EXTRA_OPTS='-k --wal-segsize=4 -c work_mem=50MB'
+</screen>
+ </para>
+
+ <para>
+ For the core regression test suite and other tests driven by
+ <command>pg_regress</command>, custom run-time server settings can also be
set in the <varname>PGOPTIONS</varname> environment variable (for settings
- that allow this):
+ that allow this), for example:
<screen>
make check PGOPTIONS="-c debug_parallel_query=regress -c work_mem=50MB"
</screen>
+ (This makes use of functionality provided by libpq; see <xref
+ linkend="libpq-connect-options"/> for details.)
+ </para>
+
+ <para>
When running against a temporary installation, custom settings can also be
set by supplying a pre-written <filename>postgresql.conf</filename>:
<screen>
</screen>
</para>
- <para>
- This can be useful to enable additional logging, adjust resource limits,
- or enable extra run-time checks such as <xref
- linkend="guc-debug-discard-caches"/>.
- </para>
</sect2>
<sect2 id="regress-run-extra-tests">
use Test::More;
use PostgreSQL::Test::Utils ();
use PostgreSQL::Test::BackgroundPsql ();
+use Text::ParseWords qw(shellwords);
use Time::HiRes qw(usleep);
use Scalar::Util qw(blessed);
$params{allows_streaming} = 0 unless defined $params{allows_streaming};
$params{has_archiving} = 0 unless defined $params{has_archiving};
+ my $initdb_extra_opts_env = $ENV{PG_TEST_INITDB_EXTRA_OPTS};
+ if (defined $initdb_extra_opts_env)
+ {
+ push @{ $params{extra} }, shellwords($initdb_extra_opts_env);
+ }
+
mkdir $self->backup_dir;
mkdir $self->archive_dir;
const char *keywords[4];
const char *values[4];
PGPing rv;
+ const char *initdb_extra_opts_env;
/*
* Prepare the temp instance
if (!directory_exists(buf))
make_directory(buf);
+ initdb_extra_opts_env = getenv("PG_TEST_INITDB_EXTRA_OPTS");
+
initStringInfo(&cmd);
/*
* duplicate it until we require perl at build time.
*/
initdb_template_dir = getenv("INITDB_TEMPLATE");
- if (initdb_template_dir == NULL || nolocale || debug)
+ if (initdb_template_dir == NULL || nolocale || debug || initdb_extra_opts_env)
{
note("initializing database system by running initdb");
appendStringInfoString(&cmd, " --debug");
if (nolocale)
appendStringInfoString(&cmd, " --no-locale");
+ if (initdb_extra_opts_env)
+ appendStringInfo(&cmd, " %s", initdb_extra_opts_env);
appendStringInfo(&cmd, " > \"%s/log/initdb.log\" 2>&1", outputdir);
fflush(NULL);
if (system(cmd.data))