Separate Postgres build dir from installation dir.

Previously, Postgres was built in 'tmp_install/build', and installed
into 'tmp_install'. In the CI, the 'build' directory was included in
the final neon.tar.zst artifact that includes all the necessary
binaries. That was unnecessary, the intermediate build results are not
needed, only the final binaries. Separate the build directory so that
the Postgres build happens in 'build', and it is installed into
'tmp_install'. That makes the final neon.tar.zst artifact smaller.

The changes to the python tests are needed to find the 'pg_regress'
binary in the installation directory. Previously, they would use the
'pg_regress' binary from the build directory, not the final
installation location.
This commit is contained in:
Heikki Linnakangas
2022-07-20 15:39:51 +03:00
parent e7c9d66956
commit 1bc18f2cf2
7 changed files with 68 additions and 37 deletions

View File

@@ -20,18 +20,22 @@ def test_isolation(neon_simple_env: NeonEnv, test_output_dir: Path, pg_bin, caps
runpath = test_output_dir / 'regress'
(runpath / 'testtablespace').mkdir(parents=True)
# Find the pg_isolation_regress binary
proc = pg_bin.run(['pg_config', '--libdir'], capture_output=True)
libdir = proc.stdout.decode().strip()
proc = pg_bin.run(['pg_config', '--bindir'], capture_output=True)
bindir = proc.stdout.decode().strip()
pg_isolation_regress = os.path.join(libdir,
'postgresql/pgxs/src/test/isolation/pg_isolation_regress')
# Compute all the file locations that pg_isolation_regress will need.
build_path = os.path.join(pg_distrib_dir, 'build/src/test/isolation')
src_path = os.path.join(base_dir, 'vendor/postgres/src/test/isolation')
bindir = os.path.join(pg_distrib_dir, 'bin')
schedule = os.path.join(src_path, 'isolation_schedule')
pg_isolation_regress = os.path.join(build_path, 'pg_isolation_regress')
pg_isolation_regress_command = [
pg_isolation_regress,
'--use-existing',
'--bindir={}'.format(bindir),
'--dlpath={}'.format(build_path),
'--inputdir={}'.format(src_path),
'--schedule={}'.format(schedule),
]

View File

@@ -20,19 +20,22 @@ def test_neon_regress(neon_simple_env: NeonEnv, test_output_dir: Path, pg_bin, c
runpath = test_output_dir / 'regress'
(runpath / 'testtablespace').mkdir(parents=True)
# Find the pg_regress binary and --bindir option to pass to it.
proc = pg_bin.run(['pg_config', '--libdir'], capture_output=True)
libdir = proc.stdout.decode().strip()
proc = pg_bin.run(['pg_config', '--bindir'], capture_output=True)
bindir = proc.stdout.decode().strip()
pg_regress = os.path.join(libdir, 'postgresql/pgxs/src/test/regress/pg_regress')
# Compute all the file locations that pg_regress will need.
# This test runs neon specific tests
build_path = os.path.join(pg_distrib_dir, 'build/src/test/regress')
src_path = os.path.join(base_dir, 'test_runner/neon_regress')
bindir = os.path.join(pg_distrib_dir, 'bin')
schedule = os.path.join(src_path, 'parallel_schedule')
pg_regress = os.path.join(build_path, 'pg_regress')
pg_regress_command = [
pg_regress,
'--use-existing',
'--bindir={}'.format(bindir),
'--dlpath={}'.format(build_path),
'--schedule={}'.format(schedule),
'--inputdir={}'.format(src_path),
]

View File

@@ -19,19 +19,23 @@ def test_pg_regress(neon_simple_env: NeonEnv, test_output_dir: pathlib.Path, pg_
runpath = test_output_dir / 'regress'
(runpath / 'testtablespace').mkdir(parents=True)
# Find the pg_regress binary and --bindir option to pass to it.
proc = pg_bin.run(['pg_config', '--libdir'], capture_output=True)
libdir = proc.stdout.decode().strip()
proc = pg_bin.run(['pg_config', '--bindir'], capture_output=True)
bindir = proc.stdout.decode().strip()
pg_regress = os.path.join(libdir, 'postgresql/pgxs/src/test/regress/pg_regress')
# Compute all the file locations that pg_regress will need.
build_path = os.path.join(pg_distrib_dir, 'build/src/test/regress')
src_path = os.path.join(base_dir, 'vendor/postgres/src/test/regress')
bindir = os.path.join(pg_distrib_dir, 'bin')
schedule = os.path.join(src_path, 'parallel_schedule')
pg_regress = os.path.join(build_path, 'pg_regress')
dlpath = os.path.join(base_dir, 'build/src/test/regress')
pg_regress_command = [
pg_regress,
'--bindir=""',
'--use-existing',
'--bindir={}'.format(bindir),
'--dlpath={}'.format(build_path),
'--dlpath={}'.format(dlpath),
'--schedule={}'.format(schedule),
'--inputdir={}'.format(src_path),
]

View File

@@ -1372,7 +1372,10 @@ class PgBin:
env.update(env_add)
return env
def run(self, command: List[str], env: Optional[Env] = None, cwd: Optional[str] = None):
def run(self,
command: List[str],
env: Optional[Env] = None,
**kwargs) -> 'subprocess.CompletedProcess[str]':
"""
Run one of the postgres binaries.
@@ -1389,7 +1392,7 @@ class PgBin:
self._fixpath(command)
log.info('Running command "{}"'.format(' '.join(command)))
env = self._build_env(env)
subprocess.run(command, env=env, cwd=cwd, check=True)
return subprocess.run(command, env=env, check=True, **kwargs)
def run_capture(self,
command: List[str],