forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
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
Showing
6 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...s/smallrye-graphql/src/main/java/io/quarkus/it/smallrye/graphql/FaultTolerantService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jmartisk
Author
Owner
|
||
} catch (InterruptedException e) { | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
integration-tests/smallrye-graphql/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
8 changes: 8 additions & 0 deletions
8
...lrye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...ye-graphql/src/test/java/io/quarkus/it/smallrye/graphql/GraphQLAndFaultToleranceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} |
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.