Riptide: Chaos adds Chaos and Fault/Failure Injection to Riptide.
Http.builder()
.plugin(new ChaosPlugin(
new LatencyInjection(
Probability.fixed(0.01),
Clock.systemUTC(),
Duration.ofSeconds(1))))
.build();
- Controlled failure injection
- Latency injection
- Error response injection
- Exception injection
- Java 8
- Riptide: Core
Add the following dependency to your project:
<dependency>
<groupId>org.zalando</groupId>
<artifactId>riptide-chaos</artifactId>
<version>${riptide.version}</version>
</dependency>
Prolongs the processing of a response by the given delay. This injection will be skipped if the response is already delayed.
Http.builder()
.plugin(new ChaosPlugin(
new LatencyInjection(
Probability.fixed(0.01),
Clock.systemUTC(),
Duration.ofSeconds(1))))
.build();
Injects an exception, constructed using one of the given suppliers, and injects it after the actual response has been received. This injection will be skipped if any exception already occurred.
Http.builder()
.plugin(new ChaosPlugin(
new ExceptionInjection(
Probability.fixed(0.001),
Arrays.asList(
SocketTimeoutException::new,
NoRouteToHostException::new)))
.build();
Injects an error response, using one of the given status codes, and injects it after the actual has been received. This injection will be skipped if any error response (4xx or 5xx) already occurred.
Http.builder()
.plugin(new ChaosPlugin(
new ErrorResponseInjection(
Probability.fixed(0.001),
Arrays.asList(
HttpStatus.INTERNAL_SERVER_ERROR,
HttpStatus.SERVICE_UNAVAILABLE))))
.build();
If you want to enabled multiple different failure injections at the same time you can use the composite:
new ChaosPlugin(composite(
new LatencyInjection(
Probability.fixed(0.01),
Clock.systemUTC(),
Duration.ofSeconds(1))),
new ExceptionInjection(
Probability.fixed(0.001),
Arrays.asList(
SocketTimeoutException::new,
NoRouteToHostException::new)))
Please note that since both injections evaluate their probability independently the chance that both happen at the same time is the product of both, e.g. 0.00001 or 0.001%.
The built-in default implementation for Probability
is a fixed one using a random
number generator and a given probability [0..1)
.
A more sophisticated implementation could use some shared configuration with support for updating configuration at runtime to control the probability of certain failure injections in a more dynamic, controlled way, e.g. during a fire drill.
If you have questions, concerns, bug reports, etc., please file an issue in this repository's Issue Tracker.
To contribute, simply make a pull request and add a brief description (1-2 sentences) of your addition or change. For more details, check the contribution guidelines.