Re: Re: In-core regression tests for replication, cascading, archiving, PITR, etc. - Mailing list pgsql-hackers
From | Alvaro Herrera |
---|---|
Subject | Re: Re: In-core regression tests for replication, cascading, archiving, PITR, etc. |
Date | |
Msg-id | 20151127225310.GG4320@alvherre.pgsql Whole thread Raw |
In response to | Re: Re: In-core regression tests for replication, cascading, archiving, PITR, etc. (Michael Paquier <michael.paquier@gmail.com>) |
Responses |
Re: Re: In-core regression tests for replication,
cascading, archiving, PITR, etc.
Re: Re: In-core regression tests for replication, cascading, archiving, PITR, etc. |
List | pgsql-hackers |
Michael Paquier wrote: > The result of a couple of hours of hacking is attached: > - 0001 is the refactoring adding PostgresNode and RecursiveCopy. I have > also found that it is quite advantageous to move some of the routines that > are synonyms of system() and the stuff used for logging into another > low-level library that PostgresNode depends on, that I called TestBase in > this patch. This way, all the infrastructure depends on the same logging > management. Existing tests have been refactored to fit into the new code, > and this leads to a couple of simplifications particularly in pg_rewind > tests because there is no more need to have there routines for environment > cleanup and logging. I have done tests on OSX and Windows using it and > tests are passing. I have as well tested that ssl tests were working. Here's another version of this. I changed the packages a bit more. For starters, I moved the routines around a bit; some of your choices seemed more about keeping stuff where it was originally rather than moving it to where it made sense. These are the routines in each module: TestBase: system_or_bail system_log run_log slurp_dir slurp_file append_to_file TestLib: get_new_node teardown_node psql poll_query_until command_ok command_fails command_exit_is program_help_ok program_version_ok program_options_handling_ok command_like issues_sql_like I tried to get rid of teardown_node by having a DESTROY method for PostgresNode; that method would call "pg_ctl stop -m immediate". That would have been much cleaner. However, when a test fails this doesn't work sanely because the END block for File::Temp runs earlier than that DESTROY block, which means the datadir is already gone by the time pg_ctl stop runs, so the node stop doesn't work at all. (Perhaps we could fix this by noting postmaster's PID at start time, and then sending a signal directly instead of relying on pg_ctl). I moved all the initialization code (deleting stuff from environment, detecting Windows, opening SimpleTie filedescs etc) into BEGIN blocks, which run earlier than any other code. I perltidy'ed PostgresNode (and all the other files actually), to have the style match the rest of our code. I also updated some code to be more Perlish. I added a lot of error checking in RecursiveCopy. You had a "cat" call somewhere, which I replaced with slurp_file. I considered updating RewindTest so that it didn't have to export the node global variables, but decided not to, not because of the huge code churn for the t/*.pl files but because of the problem with the DESTROY method above: it didn't actually buy anything. Hmm. I just noticed RewindTest sets $ENV{PGDATABASE} outside BEGIN. Not sure what to think of that. Could instead pass the database name in $node->getConnStr() calls, like run_pg_rewind() is already doing. I tried all the t/ tests we have and all of them pass for me. If I'm able, I will push this on my Sunday late evening, so that I can fix whatever gets red on Monday first thing ... -- Álvaro Herrera http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachment
pgsql-hackers by date: