From baa8d5a16ac5ee5e033d633d06c137fb4e4bf06e Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Tue, 29 Nov 2022 13:25:25 +0200 Subject: [PATCH] Test that physical size is the same before and after re-attaching tenant. --- test_runner/fixtures/neon_fixtures.py | 2 ++ .../test_tenants_with_remote_storage.py | 30 +++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/test_runner/fixtures/neon_fixtures.py b/test_runner/fixtures/neon_fixtures.py index 4e66ed677c..d79200108f 100644 --- a/test_runner/fixtures/neon_fixtures.py +++ b/test_runner/fixtures/neon_fixtures.py @@ -2528,6 +2528,7 @@ class SafekeeperTimelineStatus: acceptor_epoch: int pg_version: int flush_lsn: Lsn + commit_lsn: Lsn timeline_start_lsn: Lsn backup_lsn: Lsn remote_consistent_lsn: Lsn @@ -2577,6 +2578,7 @@ class SafekeeperHttpClient(requests.Session): acceptor_epoch=resj["acceptor_state"]["epoch"], pg_version=resj["pg_info"]["pg_version"], flush_lsn=Lsn(resj["flush_lsn"]), + commit_lsn=Lsn(resj["commit_lsn"]), timeline_start_lsn=Lsn(resj["timeline_start_lsn"]), backup_lsn=Lsn(resj["backup_lsn"]), remote_consistent_lsn=Lsn(resj["remote_consistent_lsn"]), diff --git a/test_runner/regress/test_tenants_with_remote_storage.py b/test_runner/regress/test_tenants_with_remote_storage.py index 8fd28cf53e..a7e0433e03 100644 --- a/test_runner/regress/test_tenants_with_remote_storage.py +++ b/test_runner/regress/test_tenants_with_remote_storage.py @@ -160,6 +160,26 @@ def test_tenants_attached_after_download( ##### Stop the pageserver, erase its layer file to force it being downloaded from S3 env.postgres.stop_all() + + sk_commit_lsns = [ + sk.http_client().timeline_status(tenant_id, timeline_id).commit_lsn + for sk in env.safekeepers + ] + log.info("wait for pageserver to process all the WAL") + wait_for_last_record_lsn(client, tenant_id, timeline_id, max(sk_commit_lsns)) + log.info("wait for it to reach remote storage") + pageserver_http.timeline_checkpoint(tenant_id, timeline_id) + wait_for_upload(client, tenant_id, timeline_id, max(sk_commit_lsns)) + log.info("latest safekeeper_commit_lsn reached remote storage") + + detail_before = client.timeline_detail( + tenant_id, timeline_id, include_non_incremental_physical_size=True + ) + assert ( + detail_before["current_physical_size_non_incremental"] + == detail_before["current_physical_size"] + ) + env.pageserver.stop() timeline_dir = Path(env.repo_dir) / "tenants" / str(tenant_id) / "timelines" / str(timeline_id) @@ -186,11 +206,17 @@ def test_tenants_attached_after_download( assert ( len(restored_timelines) == 1 ), f"Tenant {tenant_id} should have its timeline reattached after its layer is downloaded from the remote storage" - retored_timeline = restored_timelines[0] - assert retored_timeline["timeline_id"] == str( + restored_timeline = restored_timelines[0] + assert restored_timeline["timeline_id"] == str( timeline_id ), f"Tenant {tenant_id} should have its old timeline {timeline_id} restored from the remote storage" + # Check that the physical size matches after re-downloading + detail_after = client.timeline_detail( + tenant_id, timeline_id, include_non_incremental_physical_size=True + ) + assert detail_before["current_physical_size"] == detail_after["current_physical_size"] + @pytest.mark.parametrize("remote_storage_kind", [RemoteStorageKind.LOCAL_FS]) def test_tenant_upgrades_index_json_from_v0(