fix(datastreams): make TestProcessor/test_service_name_override deterministic#4517
fix(datastreams): make TestProcessor/test_service_name_override deterministic#4517
Conversation
…ministic The subtest had two bugs causing a timing-sensitive flake: 1. It captured `tp = time.Now().Truncate(bucketDuration)` from the wall clock, making bucket boundaries dependent on real wall-clock time. 2. It asserted against `tp1` (a variable from the outer test scope) instead of the local `tp`, causing incorrect bucket start values if the two timestamps happened to land in different buckets. Fix: replace `time.Now()` with a fixed synthetic time injected via the existing `timeSource` field, and correct the assertions to reference the local `tp`. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files🚀 New features to boost your workflow:
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 781b03c | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
BenchmarksBenchmark execution time: 2026-03-09 16:50:36 Comparing candidate commit 781b03c in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 156 metrics, 8 unstable metrics.
|
What does this PR do?
Fixes a timing-sensitive flake in
TestProcessor/test_service_name_override(
internal/datastreams/processor_test.go) by eliminating two bugs in the subtest.Motivation
The test was flaking in CI:
internal/datastreams TestProcessor/test_service_name_overridefailed with bucket
Starttimestamps off by exactly 10 seconds (one bucket width).Two bugs were causing this:
Wall-clock dependency — the test captured
tp = time.Now().Truncate(bucketDuration)thenasserted that flushed
StatsBucket.Startvalues equalledtp. When CI runners ran slowly,the real clock crossed a bucket boundary mid-test, shifting all Start values by one bucket.
Wrong reference in assertions — all four
Startassertion sites referencedtp1(avariable from the outer
TestProcessorscope) instead of the localtp. This madeassertions incorrect whenever the two timestamps happened to fall in different buckets.
The fix uses the existing
timeSourcefield onProcessorto freeze the processor's clockto a fixed synthetic time, and corrects the assertion references.
No production code was changed.
Reviewer's Checklist
make lintlocally. ✓make testlocally. ✓ (fullinternal/datastreamssuite passes, test verified across 5 runs)make generatelocally. — N/AUnsure? Have a question? Request a review!