Commit 0fe9ef4
fix: await async metric delivery in metrics collection tests (#490)
## Which issue does this PR close?
Closes #487.
## Rationale for this change
`test_metrics_collection_e2e_1` flakes intermittently in CI, panicking
on `Option::unwrap()` of a `None` value at the task-key lookup in
`run_metrics_collection_e2e_test` (e.g. [this
run](https://github.com/datafusion-contrib/datafusion-distributed/actions/runs/27137166880/job/80101529756)).
Per-task metrics are delivered to the coordinator asynchronously over
the `WorkerToCoordinator` side channel by a background task, which may
still be in flight after `execute_plan` returns. The test asserted on
the collected metrics immediately, racing that delivery, so a task key
was occasionally still absent from the `MetricsStore` when the assertion
ran.
## What changes are included in this PR?
- Add a `wait_for_task_metrics` test helper that waits on the
`MetricsStore` watch channel until every expected task key is present
before asserting, bounded by a 10s timeout that reports any
still-missing keys. This mirrors the existing
`DistributedExec::wait_for_metrics` pattern but waits on exactly the
task keys the assertions check.
- Use it in `run_metrics_collection_e2e_test` (covers `_e2e_1` and
`_e2e_2`).
- `test_metrics_collection_with_limit_causing_early_stream_termination`
had the same race papered over with a single `yield_now().await`;
replace that with the same deterministic wait.
## Are there any user-facing changes?
No. Test-only change.
---------
Signed-off-by: sjhddh <151469562+sjhddh@users.noreply.github.com>
Co-authored-by: sjhddh <151469562+sjhddh@users.noreply.github.com>1 parent 09c2b18 commit 0fe9ef4
1 file changed
Lines changed: 15 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
175 | 181 | | |
176 | 182 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 183 | + | |
183 | 184 | | |
184 | 185 | | |
185 | 186 | | |
| |||
294 | 295 | | |
295 | 296 | | |
296 | 297 | | |
297 | | - | |
298 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
299 | 301 | | |
300 | 302 | | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
309 | 306 | | |
310 | 307 | | |
311 | | - | |
312 | | - | |
| 308 | + | |
| 309 | + | |
313 | 310 | | |
314 | 311 | | |
315 | 312 | | |
| |||
0 commit comments