From eb3fd7a8da5b0bab8691cbbb7725fcdd854878dd Mon Sep 17 00:00:00 2001 From: anastasia Date: Fri, 3 Sep 2021 17:47:38 +0300 Subject: [PATCH] print diff for mismatching files in check_restored_datadir_content() --- .../batch_pg_regress/test_pg_regress.py | 3 +-- test_runner/fixtures/zenith_fixtures.py | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/test_runner/batch_pg_regress/test_pg_regress.py b/test_runner/batch_pg_regress/test_pg_regress.py index 32b056a330..aa00865e89 100644 --- a/test_runner/batch_pg_regress/test_pg_regress.py +++ b/test_runner/batch_pg_regress/test_pg_regress.py @@ -55,5 +55,4 @@ def test_pg_regress(pageserver: ZenithPageserver, postgres: PostgresFactory, pg_ lsn = pg.safe_psql('select pg_current_wal_insert_lsn()')[0][0] # Check that we restore the content of the datadir correctly - # FIXME Now it fails on pg_xact for some reason - # check_restored_datadir_content(zenith_cli, pg, lsn, postgres) + check_restored_datadir_content(zenith_cli, pg, lsn, postgres) diff --git a/test_runner/fixtures/zenith_fixtures.py b/test_runner/fixtures/zenith_fixtures.py index 6665a4ec8d..decfee6103 100644 --- a/test_runner/fixtures/zenith_fixtures.py +++ b/test_runner/fixtures/zenith_fixtures.py @@ -11,6 +11,7 @@ import signal import subprocess import time import filecmp +import difflib from contextlib import closing from pathlib import Path @@ -956,10 +957,10 @@ def check_restored_datadir_content(zenith_cli, pg, lsn, postgres: PostgresFactor # create new branch, but don't start postgres # We only need 'basebackup' result here. zenith_cli.run( - ["branch", "new", pg.branch + "@" + lsn]) + ["branch", "check_restored_datadir", pg.branch + "@" + lsn]) - pg2 = postgres.create('new') - print('postgres is created on new branch') + pg2 = postgres.create('check_restored_datadir') + print('postgres is created on check_restored_datadir branch') print('files in a basebackup') # list files we're going to compare @@ -979,4 +980,18 @@ def check_restored_datadir_content(zenith_cli, pg, lsn, postgres: PostgresFactor print('filecmp result mismatch and error lists:') print(mismatch) print(error) + + for f in mismatch: + + f1 = os.path.join(pg.pgdata_dir, f) + f2 = os.path.join(pg2.pgdata_dir, f) + stdout_filename = "{}.diff".format(f2) + + with open(stdout_filename, 'w') as stdout_f: + subprocess.run("xxd -b {} > {}.hex ".format(f1, f1), shell=True) + subprocess.run("xxd -b {} > {}.hex ".format(f2, f2), shell=True) + + cmd = ['diff {}.hex {}.hex'.format(f1, f2)] + subprocess.run(cmd, stdout=stdout_f, shell=True) + assert (mismatch, error) == ([], [])