Skip to content

test(core): stop the alarm collector losing events under concurrency - #79

Merged
araujof merged 1 commit into
praxis-proxy:mainfrom
araujof:fix/flaky-alarm-collector
Sep 3, 2026
Merged

test(core): stop the alarm collector losing events under concurrency#79
araujof merged 1 commit into
praxis-proxy:mainfrom
araujof:fix/flaky-alarm-collector

Conversation

@araujof

@araujof araujof commented Sep 3, 2026

Copy link
Copy Markdown
Member

Description

crates/ppe-core/tests/identity_route_e2e.rs failed about 1 run in 6 under cargo test, so make ci and make coverage were intermittently red. This was meant to go into #72 but that merged first.

The failure was always zero alarms collected, never a wrong count. Callsite interest in tracing is global and cached, while with_default is thread-local. Other tests in the same binary load a config with no subscriber installed, which registers those warn! callsites under NoSubscriber; that caches Interest::never() for the process, and every later collector sees nothing.

Changes

  • One subscriber installed globally for the binary instead of a thread-local one per call, so NoSubscriber never registers these callsites.
  • register_callsite returns Interest::sometimes(), so no verdict is cached and enabled is asked per event.
  • Events route to a per-thread sink that the helper sets and clears.

Testing

Measured before: 0/10 failures with the alarm tests alone, 0/6 with --test-threads=1, about 2/6 for the full binary concurrent. Adding rebuild_interest_cache() alone cut it to 1/12, which is what identified the cache as the cause and showed a thread-local subscriber could not fix it.

After: 0/40 runs on the original branch, 0/20 here, and make ci green four consecutive times. Confirmed the test still fails when the alarm is suppressed, so it is not passing vacuously.

dispatch_mode_e2e.rs and delegation_identity_warning.rs hand-roll the same pattern but do not manifest it, 0/12 each, because their binaries have no no-subscriber config loads. Left alone; they would start failing if that changes.

identity_route_e2e failed about 1 run in 6 under cargo test, always by
collecting zero alarms. Callsite interest is global and cached, while
with_default is thread-local: another test in the binary loading a config
with no subscriber registered the same warn! sites under NoSubscriber,
which caches never, and later collectors saw nothing.

Install one subscriber globally, return Interest::sometimes so no verdict
is cached, and route events to a per-thread sink.

40 runs clean, and make ci green three times where it was a coin flip.
Verified the assertion still bites by suppressing the alarm.

dispatch_mode_e2e and delegation_identity_warning share the pattern but do
not manifest it: 0/12 each. Left alone.

Signed-off-by: Frederico Araujo <frederico.araujo@ibm.com>
@araujof
araujof requested a review from a team September 3, 2026 17:25
@araujof
araujof requested a review from terylt as a code owner September 3, 2026 17:25
@araujof araujof added the tests label Sep 3, 2026
@araujof araujof moved this from Backlog to Review in Praxis Policy Engine (PPE) Sep 3, 2026
@araujof araujof added this to the 0.1.1 milestone Sep 3, 2026

@terylt terylt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@araujof
araujof merged commit 711a8bc into praxis-proxy:main Sep 3, 2026
7 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in Praxis Policy Engine (PPE) Sep 3, 2026
@araujof
araujof deleted the fix/flaky-alarm-collector branch September 3, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants