-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support configuring fail point in RAII style #62
Conversation
Signed-off-by: tabokie <xy.tao@outlook.com>
@BusyJay What do you think |
Why not use |
User might not want to configure a global hook that applies to all failpoint tests (like we do in TiKV). If they don't do that, they have to add additional two lines for every tests. I already used similar thing in Raft Engine (https://github.com/tikv/raft-engine/blob/1a9dd43a74a6ff93c176670e584db6ec520b6953/tests/failpoints/test_io_error.rs#L155), it's really natural to use. Also, with respect to TiKV's implementation, calling |
Actually, TiKV configures global hook using its own way.
Your usage is wrong. Technically, there is only one global failpoint registry, so without synchronization, failpoint configuration set by any cases will affect other cases as well. Hence executing cases in sequential order is required.
It doesn't matter. Teardown will wake up all blocking threads. |
I'm saying user might not want to go over the trouble to doing a configuration like this.
You are looking at the wrong thing. I'm demonstrating that using I see that there are two things with failpoint tests. (1) failpoint cleanup (2) exclusive ownership to global registry.
It does matter. As I explained, the object destruction can be called inside the test closure. That means the process will be blocked inside without getting a chance to call the To see it in action, I have observed two cases that appear to be caused by forgetting to remove failpoints after test: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
src/lib.rs
Outdated
/// Configure the actions for a fail point during the lifetime of the returning object. | ||
/// | ||
/// Read documentation of [`cfg_callback`] for more details. | ||
pub fn new_callback<S, F>(name: S, f: F) -> Result<FailGuard, String> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be named with_callback
.
Signed-off-by: tabokie <xy.tao@outlook.com>
@BusyJay I can't merge this. |
It is very easy to write failpoint tests without freeing up the failpoint in the end.
Signed-off-by: tabokie xy.tao@outlook.com