From 5cc3f4739a7d91c269b5e983e08d46eb102f6857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Marti=C5=A1ka?= Date: Wed, 29 Sep 2021 10:13:40 +0200 Subject: [PATCH 1/2] Upgrade to SmallRye GraphQL 1.3.4 --- bom/application/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 671e6f7e07ac8..15517d47aa466 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -46,7 +46,7 @@ 3.1.1 3.0.1 2.1.15 - 1.3.3 + 1.3.4 2.0.1 5.2.1 3.3.0 From f2bfd9cbf449500545fc00913f8905aa4ec072ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Marti=C5=A1ka?= Date: Fri, 17 Sep 2021 12:14:53 +0200 Subject: [PATCH 2/2] Test for GraphQL+Fault Tolerance together --- integration-tests/smallrye-graphql/pom.xml | 17 ++++++++++ .../graphql/FaultTolerantService.java | 19 ++++++++++++ .../it/smallrye/graphql/GreetingResource.java | 11 +++++++ .../src/main/resources/application.properties | 3 +- .../graphql/GraphQLAndFaultToleranceIT.java | 8 +++++ .../graphql/GraphQLAndFaultToleranceTest.java | 31 +++++++++++++++++++ 6 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/FaultTolerantService.java create mode 100644 integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceIT.java create mode 100644 integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceTest.java diff --git a/integration-tests/smallrye-graphql/pom.xml b/integration-tests/smallrye-graphql/pom.xml index 941d1e6d19834..64e2e214376a2 100644 --- a/integration-tests/smallrye-graphql/pom.xml +++ b/integration-tests/smallrye-graphql/pom.xml @@ -20,6 +20,10 @@ io.quarkus quarkus-smallrye-graphql + + io.quarkus + quarkus-smallrye-fault-tolerance + io.quarkus @@ -46,6 +50,19 @@ + + io.quarkus + quarkus-smallrye-fault-tolerance-deployment + ${project.version} + pom + test + + + * + * + + + diff --git a/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/FaultTolerantService.java b/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/FaultTolerantService.java new file mode 100644 index 0000000000000..424e11a083c69 --- /dev/null +++ b/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/FaultTolerantService.java @@ -0,0 +1,19 @@ +package io.quarkus.it.smallrye.graphql; + +import java.util.concurrent.TimeUnit; + +import javax.inject.Singleton; + +import org.eclipse.microprofile.faulttolerance.Timeout; + +@Singleton +public class FaultTolerantService { + + @Timeout(10) + public void causeTimeout() { + try { + TimeUnit.MILLISECONDS.sleep(2500); + } catch (InterruptedException e) { + } + } +} diff --git a/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/GreetingResource.java b/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/GreetingResource.java index e3708cb98a71f..81cfbf1ca5511 100644 --- a/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/GreetingResource.java +++ b/integration-tests/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/GreetingResource.java @@ -5,6 +5,8 @@ import java.util.Collection; import java.util.List; +import javax.inject.Inject; + import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.graphql.GraphQLApi; import org.eclipse.microprofile.graphql.Mutation; @@ -52,4 +54,13 @@ public Collection buildInOptionsCollection(@Source Greeting greeting) public Farewell farewell() { return new Farewell(); } + + @Inject + FaultTolerantService service; + + @Query + public String faultTolerance() { + service.causeTimeout(); + return "PASSED"; + } } diff --git a/integration-tests/smallrye-graphql/src/main/resources/application.properties b/integration-tests/smallrye-graphql/src/main/resources/application.properties index 7df30cbf277d9..8a3936f8d443a 100644 --- a/integration-tests/smallrye-graphql/src/main/resources/application.properties +++ b/integration-tests/smallrye-graphql/src/main/resources/application.properties @@ -1 +1,2 @@ -message=Production \ No newline at end of file +message=Production +quarkus.smallrye-graphql.show-runtime-exception-message=org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException \ No newline at end of file diff --git a/integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceIT.java b/integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceIT.java new file mode 100644 index 0000000000000..4d24a79a64148 --- /dev/null +++ b/integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceIT.java @@ -0,0 +1,8 @@ +package io.quarkus.it.smallrye.graphql; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +public class GraphQLAndFaultToleranceIT extends GraphQLAndFaultToleranceTest { + +} diff --git a/integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceTest.java b/integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceTest.java new file mode 100644 index 0000000000000..5924149d8bd44 --- /dev/null +++ b/integration-tests/smallrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceTest.java @@ -0,0 +1,31 @@ +package io.quarkus.it.smallrye.graphql; + +import static io.quarkus.it.smallrye.graphql.PayloadCreator.MEDIATYPE_JSON; +import static io.quarkus.it.smallrye.graphql.PayloadCreator.getPayload; +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.containsString; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +public class GraphQLAndFaultToleranceTest { + + @Test + public void testGraphQLAndFaultToleranceTogether() { + String helloRequest = getPayload("{\n" + + " faultTolerance\n" + + "}"); + + given() + .when() + .accept(MEDIATYPE_JSON) + .contentType(MEDIATYPE_JSON) + .body(helloRequest) + .post("/graphql") + .then() + .statusCode(200) + .body("errors[0].message", containsString("Timeout")); + } +}