profiler: stop using runProfile in tests #3590
Draft
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.
In general, we should prefer testing the profiler with as close to the API
customers will use as possible. For one, it gives us more confidence that
customers will get the data they expect. Also, it's been a pain to work on the
profiler when internals-only changes break tests that happen to depend on the
internals of the profiler, such as TestRunProfile. This change starts getting
rid of uses of runProfile in particular.
This change gets rid of the CPU and goroutine sub-tests in TestRunProfile since
they really don't assert anything meaningful (other tests already check that
those profiles are present, and mocking their contents doesn't tell us
anything on top of that). For the goroutine wait profile sub-tests, we can at
least remove the dependency on run profile. This change moves those sub-tests
to their own test functions, TestGoroutineWait and TestGoroutinesWaitLimit. For
TestGoroutineWait, we are basically testing converting a debug goroutine
profile to a pprof, so the tests opts to use goroutineDebug2ToPprof directly
rather than hook into the profiler. For TestGoroutinesWaitLimit, we use
startTestProfiler, which is more end-to-end, and make assertions about the
profiles we would upload and the logs we would emit instead of hooking in to
the profiler.
TODO - tackle the "delta" test. We already test the delta implementation pretty
extensively, but it might be good to have some kind of more "end-to-end" test
for that. If we can remove the bits where we hook into the profiler there, I
think we can get rid of the testHooks stuff.