I stumbled over another new Quarkus extension, Quarkus Network Faults, and it sounded like it had something to do with Goblin, which we covered previously. We had used Goblin to slow down an inventory call and make it return HTTP 503. So, I wanted to see how Network Faults approaches those failures and where it fits alongside that example.
Network Faults puts a Vert.x proxy between the application and a dependency it calls. In the REST Client setup I'm using here, the extension replaces the client's configured URL with the address of that proxy, which runs inside the test JVM. The proxy forwards requests to the original service until the test applies a fault. My application goes through its real REST Client, including JSON mapping and the SmallRye Fault Tolerance policy around the call.
From the test, I can make the proxy refuse new connections, accept a connection and stop answering, or return a chosen HTTP status. I can also make the first two HTTP requests fail and let the third reach the service. That gives a retry policy a repeatable sequence to handle, and Network Faults provides counters so I can check how many requests the client sent before it returned a response.
How this compares with Goblin
With Goblin 0.0.1, I installed the extension in the application receiving the request. Its incoming REST filter added the delay or HTTP failure before the inventory resource method could run. The quote endpoint and inventory endpoint happened to share one JVM in that example, but the request crossed HTTP between them. I selected the inventory package to keep the public quote endpoint reachable, then used the Dev UI to change the fault and the percentage of requests affected.
Network Faults gives me control from the calling application's test. The receiving service can stay as it is, because the proxy introduces the failures on the connection to it. A refused connection, for example, never reaches Goblin's incoming REST filter. Both extensions can introduce delays and HTTP failures, and both have development controls; the difference here is where I put that control. With Goblin I selected the receiving resource package. With Network Faults I select the outbound client and describe the failure in the test that uses it.
A small carrier example
To try these features, I kept the application small: a quote endpoint, a service with timeout, retry, and fallback policies, and a REST Client calling a carrier for a shipping price. The carrier is a local test server that returns EUR 9.90 whenever a request reaches it. The proxy supplies the failures, so the server needs no fault handling of its own. We can run the whole example without an external account or service.
The test selects the carrier connection through its client bean:
faults.target(CarrierClient.class)The proxy sits between that client and the local carrier. A request through the demo follows this path:
REST Assured
-> GET /quotes
-> QuoteService
-> CarrierClient
-> in-process fault proxy
-> local carrier serverWhen the carrier answers, the quote API returns that price. If the permitted attempts fail, I return HTTP 503 because I have no confirmed shipping price to offer. In the Goblin example, I could return HTTP 200 with conservative inventory data as a fallback. Those responses follow the choices in the two applications; the extensions let me introduce the failures that trigger them.
Bringing the proxy into a test
I kept Java 25 from the Goblin example and used Quarkus 4.0.0.Beta1 with Network Faults 0.1.0. The extension requires Quarkus 4.0.0.Beta1 or later and at least Java 21, so the beta is part of this setup. The companion project contains the application and complete tests; with JDK 25 installed, you can run the fault cases from its quarkus-network-faults-demo directory:
./mvnw testThe application already uses Quarkus REST, REST Client, and SmallRye Fault Tolerance. Network Faults detects the supported integrations from those dependencies. I added its JUnit helper with test scope, which also brings in the fault extension:
<dependency>
<groupId>io.quarkiverse.networkfaults</groupId>
<artifactId>quarkus-network-faults-junit</artifactId>
<version>0.1.0</version>
<scope>test</scope>
</dependency>The helper supplies NetworkFaultsProfile. I use it with @TestProfile(NetworkFaultsProfile.class) on my @QuarkusTest, then inject NetworkFaults into the test class. The profile carries the proxy's build-time setting into the test application's build. From there, faults.target(CarrierClient.class) gives me control over the connection used by that client.
My local carrier starts through a QuarkusTestResourceLifecycleManager, gets an available loopback port, and supplies its address through configuration. Network Faults resolves the configured URL after its expression is expanded, so the proxy picks up that address. The same test lifecycle closes the carrier afterward. I didn't need a separate proxy process or a container for this example.
Before applying any faults, I called the quote endpoint and got the carrier's EUR 9.90 response. That call also checks the JSON mapping. I reuse it in the tests below as healthyQuote, which checks the requested destination, amount, and currency. There are two paths through the demo: /quotes/once makes one carrier attempt, and /quotes allows two retries. Both use a 300 ms application timeout per attempt, so I can apply the same fault and follow what changes when retrying is enabled.
Refusing a connection
I started with unavailable(). This makes the proxy refuse new connections and reset existing ones, giving the REST Client a connection failure to handle. In the single-attempt test, that looks like this:
@Test
void refusesConnectionsAndRecoversAfterTheFault() {
try (ActiveFault ignored = faults.target(CarrierClient.class).unavailable()) {
when().get("/quotes/once?destination=Berlin").then()
.statusCode(503)
.body("error", equalTo("carrier_unavailable"))
.body("cause", equalTo("ProcessingException"));
}
healthyQuote("/quotes/once");
}The quote endpoint returned HTTP 503, with ProcessingException as the cause. The 503 came from my fallback response. The carrier hadn't sent an HTTP error; its client failed to communicate with it. I included the exception name in the demo response so I could follow that distinction through the public endpoint. In a public API, use stable error codes and keep exception details in telemetry.
Goblin's incoming filter needs a request to reach the receiving application. Here the connection fails before that can happen, while my caller goes through its transport failure and fallback handling.
The ActiveFault is an AutoCloseable, so the fault ends when execution leaves the block. The next call in the same test returned the carrier's price again. That lets me keep the failed call and its recovery together without putting failure switches into the carrier server.
Keeping a connection open without answering
A refused connection gives the client a failure quickly. With hangs(), I could instead leave it waiting for an answer. I used the single-attempt path first, with the REST Client's connect and read timeouts both set to one second. The application's @Timeout(300) should end the caller's wait before the client's read timeout does.
Network Faults includes a Stopwatch helper for measuring the call. I used it around the request to the public endpoint, so the measurement includes the time until that caller receives its response:
@Test
void boundsAHangingAttemptWithTheApplicationTimeout() {
healthyQuote("/quotes/once");
try (ActiveFault ignored = faults.target(CarrierClient.class).hangs()) {
long elapsed = Stopwatch.millis(() -> when().get("/quotes/once?destination=Berlin").then()
.statusCode(503)
.body("cause", equalTo("TimeoutException")));
LOG.infof("Single hanging attempt returned after %d ms", elapsed);
assertTrue(elapsed >= 250 && elapsed < 900, "application timeout took " + elapsed + " ms");
}
healthyQuote("/quotes/once");
}I made a healthy call before timing the failed one to start the client and complete the successful request path. With the fault active, the unavailable response came back after about 315 ms, with TimeoutException in its body. That was close to the application's 300 ms limit and well before the one-second client timeout. The assertion allows scheduling slack, while the exception check identifies which failure reached the fallback.
Returning from @Timeout doesn't guarantee that the underlying client operation has stopped, which is why I also configured the transport timeouts. The proxy gave me a way to hold the connection open while following the caller's response through the application timeout and fallback.
Failing exactly two requests
For the HTTP cases, Network Faults lets me choose which requests receive a synthetic response. I used forFirst(2) to return 503 for the first two requests, then allow the third through to the carrier. I could put that sequence directly into the test while keeping the carrier's successful response unchanged.
The demo's retrying method allows the initial attempt and two retries, with a 100 ms delay between them. Its policy is in QuoteService:
@Timeout(300)
@Retry(maxRetries = 2, delay = 100, jitter = 0, maxDuration = 2_000,
retryOn = { CarrierHttpException.class, ProcessingException.class, TimeoutException.class })
@Fallback(fallbackMethod = "unavailable")
public QuoteResult retrying(String destination) {
return QuoteResult.available(carrier.quote(destination));
}The REST Client maps a carrier 503 to CarrierHttpException, which is included in that retry list alongside transport failures and application timeouts. The extension supplies the HTTP failure; this application policy decides whether to send another request. With both in place, I could check the successful response and the number of attempts that preceded it:
@Test
void recoversFromExactlyTwoHttpFailures() {
Target carrier = faults.target(CarrierClient.class);
long before = carrier.traffic().httpRequestsSeen();
try (ActiveFault ignored = carrier.http().forFirst(2).http().respondsWith(503)) {
healthyQuote("/quotes");
assertEquals(3, carrier.traffic().httpRequestsSeen() - before);
Attempts.last(carrier.traffic().httpRequests(), 3)
.assertGapsAtLeast(Duration.ofMillis(80));
}
}The quote returned EUR 9.90 after exactly three outbound requests. The third request reached the carrier while the fault scope was open because it fell outside the first-two selector. With Goblin, I had selected the inventory resource and the percentage of requests affected. Here I could describe the failure sequence and inspect the attempts in the same test.
Those request records let me check more than the count. I used Attempts to check that the retry delays appeared between requests, allowing an 80 ms lower bound for the configured 100 ms delay. I set jitter to zero for this local example. If your policy includes jitter, check an acceptable range or distribution instead. The counter also accumulates across the test application's lifetime, so I read it before the call and assert the difference to exclude earlier traffic.
I then removed the first-two selector and kept carrier.http().respondsWith(503) active for the whole call. All three attempts failed, the fallback reported CarrierHttpException, and the quote endpoint returned its unavailable response. After the fault ended, the next quote succeeded. With a synthetic 400, the retry policy sent only one request: the client's default exception mapping put that response outside my retry list.
My quote API returned 503 in both cases, even though one made three outbound requests and the other made one. I had chosen one error response for unsuccessful carrier calls, so the response alone couldn't tell me whether the policy retried. Network Faults' request counter made that difference visible in the test.
I kept these HTTP experiments on plaintext HTTP/1.x. Network Faults needs to read the requests to apply selectors and produce request records. It relays TLS bytes without reading the HTTP messages inside them, so this first-two selector cannot be applied to encrypted traffic.
Following the caller through three timeouts
After counting the HTTP retries, I applied hangs() to the retrying path. This reused the same fault as the single-attempt case, but the caller now waited about 1.14 seconds before receiving its unavailable response. The 300 ms timeout applied to each attempt: three waits of 300 ms and two delays of 100 ms add up to roughly 1.1 seconds. Allowing two retries had taken the caller from about 315 ms to more than a second.
I gave that local test a two-second upper bound and a lower bound of 950 ms to catch an unexpectedly early response. These bounds check the result on the machine running the test. They don't enforce an overall deadline in the application.
The policy's maxDuration = 2_000 limits how long retrying can continue. The SmallRye 7.0.0 retry implementation checks elapsed time before another attempt starts; reaching that duration doesn't cancel an attempt already in progress. If your API needs a hard overall deadline, apply one around the complete operation alongside its per-attempt and transport limits.
Using the same proxy fault for both paths let me follow the time added by my retry policy without changing the carrier. I kept the operation read-only, as in the Goblin example. Retrying this GET doesn't create another order or reservation. For a write, the server can commit before the caller times out, so use an idempotency key or another deduplication boundary before applying a retry policy.
What happens when a fault ends
The healthy calls after each fault show that the carrier connection is available again. Network Faults also has cleanup behavior beyond removing the proxy fault: it resets SmallRye Fault Tolerance circuit breakers and flushes Agroal pools. I haven't included a breaker or database in this example. If you add one, account for that reset when interpreting a successful call after cleanup. A circuit breaker's natural half-open transition needs a separate test.
The extension also has a guard that fails a fault test if no relevant traffic reaches the proxy. A test can otherwise apply a fault and exercise a path that never calls the selected dependency.
I also repeated the packaged check from the Goblin example. Network Faults 0.1.0 injects faults in @QuarkusTest; it doesn't inject them through @QuarkusIntegrationTest into a packaged application. I used a separate healthy carrier call for that check and inspected the application's library directory. From the companion directory, both stages run with:
./mvnw verify -DskipITs=falseThe flag enables the packaged integration test. The packaged application called the carrier successfully, and there was no Network Faults JAR in target/quarkus-app/lib/main. In the Goblin 0.0.1 companion, its runtime JAR was present in the production package, with the assault engine enabled only in development and test modes. Here, keeping the JUnit helper in test scope kept the fault library out of the package.
I stayed with refused connections, hangs, and plaintext HTTP failures for these experiments. Other targets have their own constraints: connectTimeout() is Linux-only, Kafka can bypass the proxy after bootstrap, and TLS adds certificate and hostname requirements. The versioned target limitations describe those boundaries, and the upstream fault tolerance guide covers additional policies. The complete test class contains the cases and exact timings behind this article.
Network Faults lets me keep an exact failure sequence in the same test as the caller's response. When I change the retry policy, I'll keep the request count and waiting time beside that response assertion.


