From abb4112a28a9d3fb04785369972e5477cbcb3f89 Mon Sep 17 00:00:00 2001 From: Christian Schwarz Date: Wed, 7 Jun 2023 15:04:55 +0200 Subject: [PATCH] fixup: test_pageserver_metrics_removed_after_detach[debug-pg14-noop]' last_flush_lsn_upload obviously doesn't work with NOOP storage kind but we need the on-disk state at that lsn, so, wait for on-disk consistent in that case --- test_runner/fixtures/neon_fixtures.py | 20 ++++++++++++++++---- test_runner/regress/test_tenants.py | 6 +++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/test_runner/fixtures/neon_fixtures.py b/test_runner/fixtures/neon_fixtures.py index 551faa116e..6ee5b180ce 100644 --- a/test_runner/fixtures/neon_fixtures.py +++ b/test_runner/fixtures/neon_fixtures.py @@ -3064,6 +3064,21 @@ def fork_at_current_lsn( return env.neon_cli.create_branch(new_branch_name, ancestor_branch_name, tenant_id, current_lsn) +def last_flush_lsn_checkpoint( + env: NeonEnv, endpoint: Endpoint, tenant_id: TenantId, timeline_id: TimelineId +) -> Lsn: + """ + Wait for pageserver to catch to the latest flush LSN of given endpoint, then + checkpoint pageserver. + """ + last_flush_lsn = wait_for_last_flush_lsn(env, endpoint, tenant_id, timeline_id) + ps_http = env.pageserver.http_client() + wait_for_last_record_lsn(ps_http, tenant_id, timeline_id, last_flush_lsn) + # force a checkpoint to trigger upload + ps_http.timeline_checkpoint(tenant_id, timeline_id) + return last_flush_lsn + + def last_flush_lsn_upload( env: NeonEnv, endpoint: Endpoint, tenant_id: TenantId, timeline_id: TimelineId ) -> Lsn: @@ -3072,10 +3087,7 @@ def last_flush_lsn_upload( checkpoint pageserver, and wait for it to be uploaded (remote_consistent_lsn reaching flush LSN). """ - last_flush_lsn = wait_for_last_flush_lsn(env, endpoint, tenant_id, timeline_id) + last_flush_lsn = last_flush_lsn_checkpoint(env, endpoint, tenant_id, timeline_id) ps_http = env.pageserver.http_client() - wait_for_last_record_lsn(ps_http, tenant_id, timeline_id, last_flush_lsn) - # force a checkpoint to trigger upload - ps_http.timeline_checkpoint(tenant_id, timeline_id) wait_for_upload(ps_http, tenant_id, timeline_id, last_flush_lsn) return last_flush_lsn diff --git a/test_runner/regress/test_tenants.py b/test_runner/regress/test_tenants.py index f03bce6e6f..946bb4ef34 100644 --- a/test_runner/regress/test_tenants.py +++ b/test_runner/regress/test_tenants.py @@ -20,6 +20,7 @@ from fixtures.neon_fixtures import ( NeonEnvBuilder, RemoteStorageKind, available_remote_storages, + last_flush_lsn_checkpoint, last_flush_lsn_upload, ) from fixtures.types import Lsn, TenantId, TimelineId @@ -275,7 +276,10 @@ def test_pageserver_metrics_removed_after_detach( cur.execute("INSERT INTO t SELECT generate_series(1,100000), 'payload'") cur.execute("SELECT sum(key) FROM t") assert cur.fetchone() == (5000050000,) - last_flush_lsn_upload(env, endpoint, endpoint.tenant_id, timeline_id) + if remote_storage_kind != RemoteStorageKind.NOOP: + last_flush_lsn_upload(env, endpoint, endpoint.tenant_id, timeline_id) + else: + last_flush_lsn_checkpoint(env, endpoint, endpoint.tenant_id, timeline_id) endpoint.stop() def get_ps_metric_samples_for_tenant(tenant_id: TenantId) -> List[Sample]: