Re: tests for client programs

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tests for client programs
Date: 2014-05-07 00:44:56
Message-ID: 1399423496.5361.3.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2014-04-30 at 18:09 +0200, Andres Freund wrote:
> On 2014-04-04 16:44:46 +0200, Andres Freund wrote:
> > On 2014-02-27 21:44:48 -0500, Peter Eisentraut wrote:
> > > +open HBA, ">>$tempdir/pgdata/pg_hba.conf";
> > > +print HBA "local replication all trust\n";
> > > +print HBA "host replication all 127.0.0.1/32 trust\n";
> > > +print HBA "host replication all ::1/128 trust\n";
> > > +close HBA;
> >
> > Given the recent make check security discussions, this doesn't seem like
> > a good idea...

The socket file for the test server instance is in a private directory,
so that should be safe enough.

> >
> > > +issues_sql_like(['createdb', 'foobar1'], qr/statement: CREATE DATABASE foobar1/, 'SQL CREATE DATABASE run');
> > > +issues_sql_like(['createdb', 'foobar2', '-l', 'C', '-E', 'LATIN1', '-T', 'template0'], qr/statement: CREATE DATABASE foobar2 ENCODING 'LATIN1'/, 'create database with encoding');
> >
> > Hm. Are all platforms guaranteed to provide latin1?

Yes.

> > > diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm
> > > +if (!$ENV{PGPORT}) {
> > > + $ENV{PGPORT} = 65432;
> > > +}
> > > +
> > > +$ENV{PGPORT} = int($ENV{PGPORT}) % 65536;
> >
> > Hm. I think this should use logical similar to what pg_regress is using,
> > namely test a few ports.

That could be improved in the future.

> > > +sub start_test_server {
> > > + my ($tempdir) = @_;
> > > + my $ret;
> > > +
> > > + system "initdb -D $tempdir/pgdata -A trust -N >/dev/null";
> > > + $ret = system 'pg_ctl', '-D', "$tempdir/pgdata", '-s', '-w', '-l', "$tempdir/logfile", '-o', "--fsync=off -k $tempdir --listen-addresses='' --log-statement=all", 'start';
> > > +
> > > + if ($ret != 0) {
> > > + system('cat', "$tempdir/logfile");
> > > + BAIL_OUT("pg_ctl failed");
> > > + }
> > > +
> > > + $ENV{PGHOST} = $tempdir;
> > > + $test_server_datadir = "$tempdir/pgdata";
> > > + $test_server_logfile = "$tempdir/logfile";
> > > +}
> >
> > Should stuff like --fsync-off, -k, really be on by default?

-k is to set the socket directory. You might be thinking of initdb -k?

> > I think the code to massage pg_hba.conf should also be here, there'll be
> > a fair number of tests that need it.

More refactoring is always possible as needs arise.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2014-05-07 00:54:48 Re: Wanted: jsonb on-disk representation documentation
Previous Message Bruce Momjian 2014-05-07 00:41:13 Re: [COMMITTERS] pgsql: pgindent run for 9.4