From 8431adaf0bdf34a040a547b9592e80399bc1e3d9 Mon Sep 17 00:00:00 2001 From: Sandy Chapman Date: Tue, 7 Jul 2026 12:53:09 -0300 Subject: [PATCH] test(intake): seed ATIF ingest spans relative to now to stay within TTL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_atif_ingest_accepts_example_trajectory_and_reconstructs_read_side_data seeded spans at a fixed `_BASE_TIME = 2026-01-15`. The spans/traces ClickHouse tables carry `TTL toDate(start_time) + INTERVAL 90 DAY`, so once that fixed date is >90 days in the past the rows fall out of retention and the read returns nothing (assert 0 == 7). Because TTL eviction runs on async background merges, the failure is flaky — it passes only when no merge evicts the rows before the read, which is why it intermittently blocked the merge queue. Seed relative to `now()` (~45 days back): beyond the removed 30-day list lookback that this test exercises, yet safely inside the 90-day TTL, and no longer a fixed date that rots. Use a .500000 microsecond offset so no derived timestamp lands on a whole second, which the span read-side returns without a fractional part and would fail the exact-timestamp assertions (the pre-#580 `now()-2h` seed avoided this; the fixed µs=0 base introduced in #580 did not). Full module passes repeatedly. Signed-off-by: Sandy Chapman --- .../intake/tests/integration/spans/test_atif_ingest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/services/intake/tests/integration/spans/test_atif_ingest.py b/services/intake/tests/integration/spans/test_atif_ingest.py index 92218ee29b..d538cc1b61 100644 --- a/services/intake/tests/integration/spans/test_atif_ingest.py +++ b/services/intake/tests/integration/spans/test_atif_ingest.py @@ -12,8 +12,14 @@ _HISTORICAL_GTE = "2024-01-01T00:00:00Z" -# Frozen so ingested timestamps (and everything derived from them) are deterministic. -_BASE_TIME = datetime(2026, 1, 15, 12, 0, 0, tzinfo=timezone.utc) +# Seeded relative to "now" (not a fixed calendar date) with a fixed sub-second offset: +# - relative so the spans stay inside the 90-day ClickHouse TTL (see clickhouse_migrations.py); a +# fixed past date silently ages out of retention and this test flakes red (TTL eviction runs on +# async merges). ~45 days is well beyond the (removed) 30-day list lookback yet within retention. +# - .500000 microseconds so no derived timestamp lands on a whole second, which the span read-side +# returns without a fractional part (e.g. "...:12" vs "...:12.000000") and would fail exact matches. +# Everything derived from this base moves with it, so the reconstructed-timestamp assertions stay exact. +_BASE_TIME = (datetime.now(timezone.utc) - timedelta(days=45)).replace(microsecond=500_000) def _atif_timestamp(dt: datetime) -> str: