tikv / fail-rs

Fail points for rust
Apache License 2.0
333 stars 39 forks source link

Thread-local failpoints #24

Open brson opened 5 years ago

brson commented 5 years ago

Is your feature request related to a problem? Please describe.

Failpoint unit tests require taking a global lock, preventing test parallelism. An alternate or complimentary solution to a global lock (https://github.com/pingcap/fail-rs/issues/23) would be to have a thread-local failpoint configuration, protected by a guard.

Describe the solution you'd like Add a thread-local configuration that is protected by a guard that performs teardown.

Describe alternatives you've considered Global locks: https://github.com/pingcap/fail-rs/issues/23

Additional context This would work for single-threaded test cases, but not generally for tests that require multiple threads.

BusyJay commented 5 years ago

Or the library can expose the FailPointRegistry to users, so users can control the lock pattern more precisely.