Commit 4591885
authored
chore(profiling): remove duplicate tests and unneeded test functions (#15403)
## Description
This PR updates tests to be less verbose, and to successfully pass even
if we have different allocation counts between snapshots.
This PR removes:
- 6 deprecated test functions that were using the old `test_snapshot()`
API
- The `test_snapshot()` method itself from `MemoryCollector`
- The `MemorySample` NamedTuple class that was only used by
`test_snapshot()`
These tests are safely redundant because their functionality is now
comprehensively covered by newer tests that use the
`snapshot_and_parse_pprof()` API, which validates against actual pprof
profiles (the format we actually export).
### 1. `test_heap_profiler_sampling_accuracy()`
**Why it's safe to remove:**
- **Covered by:**
`test_memory_collector_allocation_accuracy_with_tracemalloc()`
- **Coverage:** The replacement test validates sampling accuracy using
tracemalloc as ground truth, testing allocation counts and size accuracy
across multiple sample intervals (256, 512, 1024 bytes)
- **Improvements:** The new test uses the pprof-based approach and
validates both size and count accuracy with statistical assertions
### 2. `test_iter_events()`
**Why it's safe to remove:**
- **Covered by:**
- `test_memory_collector()` - validates allocation capture and sample
structure from pprof profiles
- `test_memory_collector_allocation_accuracy_with_tracemalloc()` -
validates allocation counts and accuracy
- **Coverage:** Both replacement tests verify that allocations are
captured with correct stack traces, thread IDs, and counts from actual
pprof exports
### 3. `test_iter_events_dropped()`
**Why it's safe to remove:**
- **Covered by:**
- `test_memory_collector()` - validates that allocations are captured
- `test_memory_collector_allocation_accuracy_with_tracemalloc()` -
validates allocation counts meet expected thresholds
- **Coverage:** These tests verify that samples aren't improperly
dropped and allocation counts are accurate
### 4. `test_iter_events_not_started()`
**Why it's safe to remove:**
- **Edge case behavior changed:** The new `snapshot_and_parse_pprof()`
API throws an error if the collector hasn't been started, rather than
returning an empty tuple
- **Not safety-critical:** This tested an edge case that would be caught
immediately in any real usage
- **Better failure mode:** An exception is more obvious than silently
returning empty data
### 5. `test_iter_events_multi_thread()`
**Why it's safe to remove:**
- **Covered by:**
- `test_memory_collector_thread_lifecycle()` - validates allocations
across multiple threads that are created and destroyed dynamically
- `test_memory_collector_buffer_pool_exhaustion()` - validates
concurrent thread allocations with deep stack traces
- **Coverage:** Both tests verify multi-threaded allocation tracking,
with the newer tests being more comprehensive (testing thread lifecycle
and concurrent stress scenarios)
### 6. `test_heap()` and `_test_heap_impl()` helper
**Why it's safe to remove:**
- **Covered by:**
- `test_memory_collector_allocation_tracking_across_snapshots()` -
validates heap (live) vs freed samples with deletions and garbage
collection
- `test_memory_collector_python_interface_with_allocation_tracking()` -
validates multiple snapshot cycles with allocations and frees
- **Coverage:** The replacement tests validate the same behavior
(tracking live vs freed allocations) but using the pprof-based approach
and with more comprehensive scenarios
## Testing
<!-- Describe your testing strategy or note what tests are included -->
## Risks
<!-- Note any risks associated with this change, or "None" if no risks
-->
## Additional Notes
<!-- Any other information that would be helpful for reviewers -->1 parent fc99201 commit 4591885
File tree
2 files changed
+41
-383
lines changed- ddtrace/profiling/collector
- tests/profiling/collector
2 files changed
+41
-383
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | 8 | | |
11 | | - | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
15 | | - | |
16 | | - | |
17 | 12 | | |
18 | 13 | | |
19 | 14 | | |
| |||
30 | 25 | | |
31 | 26 | | |
32 | 27 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 28 | | |
45 | 29 | | |
46 | 30 | | |
| |||
101 | 85 | | |
102 | 86 | | |
103 | 87 | | |
104 | | - | |
| 88 | + | |
105 | 89 | | |
106 | 90 | | |
107 | 91 | | |
| |||
111 | 95 | | |
112 | 96 | | |
113 | 97 | | |
114 | | - | |
| 98 | + | |
115 | 99 | | |
116 | 100 | | |
117 | 101 | | |
| |||
138 | 122 | | |
139 | 123 | | |
140 | 124 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | 125 | | |
167 | 126 | | |
168 | 127 | | |
| |||
193 | 152 | | |
194 | 153 | | |
195 | 154 | | |
196 | | - | |
197 | | - | |
198 | | - | |
0 commit comments