Repository navigation
Commit 7ec7370
test(android): Fix flaky AnrV2 scope persistence assertion (#6031)
* test(android): Fix flaky AnrV2 scope persistence assertion
The final assertions of the AnrV2 enrichment test read transaction.json
and release.json straight off disk, but both are written from the Sentry
executor and nothing in the test joins it.
The awaited beforeSend callback runs on the ANR processing task, which is
queued ahead of the scope flush, so it flipping says nothing about whether
the writes have landed. Awaitility's 100ms poll interval normally hides
this; on a loaded CI runner it does not, and the read returns the value
prefilled by the test setup instead of the new one.
Poll for the persisted values rather than reading them once.
* test(android): Cap the AnrV2 persistence poll at 5 seconds
Awaitility's 10 second default is the wait a genuine regression now pays
before the test reports it.
By this point the only work left in the executor queue is two short file
writes: the long ANR processing task has already run, which is what let
the awaited beforeSend callback flip. Scheduler starvation on a loaded
runner is the only plausible source of delay, so 5 seconds leaves ample
headroom while halving the failure wait.
* test(android): Lower the AnrV2 persistence poll cap to 2 seconds
The remaining executor work is two short file writes, so the cap only has
to cover scheduler starvation on a loaded runner. 2 seconds still leaves
an order of magnitude of headroom and shortens the wait a genuine
regression pays before the test reports it.
* fix(core): Clear the persisted replay id when resetting the scope cache
resetCache() cleared every other persisted scope value on init but left
replay.json in place, so a replay id written by a previous process could
still be attached to events from the current one. The reset already runs
after the integrations that consume those values, so deleting it here is
safe.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(android): Observe the scope-reset assertions instead of dropping them
The reset assertions were submitted to the Sentry executor and their
Future discarded, so an AssertionError never reached the test runner and
the test passed regardless of what they found. Joining the Future revives
them; the replay expectation is corrected to assertNull to match what
resetCache does.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(android): Lower the scope-reset join timeout to 2 seconds
The join only guards against a wedged executor; the task is expected to
be long finished by then. 30 seconds was arbitrary and 15x the cap the
sibling assertion in this test uses, so a hang burned CI time for no
added coverage.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(android): Move the replay id reset out of the flakiness fix
The scope-reset assertion revived by the previous commit expected
resetCache() to clear replay.json, which it has never done. Fixing that
is a product change unrelated to the flaky assertion this branch is
about, so it moves to its own PR along with its test and changelog entry.
The replay expectation is dropped rather than corrected: resetCache's
behaviour belongs in PersistingScopeObserverBatchingTest, not incidental
to a test about ANR enrichment. The breadcrumbs assertion beside it stays
and is now observed.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 0df52e7 commit 7ec7370
1 file changed
Lines changed: 35 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | 54 | | |
56 | 55 | | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
454 | 450 | | |
455 | 451 | | |
456 | 452 | | |
| |||
464 | 460 | | |
465 | 461 | | |
466 | 462 | | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
478 | 487 | | |
479 | 488 | | |
480 | 489 | | |
| |||
0 commit comments