From de5e6a15ae60b7a4c5f44e5039b609420f7622b1 Mon Sep 17 00:00:00 2001 From: Alexey Kondratov Date: Thu, 11 Nov 2021 13:04:58 +0300 Subject: [PATCH] Set LD_LIBRARY_PATH in the check_restored_datadir_content() psql call Otherwise we may use outdated system libpq. Also print stdout/stderr if basebackup failed in check_restored_datadir_content() --- test_runner/fixtures/zenith_fixtures.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test_runner/fixtures/zenith_fixtures.py b/test_runner/fixtures/zenith_fixtures.py index 6330b28094..326cb060d1 100644 --- a/test_runner/fixtures/zenith_fixtures.py +++ b/test_runner/fixtures/zenith_fixtures.py @@ -1219,7 +1219,17 @@ def check_restored_datadir_content(test_output_dir: str, env: ZenithEnv, pg: Pos | tar -x -C {restored_dir_path} """ - subprocess.check_call(cmd, shell=True) + # Set LD_LIBRARY_PATH in the env properly, otherwise we may use the wrong libpq. + # PgBin sets it automatically, but here we need to pipe psql output to the tar command. + psql_env = {'LD_LIBRARY_PATH': os.path.join(str(pg_distrib_dir), 'lib')} + result = subprocess.run(cmd, env=psql_env, capture_output=True, text=True, shell=True) + + # Print captured stdout/stderr if basebackup cmd failed. + if result.returncode != 0: + log.error('Basebackup shell command failed with:') + log.error(result.stdout) + log.error(result.stderr) + assert result.returncode == 0 # list files we're going to compare assert pg.pgdata_dir