Use "template" data directory in tests
authorAndres Freund <andres@anarazel.de>
Thu, 24 Aug 2023 21:17:03 +0000 (14:17 -0700)
committerAndres Freund <andres@anarazel.de>
Thu, 24 Aug 2023 21:38:02 +0000 (14:38 -0700)
commit252dcb32397f64a5e1ceac05b29a271ab19aa960
tree78bdd6b97400ebb07bcec001dc85ad7fe4ece3b4
parent9625845532ae03e7da3fc8fc592c6ec333b93166
Use "template" data directory in tests

When running all (or just many) of our tests, a significant portion of both
CPU time and IO is spent running initdb. Most of those initdb runs don't
specify any options influencing properties of the created data directory.

Avoid most of that overhead by creating a "template" data directory, alongside
the temporary installation. Instead of running initdb, pg_regress and tap
tests can copy that data directory. When a tap test specifies options to
initdb, the template data directory is not used. That could be relaxed for
some options, but it's not clear it's worth the effort.

There unfortunately is some duplication between pg_regress.c and Cluster.pm,
but there are no easy ways of sharing that code without introducing additional
complexity.

Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/20220120021859.3zpsfqn4z7ob7afz@alap3.anarazel.de
.cirrus.tasks.yml
meson.build
src/Makefile.global.in
src/test/perl/PostgreSQL/Test/Cluster.pm
src/test/regress/pg_regress.c