Closed
Conversation
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
|
|
…nup from async tests Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix shared global enforcer state causing async test failures
Add async test isolation for EnforcerServer
Feb 12, 2026
Member
|
@copilot fix: moreover, don't add test code, don't add markdown files, don't modify README.md |
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Contributor
Author
... Fixed in d02c47f. Removed all test files, markdown documentation, and README changes. Only kept the core library files (lib/casbin/test_helper.ex and lib/casbin/async_case.ex) and ensured they are properly formatted. |
Member
|
@copilot you should not add test templates. you should do as: #31 |
Co-authored-by: hsluoyz <3787410+hsluoyz@users.noreply.github.com>
Contributor
Author
Copilot
AI
changed the title
Add async test isolation for EnforcerServer
Support dynamic enforcer names per test
Feb 12, 2026
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.
Tests using a shared enforcer name experience race conditions in async mode. One test's cleanup deletes policies while another test is executing, causing intermittent failures.
This PR provides utility functions to support dynamic enforcer names per test, allowing tests to run safely with
async: true.Changes
Core utilities (
lib/casbin/test_helper.ex)unique_enforcer_name/1- Generates unique enforcer names via:erlang.unique_integer/1cleanup_enforcer/1- Removes enforcer from ETS and stops processUsage
Before:
After:
Benefits
✅ Each test gets a unique enforcer instance
✅ Tests can run in parallel with
async: true✅ No race conditions or flaky tests
✅ Backward compatible
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.