Skip to content
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 customized logic for FAILPOINTS tasks #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

quark-zju
Copy link

See also commit messages.

I'd like to add 2 primitives to construct interesting race conditions between processes:

  • wait(name): wait for unblock(name)
  • unblock(name): unblock current or future wait(name), block until one wait(name) is unblocked.

There does not seem to be a generic/portable way to implement them. But with certain assumptions like $TESTING_TEMP is a directory that can be freely written to for communication, it is possible to implement above feature. This PR adds a way so applications can implement their needs and get the logic exposed via the FAILPOINTS environment variable.


Side note:

It almost seems that there are 2 different use-cases of fail:

  • Library testing. One can just use cfg, cfg_callback without using the FAILPOINTS environment at all. Different test cases have different failpoint configurations
  • Application testing. FAILPOINTS is probably used exclusively, since the cfg approach would require compiling the executable to O(test case) different ones, which does not make much sense.

The "callback" flexibility seems exclusive to library testing. This change closes the gap so application testing can get similar flexibility.

For now it makes the environment variable configurable, which
might be useful for different applications to use different
env var names to avoid conflict.

I plan to add more features in the next change.

Signed-off-by: Jun Wu <quark@lihdd.net>
Previously, the only way to provide customized (as a Rust function)
failpoint behavior is to use `cfg_callback` API. This change extends
the customization to the FAILPOINTS environment variable. Application
can provide a function to turn a `call(arg)` task in FAILPOINTS to
a "callback". Unlike `cfg_callback`, this integrates with the rest
of FAILPOINTS syntax, for example:

    3*call(foo)->2*return->panic

`cfg_callback` does not seem to be able to express `return`.

The use-case that motivates this change is to test race conditions
in multiple processes. I'd like to use 2 primitives:

    wait("foo")     // wait for "foo".
    unblock("foo")  // unblock a current or future wait of "foo".

instead of "sleep" to create interesting racy cases deterministically.

Signed-off-by: Jun Wu <quark@lihdd.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant