Test that physical size is the same before and after re-attaching tenant.

This commit is contained in:
Heikki Linnakangas
2022-11-29 13:25:25 +02:00
committed by Heikki Linnakangas
parent fbd5f65938
commit baa8d5a16a
2 changed files with 30 additions and 2 deletions

View File

@@ -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"]),

View File

@@ -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(