Skip to content

Simulate fault #149

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

Open
Sytten opened this issue Oct 22, 2024 · 5 comments · May be fixed by #159
Open

Simulate fault #149

Sytten opened this issue Oct 22, 2024 · 5 comments · May be fixed by #159
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Sytten
Copy link

Sytten commented Oct 22, 2024

It would be very useful to be able simulate faults to test how the program reacts to them.

@LukeMathWalker
Copy link
Owner

What kind of faults?

@Sytten
Copy link
Author

Sytten commented Oct 22, 2024

Sorry for the lack of details. I meant to come back and fill the details.

The base and most useful case is simulating a network failure/disconnect (usually an EOF) mid transmission. That happens often to regular users so it interesting to test. This can also be used to simulate an offline mode.

It would also be nice to be able to control the frames that sent (like in chunked encoding) to introduce delays between chunks and also failures after a number of chunks.

See the Java implementation: https://wiremock.org/docs/simulating-faults/#bad-responses

@LukeMathWalker LukeMathWalker added enhancement New feature or request help wanted Extra attention is needed labels Oct 23, 2024
@konstin
Copy link

konstin commented May 21, 2025

One array that would be very interesting for us are things that translate to io::Errors in reqwest, such as io::ErrorKind::ConnectionReset, io::ErrorKind::UnexpectedEof and io::ErrorKind::BrokenPipe. Users reported seeing these errors (especially in GitHub Actions there are a lot of connectivity problems) and we'd like to simulate these error to ensure we're retrying correctly when encountering them. These are errors without an HTTP status code, so we're looking for a way to simulate lower-level errors in response templates.

@Sytten
Copy link
Author

Sytten commented May 21, 2025

Yep that is exactly my thought @konstin, I would like to try our logic for cloud connectivity and ensure that the code reacts correctly when the network is unstable.

@LukeMathWalker
Copy link
Owner

One array that would be very interesting for us are things that translate to io::Errors in reqwest, such as io::ErrorKind::ConnectionReset, io::ErrorKind::UnexpectedEofandio::ErrorKind::BrokenPipe`. Users reported seeing these errors (especially in GitHub Actions there are a lot of connectivity problems) and we'd like to simulate these error to ensure we're retrying correctly when encountering them. These are errors without an HTTP status code, so we're looking for a way to simulate lower-level errors in response templates.

That sounds like a good enough characterization and I'd be happy to support it.

konstin added a commit to konstin/wiremock-rs that referenced this issue May 23, 2025
Add `MockBuilder::respond_with_err` to respond with an arbitrary Rust error instead of an HTTP error.

Due to overlapping impl constraints, `RespondErr` only supports passing a function that returns an error and not the error itself.

Fixes LukeMathWalker#149
@konstin konstin linked a pull request May 23, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants