test(intake): seed ATIF ingest spans relative to now to stay within TTL#587
Merged
Merged
Conversation
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 <[email protected]>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughChanged ChangesTest time basis update
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
gabwow
approved these changes
Jul 7, 2026
SandyChapman
enabled auto-merge
July 7, 2026 16:13
Contributor
|
BrianNewsom
approved these changes
Jul 7, 2026
arpitsardhana
pushed a commit
that referenced
this pull request
Jul 9, 2026
…TL (#587) 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 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
test_atif_ingest_accepts_example_trajectory_and_reconstructs_read_side_dataintermittently failsassert 0 == 7(read-side spans empty), and has been blocking the merge queue for unrelated PRs (e.g. #561, which passed only on a lucky re-queue).Root cause
Two issues, both introduced by #580 (
9d16a122c4) when it swapped the test's relativenow() - timedelta(hours=2)seed for a fixed_BASE_TIME = datetime(2026, 1, 15)(µs=0):TTL toDate(start_time) + INTERVAL 90 DAY(services/intake/src/nmp/intake/spans/clickhouse_migrations.py:142,:295). The fixed2026-01-15seed is now ~170+ days in the past — beyond the 90-day TTL — so the rows are eligible for eviction. TTL eviction runs on async background merges, so the read returns 7 or 0 depending on whether a merge fired first → flaky red....:12(no fractional part) while_span_started_atformats...:12.000000, failing the exact-timestamp assertion. The pre-fix(intake): remove implicit 30-day lookback from span/trace lists; s… #580now()-2hseed always had sub-second µs and avoided this.Repro: same payload dated
now()-2h→session_only=7, gte=7; dated2026-01-15→0/0(verified locally). Querying bysession_idonly (no time filter) is also 0, confirming it's storage-side TTL, not the removed list lookback.Fix
Seed
_BASE_TIMErelative tonow()(~45 days back) with a fixed.500000µs offset:.500000µs ensures no derived timestamp lands on a whole second.Everything derived from the base moves with it, so all reconstructed-timestamp assertions stay exact. Keeps #580's explicit-
gtequery behavior.Testing
services/intake/tests/integration/spans/test_atif_ingest.py→ 16 passed, on two consecutive runs (stable).ruff check/ruff formatclean.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests