summaryrefslogtreecommitdiff
path: root/src/test/perl/PostgresNode.pm
AgeCommit message (Collapse)Author
2017-01-14pg_ctl: Change default to wait for all actionsPeter Eisentraut
The different actions in pg_ctl had different defaults for -w and -W, mostly for historical reasons. Most users will want the -w behavior, so make that the default. Remove the -w option in most example and test code, so avoid confusion and reduce verbosity. pg_upgrade is not touched, so it can continue to work with older installations. Reviewed-by: Beena Emerson <[email protected]> Reviewed-by: Ryan Murphy <[email protected]>
2017-01-12Fix mistake in commentPeter Eisentraut
The node->restart() function doesn't take a mode argument.
2017-01-05Fix format for TAP test docsSimon Riggs
Small number of fixes to perl docs for TAP tests. Plus two comments that use "xlog" rather than WAL Michael Paquier
2017-01-04Allow PostgresNode.pm tests to wait for catchupSimon Riggs
Add methods to the core test framework PostgresNode.pm to allow us to test that standby nodes have caught up with the master, as well as basic LSN handling. Used in tests recovery/t/001_stream_rep.pl and recovery/t/004_timeline_switch.pl Craig Ringer, reviewed by Aleksander Alekseev and Simon Riggs
2017-01-04Make wal streaming the default mode for pg_basebackupMagnus Hagander
Since streaming is now supported for all output formats, make this the default as this is what most people want. To get the old behavior, the parameter -X none can be specified to turn it off. This also removes the parameter -x for fetch, now requiring -X fetch to be specified to use that. Reviewed by Vladimir Rusinov, Michael Paquier and Simon Riggs
2016-10-19Use pg_ctl promote -w in TAP testsPeter Eisentraut
Switch TAP tests to use the new wait mode of pg_ctl promote. This allows avoiding extra logic with poll_query_until() to be sure that a promoted standby is ready for read-write queries. From: Michael Paquier <[email protected]>
2016-10-19initdb pg_basebackup: Rename --noxxx options to --no-xxxPeter Eisentraut
--noclean and --nosync were the only options spelled without a hyphen, so change this for consistency with other options. The options in pg_basebackup have not been in a release, so we just rename them. For initdb, we retain the old variants. Vik Fearing and me
2016-10-05Update obsolete comments and perldoc.Robert Haas
Loose ends from commit 2a0f89cd717ce6d49cdc47850577823682167e87. Daniel Gustafsson
2016-10-01Set log_line_prefix and application name in test driversPeter Eisentraut
Before pg_regress runs psql, set the application name to the test name. Similarly, set the application name to the test file name in the TAP tests. Also, set a default log_line_prefix that show the application name, as well as the PID and a time stamp. That way, the server log output can be correlated to the test input files, making debugging a bit easier.
2016-09-29Switch pg_basebackup commands in Postgres.pm to use --nosyncPeter Eisentraut
On slow machines, this greatly reduces the I/O pressure induced by the tests. From: Michael Paquier <[email protected]>
2016-09-22Add tests for various connection string issuesPeter Eisentraut
Add tests for consistent support of connection strings in frontend programs as well as proper handling of unusual characters in database and user names. These tests were developed for the issues of CVE-2016-5424. To allow testing of names with spaces, change the pg_regress command-line options --create-role and --dbname to split their arguments by comma only, not space or comma as before. Only commas were actually used in existing uses. Noah Misch, Michael Paquier, Peter Eisentraut
2016-08-15Final pgindent + perltidy run for 9.6.Tom Lane
2016-07-25Give recovery tests more time to finishAlvaro Herrera
These tests are currently only running in buildfarm member hamster, which is purposefully very slow. This suite has failed a couple of times recently because of timeouts, so increase the allowed number of iterations to avoid spurious failures. Author: Michaël Paquier
2016-07-09Fix TAP tests and MSVC scripts for pathnames with spaces.Tom Lane
Change assorted places in our Perl code that did things like system("prog $path/file"); to do it more like system('prog', "$path/file"); which is safe against spaces and other special characters in the path variable. The latter was already the prevailing style, but a few bits of code hadn't gotten this memo. Back-patch to 9.4 as relevant. Michael Paquier, Kyotaro Horiguchi Discussion: <[email protected]>
2016-06-12Finish pgindent run for 9.6: Perl files.Noah Misch
2016-04-26Fix order of shutdown cleanup operations in PostgresNode.pm.Tom Lane
Previously, database clusters created by a TAP test were shut down by DESTROY methods attached to the PostgresNode objects representing them. The trouble with that is that if the objects survive into the final global destruction phase (which they do), Perl executes the DESTROY methods in an unspecified order. Thus, the order of shutdown of multiple clusters was indeterminate, which might lead to not-very-reproducible errors getting logged (eg from a slave whose master might or might not get killed first). Worse, the File::Temp objects representing the temporary PGDATA directories might get destroyed before the PostgresNode objects, resulting in attempts to delete PGDATA directories that still have live servers in them. On Windows, this would lead to directory deletion failures; on Unix, it usually had no effects worse than erratic "could not open temporary statistics file "pg_stat/global.tmp": No such file or directory" log messages. While none of this would affect the reported result of the TAP test, which is already determined, it could be very confusing when one is trying to understand from the logs what went wrong with a failed test. To fix, do the postmaster shutdowns in an END block rather than at object destruction time. The END block will execute at a well-defined (and reasonable) time during script termination, and it will stop the postmasters in order of PostgresNode object creation. (Perhaps we should change that to be reverse order of creation, but the main point here is that we now have control which we did not before.) Use "pg_ctl stop", not an asynchronous kill(SIGQUIT), so that we wait for the postmasters to shut down before proceeding with directory deletion. Deletion of temporary directories still happens in an unspecified order during global destruction, but I can see no reason to care about that once the postmasters are stopped.
2016-04-25Try harder to detect a port conflict in PostgresNode.pm.Tom Lane
Commit fab84c7787f25756 tried to get away without doing an actual bind(), but buildfarm results show that that doesn't get the job done. So we must really bind to the target port --- and at least on my Linux box, we need a listen() as well, or conflicts won't be detected. We rely on SO_REUSEADDR to prevent problems from starting a postmaster on the socket immediately after we've bound to it in the test code. (There may be platforms where that doesn't work too well. But fortunately, we only really care whether this works on Windows, and there the default behavior should be OK.)
2016-04-24Improve PostgresNode.pm's logic for detecting already-in-use ports.Tom Lane
Buildfarm members bowerbird and jacana have shown intermittent "could not bind IPv4 socket" failures in the BinInstallCheck stage since mid-December, shortly after commits 1caef31d9e550408 and 9821492ee417a591 changed the logic for selecting which port to use in temporary installations. One plausible explanation is that we are randomly selecting ports that are already in use for some non-Postgres purpose. Although the code tried to defend against already-in-use ports, it used pg_isready to probe the port which is quite unhelpful: if some non-Postgres server responds at the given address, pg_isready will generally say "no response", leading to exactly the wrong conclusion about whether the port is free. Instead, let's use a simple TCP connect() call to see if anything answers without making assumptions about what it is. Note that this means there's no direct check for a conflicting Unix socket, but that should be okay because there should be no other Unix sockets in use in the temporary socket directory created for a test run. This is only a partial solution for the TCP case, since if the port number is in use for an outgoing connection rather than a listening socket, we'll fail to detect that. We could try to bind() to the proposed port as a means of detecting that case, but that would introduce its own failure modes, since the system might consider the address to remain reserved for some period of time after we drop the bound socket. Close study of the errors returned by bowerbird and jacana suggests that what we're seeing there may be conflicts with listening not outgoing sockets, so let's try this and see if it improves matters. It's certainly better than what's there now, in any case. Michael Paquier, adjusted by me to work on non-Windows as well as Windows
2016-04-08Add regression tests for multiple synchronous standbys.Fujii Masao
Authors: Suraj Kharage, Michael Paquier, Masahiko Sawada, refactored by me Reviewed-By: Kyotaro Horiguchi
2016-03-28PostgresNode: initialize $timed_out if passedAlvaro Herrera
Corrects an oversight in 2c83f435a3 where the $timed_out reference var isn't initialized; using it would require the caller to initialize it beforehand, which is cumbersome. Author: Craig Ringer
2016-03-18Merge wal_level "archive" and "hot_standby" into new name "replica"Peter Eisentraut
The distinction between "archive" and "hot_standby" existed only because at the time "hot_standby" was added, there was some uncertainty about stability. This is now a long time ago. We would like to move forward with simplifying the replication configuration, but this distinction is in the way, because a primary server cannot tell (without asking a standby or predicting the future) which one of these would be the appropriate level. Pick a new name for the combined setting to make it clearer that it covers all (non-logical) backup and replication uses. The old values are still accepted but are converted internally. Reviewed-by: Michael Paquier <[email protected]> Reviewed-by: David Steele <[email protected]>
2016-03-09PostgresNode: add backup_fs_hot and backup_fs_coldAlvaro Herrera
These simple methods rely on RecursiveCopy to create a filesystem-level backup of a server. They aren't currently used anywhere yet,but will be useful for future tests. Author: Craig Ringer Reviewed-By: Michael Paquier, Salvador Fandino, Álvaro Herrera Commitfest-URL: https://commitfest.postgresql.org/9/569/
2016-03-03Rework PostgresNode's psql methodAlvaro Herrera
This makes the psql() method much more capable: it captures both stdout and stderr; it now returns the psql exit code rather than stdout; a timeout can now be specified, as can ON_ERROR_STOP behavior; it gained a new "on_error_die" (defaulting to off) parameter to raise an exception if there's any problem. Finally, additional parameters to psql can be passed if there's need for further tweaking. For convenience, a new safe_psql() method retains much of the old behavior of psql(), except that it uses on_error_die on, so that problems like syntax errors in SQL commands can be detected more easily. Many existing TAP test files now use safe_psql, which is what is really wanted. A couple of ->psql() calls are now added in the commit_ts tests, which verify that the right thing is happening on certain errors. Some ->command_fails() calls in recovery tests that were verifying that psql failed also became ->psql() calls now. Author: Craig Ringer. Some tweaks by Álvaro Herrera Reviewed-By: Michaël Paquier
2016-03-03perltidy PostgresNode and SimpleTeeAlvaro Herrera
Also, mention in README that Perl files should be perltidy'ed. This isn't really the best place (since we have Perl files elsewhere in the tree) and this is already in pgindent's README, but this subdir is likely to get hacked a whole lot more than the other Perl files, so it seems okay to spend two lines on this. Author: Craig Ringer
2016-03-02Prefix temp data dirs with the node nameAlvaro Herrera
This makes it easier to relate the temporary data dirs to each node in a test script. Author: Kyotaro Horiguchi Reviewed-By: Craig Ringer, Alvaro Herrera
2016-02-26Apply last revision of recovery patchAlvaro Herrera
I applied the previous-to-last revision of Michaël's submitted patch instead of the last; these two tweaks pointed out by Craig were left out of the previous commit by accident.
2016-02-26Add a test framework for recoveryAlvaro Herrera
This long-awaited framework is an expansion of the existing PostgresNode stuff to support additional features for recovery testing; the recovery tests included in this commit are a starting point that cover some of the recovery features we have. More scripts are expected to be added later. Author: Michaël Paquier, a bit of help from Amir Rohan Reviewed by: Amir Rohan, Stas Kelvich, Kyotaro Horiguchi, Victor Wagner, Craig Ringer, Álvaro Herrera Discussion: http://www.postgresql.org/message-id/CAB7nPqTf7V6rswrFa=q_rrWeETUWagP=h8LX8XAov2Jcxw0DRg@mail.gmail.com Discussion: http://www.postgresql.org/message-id/trinity-b4a8035d-59af-4c42-a37e-258f0f28e44a-1443795007012@3capp-mailcom-lxa08
2016-02-26Move some code from RewindTest into PostgresNodeAlvaro Herrera
Some code in the RewindTest test suite is more generally useful than just for that suite, so put it where other test suites can reach it. Some postgresql.conf parameters change their default values when a cluster is initialized with 'allows_streaming' than the previous behavior; most notably, autovacuum is no longer turned off. (Also, we no longer call pg_ctl promote with -w, but that flag doesn't actually do anything in promote so there's no behavior change.) Author: Michael Paquier
2016-02-26Add POD docs to PostgresNodeAlvaro Herrera
Also, the dump_info method got split into another method that returns the stuff as a string instead of just printing it to stdout. Add a new README in src/test/perl too. Author: Craig Ringer Reviewed by: Michaël Paquier
2016-02-11In pg_rewind test suite, triple promote timeout to 90s.Noah Misch
Thirty seconds was not consistently enough for promotion to complete on buildfarm members sungazer and tern. Experiments suggest 43s would have been enough. Back-patch to 9.5, where pg_rewind was introduced.
2016-01-20PostgresNode: Add names to nodesAlvaro Herrera
This makes the log files easier to follow when investigating a test failure. Author: Michael Paquier Review: Noah Misch
2015-12-08psql: Support multiple -c and -f options, and allow mixing them.Robert Haas
To support this, we must reconcile some historical anomalies in the behavior of -c. In particular, as a backward-incompatibility, -c no longer implies --no-psqlrc. Pavel Stehule (code) and Catalin Iacob (documentation). Review by Michael Paquier and myself. Proposed behavior per Tom Lane.
2015-12-07PostgresNode: wrap correctly around port number range endAlvaro Herrera
Per note from Tom Lane
2015-12-07Cleanup some problems in new Perl test codeAlvaro Herrera
Noted by Tom Lane: - PostgresNode had a BEGIN block which created files, contrary to perlmod suggestions to do that only on INIT blocks. - Assign ports randomly rather than starting from 90600. Noted by Noah Misch: - Change use of no-longer-set PGPORT environment variable to $node->port - Don't start a server in pg_controldata test - PostgresNode was reading the PID file incorrectly; test the right thing, and chomp the line we read from the PID file. - Remove an unused $devnull variable - Use 'pg_ctl kill' instead of "kill" directly, for Windos portability. - Make server log names more informative. Author: Michael Paquier
2015-12-02Refactor Perl test codeAlvaro Herrera
The original code was a bit clunky; make it more amenable for further reuse by creating a new Perl package PostgresNode, which is an object-oriented representation of a single server, with some support routines such as init, start, stop, psql. This serves as a better basis on which to build further test code, and enables writing tests that use more than one server without too much complication. This commit modifies a lot of the existing test files, mostly to remove explicit calls to system commands (pg_ctl) replacing them with method calls of a PostgresNode object. The result is quite a bit more straightforward. Also move some initialization code to BEGIN and INIT blocks instead of having it straight in as top-level code. This commit also introduces package RecursiveCopy so that we can copy whole directories without having to depend on packages that may not be present on vanilla Perl 5.8 installations. I also ran perltidy on the modified files, which changes some code sites that are not otherwise touched by this patch. I tried to avoid this, but it ended up being more trouble than it's worth. Authors: Michael Paquier, Álvaro Herrera Review: Noah Misch