Add test isolation utilities for async testing with EnforcerServer#58
Closed
Add test isolation utilities for async testing with EnforcerServer#58
Conversation
|
|
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix shared global enforcer state in Async tests
Add test isolation utilities for async testing with EnforcerServer
Jan 1, 2026
Member
|
@copilot don't add any markdown docs. don't add test files. focus on core code logic change |
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Contributor
Author
Removed all markdown documentation and test files. PR now contains only core |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EnforcerServer uses a global ETS table (
:enforcers_table) keyed by enforcer name. Tests sharing the same enforcer name experience race conditions when run withasync: true- policies added in one test get deleted by another's cleanup, causing intermittent failures.Changes
Test utilities module (
Casbin.TestHelper)unique_enforcer_name/1- Generate unique enforcer names per test using process refs + timestamp + randomstart_test_enforcer/2- Start isolated enforcer under supervisorcleanup_test_enforcer/1- Stop process and remove from ETS tablereset_test_enforcer/2- Clear policies without stoppingMinimal inline documentation focused on core functionality only.
Usage
Backward compatible - existing tests with shared enforcers continue working.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.