From f8fe8e91e760e0c937dabd2f153a45e9a1c4d6d2 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 3 Apr 2025 19:47:32 +0200 Subject: [PATCH] tests: reproducer for https://github.com/neondatabase/neon/issues/11439 --- test_runner/regress/test_lsn_mapping.py | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test_runner/regress/test_lsn_mapping.py b/test_runner/regress/test_lsn_mapping.py index 7280a91a12..8f3a8c24d7 100644 --- a/test_runner/regress/test_lsn_mapping.py +++ b/test_runner/regress/test_lsn_mapping.py @@ -276,3 +276,33 @@ def test_ts_of_lsn_api(neon_env_builder: NeonEnvBuilder): if i > 1: before_timestamp = tbl[i - step_size][1] assert timestamp >= before_timestamp, "before_timestamp before timestamp" + + +def test_timestamp_of_lsn_empty_branch(neon_env_builder: NeonEnvBuilder): + """ + Test that getting the timestamp of the head LSN of a newly created branch works. + This verifies that we don't get a 404 error when trying to get the timestamp + of the head LSN of a branch that was just created. + + Reproducer for https://github.com/neondatabase/neon/issues/11439 + """ + env = neon_env_builder.init_start() + + # Create a new branch + new_timeline_id = env.create_branch("test_timestamp_of_lsn_empty_branch") + + # Retrieve the commit LSN of the empty branch, which we have never run postgres on + detail = env.pageserver.http_client().timeline_detail( + tenant_id=env.initial_tenant, timeline_id=new_timeline_id + ) + head_lsn = detail["last_record_lsn"] + + # Verify we can get the timestamp for this LSN + with env.pageserver.http_client() as client: + result = client.timeline_get_timestamp_of_lsn( + env.initial_tenant, + new_timeline_id, + head_lsn, + ) + # If we get here without a 404 error, the test passes + assert result is not None