Re: Writing new unit tests with PostgresNode - Mailing list pgsql-hackers

From Craig Ringer
Subject Re: Writing new unit tests with PostgresNode
Date
Msg-id CAMsr+YFH7ZDYL6TUo-Wtykw6V5VojYNU+5EHkcDMEOU4Ar=Smg@mail.gmail.com
Whole thread Raw
In response to Re: Writing new unit tests with PostgresNode  (Michael Paquier <michael.paquier@gmail.com>)
Responses Re: Writing new unit tests with PostgresNode
List pgsql-hackers
On 22 February 2016 at 15:41, Michael Paquier <michael.paquier@gmail.com> wrote:
 

>> > Sound about right? I can tidy that up a bit and turn it into a README
>> > and
>> > add a reference to that to the public tap docs to tell users where to go
>> > if
>> > they want to write more tests.
>>
>> Yes, please.
>
> Will do that now.

This is definitely independent from the efforts of the other patches.

Done.

I got a bit carried away and added:

- src/test/perl/README
- src/test/README
- src/test/modules/README
- POD for src/test/perl/PostgresNode.pm
- $node->info() function (that just returns what dump_info() printed, but as a string
- $node->backup(...) support for passing -R to pg_basebackup
- $node->backup(...) support for passing -X stream to pg_basebackup
-  src/test/example_suite/ with some simple demo tests

I found that I was writing documentation for how to write tests that'd bitrot quickly and landed up writing a demo/sample test that can be run as part of 'make check' with --enable-tap-tests instead. Hopefully it's not overkill.

LMK if you think it's too much and I can trim out what's unwanted.

In the process I noticed a few helpers I think should be added to PostgresNode. I haven't added them since I didn't want this to turn into a big patch when it was meant to just be 'add a README', but the main things are:

- promote (you've done this)

- Facilities to make it easier to set a master up as replication-enabled (your patch does this, but it should use wal_level = 'logical' by default IMO; also I think setting autovacuum=off is very wrong and will mask problems)

- wait_for_recovery_lsn($lsn) to wait until a hot standby passes a given LSN

- wait_for_replication_lsn($lsn, $col, $appname) - wait until standby with name $appname (or any standby, if unspecified) passes $lsn for $col, where $col can be 'sent', 'write', 'flush' or 'replay'

 
> Not committed yet, I see. That's https://commitfest.postgresql.org/9/438/
> right?

Yeah... That's life.


I'll comment separately on that thread.

--
 Craig Ringer                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: psql metaqueries with \gexec
Next
From: Craig Ringer
Date:
Subject: Re: Writing new unit tests with PostgresNode