Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for GraphQL+Fault Tolerance together
Browse files Browse the repository at this point in the history
jmartisk committed Sep 17, 2021
1 parent 9b1424d commit f480b9a
Showing 6 changed files with 88 additions and 1 deletion.
17 changes: 17 additions & 0 deletions integration-tests/smallrye-graphql/pom.xml
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-graphql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-fault-tolerance</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
@@ -46,6 +50,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-fault-tolerance-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
Original file line number Diff line number Diff line change
@@ -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(50);

This comment has been minimized.

Copy link
@Ladicek

Ladicek Sep 17, 2021

I'd recommend sleeping for longer here, because distinguishing 10 millis from 50 millis requires pretty high accuracy, that often isn't available in CI environments. @Timeout(10) is fine, but the sleep should be say 2 or 3 seconds.

This comment has been minimized.

Copy link
@jmartisk

jmartisk Sep 17, 2021

Author Owner

Yeah I guess you're right. I'll increase that. Thanks for noticing

} catch (InterruptedException e) {
}
}
}
Original file line number Diff line number Diff line change
@@ -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<Greeting> buildInOptionsCollection(@Source Greeting greeting)
public Farewell farewell() {
return new Farewell();
}

@Inject
FaultTolerantService service;

@Query
public String faultTolerance() {
service.causeTimeout();
return "PASSED";
}
}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
message=Production
message=Production
quarkus.smallrye-graphql.show-runtime-exception-message=org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.it.smallrye.graphql;

import io.quarkus.test.junit.NativeImageTest;

@NativeImageTest
public class GraphQLAndFaultToleranceIT extends GraphQLAndFaultToleranceTest {

}
Original file line number Diff line number Diff line change
@@ -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"));
}
}

0 comments on commit f480b9a

Please sign in to comment.