Skip to content

test: exercise engine snapshot updates under real parallelism - #60

Open
abdallahsamabd wants to merge 1 commit into
praxis-proxy:mainfrom
abdallahsamabd:feat/test22
Open

test: exercise engine snapshot updates under real parallelism#60
abdallahsamabd wants to merge 1 commit into
praxis-proxy:mainfrom
abdallahsamabd:feat/test22

Conversation

@abdallahsamabd

Copy link
Copy Markdown
Collaborator

Summary

Adds concurrency coverage for the policy engine so registration, hot reload, and the route cache are exercised the way a host actually uses them: one PolicyEngine behind Arc, invokes in flight, mutations on other threads.

The engine already serializes writers with runtime_write. This change does not touch that. It makes the test suite able to see real OS-thread overlap, assert that a successful register is not dropped, and check the generation / snapshot Release/Acquire pairing.

What changed

  • Engine tests for registration, unregister, load_config / from_config, and the route cache now run with #[tokio::test(flavor = "multi_thread")].
  • New seeded stress tests in crates/ppe-core/tests/engine_concurrency.rs:
    • eight threads barrier-register distinct plugins; every Ok must still be visible
    • N invoke tasks vs M mutators (register / unregister / annotate / reload); lost-update assertion, coherent invoke, cache refill after quiesce
    • replay with PPE_STRESS_SEED (optional PPE_STRESS_OPS, PPE_STRESS_INVOKERS, PPE_STRESS_MUTATORS)
  • Loom model in crates/ppe-core/tests/loom_generation_snapshot.rs: if a reader Acquire-loads a higher generation, it must see the snapshot stored before the Release bump.
  • Nightly ThreadSanitizer job (.github/workflows/nightly-tsan.yml, make test-tsan) runs the stress tests under TSan. PR CI is unchanged.
  • CONTRIBUTING.md: when a new test needs flavor = "multi_thread".

Closes #22.

Test plan

  • cargo test -p praxis-policy-core --test engine_concurrency --test loom_generation_snapshot
  • cargo test -p praxis-policy-core --lib
  • Optional: PPE_STRESS_SEED=12345 cargo test -p praxis-policy-core --test engine_concurrency stress_invoke -- --nocapture
  • Confirm PR CI (make test) stays green; TSan is nightly-only

Signed-off-by: Abdallah Samara <abdallahsamabd@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(test): concurrency testing for the engine

3 participants