From 8a5a739af0c66acc061a5a0f1192e1759ce47738 Mon Sep 17 00:00:00 2001 From: "Alex Chi Z." <4198311+skyzh@users.noreply.github.com> Date: Wed, 12 Mar 2025 16:34:19 -0400 Subject: [PATCH] test(pageserver): add small tenant compaction (#11049) ## Problem close https://github.com/neondatabase/neon/issues/10881 ## Summary of changes Mock a tenant with very small amount of data. --------- Signed-off-by: Alex Chi Z --- test_runner/regress/test_compaction.py | 36 ++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test_runner/regress/test_compaction.py b/test_runner/regress/test_compaction.py index 0df88e14c2..c8cce7a4e7 100644 --- a/test_runner/regress/test_compaction.py +++ b/test_runner/regress/test_compaction.py @@ -524,6 +524,42 @@ def test_pageserver_gc_compaction_trigger(neon_env_builder: NeonEnvBuilder): workload.validate(env.pageserver.id) +def test_pageserver_small_tenant_compaction(neon_env_builder: NeonEnvBuilder): + """ + Create a small tenant that rarely needs compaction and ensure that everything works. + """ + SMOKE_CONF = { + # Run both gc and gc-compaction. + "gc_period": "5s", + "compaction_period": "5s", + # No PiTR interval and small GC horizon + "pitr_interval": "0s", + "gc_horizon": 1024, + "lsn_lease_length": "0s", + } + + env = neon_env_builder.init_start(initial_tenant_conf=SMOKE_CONF) + tenant_id = env.initial_tenant + timeline_id = env.initial_timeline + + ps_http = env.pageserver.http_client() + + workload = Workload(env, tenant_id, timeline_id) + workload.init(env.pageserver.id) + + log.info("Writing initial data ...") + workload.write_rows(10000, env.pageserver.id) + + for _ in range(100): + workload.churn_rows(10, env.pageserver.id, upload=False, ingest=False) + ps_http.timeline_checkpoint(tenant_id, timeline_id, wait_until_uploaded=True) + ps_http.timeline_compact(tenant_id, timeline_id) + ps_http.timeline_gc(tenant_id, timeline_id, None) + + log.info("Validating at workload end ...") + workload.validate(env.pageserver.id) + + # Stripe sizes in number of pages. TINY_STRIPES = 16 LARGE_STRIPES = 32768