chore(profiler): remove testHooks and runProfile from tests#4533
Conversation
BenchmarksBenchmark execution time: 2026-03-13 13:40:03 Comparing candidate commit 9bfafcc in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 155 metrics, 9 unstable metrics.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files
🚀 New features to boost your workflow:
|
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 9bfafcc | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
The CPU and goroutine profile cases do nothing useful, and hook into internal stuff, which we shouldn't do. Delete them and remove the now-unused CPU profile test hooks.
f463f4a to
49ff9c4
Compare
The testRunDeltaProfile tests call a bunch of internal profiler stuff. This makes the package painful to refactor. There is some value in confirming that we do delta profiles correctly end-to-end, though. So this commit reworks the test to _mostly_ use the public profiler API. The only internal thing we change is lookupProfile, which we now do through a single global hook so we can set it up without having to grab and modify the private profiler object. Using this, we get a simple but deterministic profiles and can confirm that the delta looks right in the actual profile output that we'd upload to the backend.
The goroutine wait tests have the same problem as the delta tests. They hook into a bunch of profiler internals. The tests do something useful, so we shouldn't completely get rid of them. But they should be reworked to test externally visible behavior as much as possible. As a result of this change, the testHooks struct is unused. The lookupProfile thing is now a global and constrained to only a few tests which actually need it and we don't use the CPU hooks. So, delete it.
49ff9c4 to
9bfafcc
Compare
felixge
left a comment
There was a problem hiding this comment.
LGTM, thanks for doing this 🙇
|
/merge |
|
View all feedbacks in Devflow UI.
The expected merge time in
|
The profiler unit tests still have many places where they hook into
pacakge-internal details. I've wanted to fix this for a while as it frustrates
me every time I try to make changes. I ran into it again recently and I figure
we should rip the band-aid off.
This PR removes the testHook object, and removes all calls to runProfile from
the profiler unit tests. There are three steps (see the commits):
that the profiler returns it.
some assurance that we're actually wiring up the delta profile stuff
properly, vs the internal fastdelta tests which check that the computation is
correct. So we should keep it. We still patch in profiles so that the test
can make determinisitic, meaningful assertions. But we only make assertions
about what gets sent to the backend.
profile we would have uploaded. Break them out into separate test functions
rather than nested in a RunProfile mega test.
I have plans to remove more internal stuff (like
unstartedProfiler) insubsequent changes.