Skip to content

Commit

Permalink
Coverage for several issues, which will be fixed in 3.8.5 via backpor…
Browse files Browse the repository at this point in the history
  • Loading branch information
fedinskiy committed May 31, 2024
1 parent 563efd8 commit 6b97454
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.ts.http.restclient.reactive.failures;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import org.eclipse.microprofile.rest.client.inject.RestClient;

import io.smallrye.mutiny.Uni;

@Path("/client/failing")
public class FailingClientResource {
@RestClient
FailureClient client;

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/straight")
public String getStraightResult() {
return client.getVisitor();
}

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/reactive")
public Uni<String> getReactiveResult() {
return client.getVisitorReactively()
.onFailure().retry().atMost(5);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package io.quarkus.ts.http.restclient.reactive.failures;

import java.util.concurrent.atomic.AtomicInteger;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/fail")
public class FailingResource {
private static final AtomicInteger counter = new AtomicInteger(0);
private static final boolean[] fail = { true, true, true, true, false };
// in earlier versions, connection was closed after three errors. We need to ensure, that this is no a case.

@GET
@Produces(MediaType.TEXT_PLAIN)
@Path("/cyclic")
public String fail() {
int visit = counter.getAndIncrement();
int index = visit % fail.length;
if (fail[index]) {
throw new RuntimeException("Whoops, we encountered a problem!");
} else {
return "You're the " + (visit + 1) + "th visitor of this page";
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.quarkus.ts.http.restclient.reactive.failures;

import java.time.temporal.ChronoUnit;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

import org.eclipse.microprofile.faulttolerance.Retry;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import io.smallrye.mutiny.Uni;

@RegisterRestClient(baseUri = "http://localhost:8080/")
@Path("/fail")
public interface FailureClient {

@GET
@Retry(delay = 1, delayUnit = ChronoUnit.SECONDS, maxRetries = 5)
@Path("/cyclic")
String getVisitor();

@GET
@Path("/cyclic")
Uni<String> getVisitorReactively();
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.BookClient".url=http
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.BookClient.AuthorClient".url=http://localhost:${quarkus.http.port}
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.ResourceAndSubResourcesClient".url=http://localhost:${quarkus.http.port}
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.MalformedClient".url=http://localhost:${quarkus.http.port}
quarkus.rest-client."io.quarkus.ts.http.restclient.reactive.failures.FailureClient".url=http://localhost:${quarkus.http.port}

quarkus.rest-client.logging.scope=request-response
quarkus.log.category."org.jboss.resteasy.reactive.client.logging".level=DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ReactiveRestClientIT {
}

static final String MALFORMED_URL = "quarkus.rest-client.\"io.quarkus.ts.http.restclient.reactive.MalformedClient\".url";

@QuarkusApplication
static RestService app = new RestService()
.withProperties("modern.properties")
Expand Down Expand Up @@ -275,6 +276,24 @@ public void clientHeaderInjectionTest() {
.body(containsString("clientFilterInvoked"));
}

@Test
@Tag("https://github.com/quarkusio/quarkus/issues/37323")
public void clientRetry() {
app.given().get("/client/failing/straight")
.then()
.statusCode(200)
.body(containsString("visitor of this page"));
}

@Test
@Tag("https://github.com/quarkusio/quarkus/issues/37323")
public void clientReactiveRetry() {
app.given().get("/client/failing/reactive")
.then()
.statusCode(200)
.body(containsString("visitor of this page"));
}

@AfterAll
static void afterAll() {
mockServer.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ public void shouldCreateJacocoReportsFromApplicationOnJvm() {

@Tag("QUARKUS-1296")
@Test
@Disabled("https://github.com/quarkusio/quarkus/issues/40410")
public void verifyRestEasyReactiveAndClassicResteasyCollisionUserMsg() {
QuarkusCliRestService app = cliClient.createApplication("dependencyCollision",
defaultWithFixedStream().withExtensions("resteasy", "rest"));
Expand Down

0 comments on commit 6b97454

Please sign in to comment.