-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30481 from alesj/i30379
Test all gRPC combos wrt exception handling, msgs, etc
- Loading branch information
Showing
40 changed files
with
574 additions
and
28 deletions.
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
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,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>quarkus-integration-tests-parent</artifactId> | ||
<groupId>io.quarkus</groupId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>quarkus-integration-test-grpc-exceptions</artifactId> | ||
<name>Quarkus - Integration Tests - gRPC - Exceptions</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-grpc</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-test-grpc</artifactId> | ||
<version>${project.version}</version> <!--kept here to not pollute the BOM--> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order --> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-grpc-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-resteasy-reactive-deployment</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>test</scope> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>*</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate-code</goal> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
16 changes: 16 additions & 0 deletions
16
...tion-tests/grpc-exceptions/src/main/java/com/example/grpc/exc/LegacyHelloGrpcService.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,16 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.grpc.Status; | ||
import io.grpc.StatusException; | ||
import io.grpc.stub.StreamObserver; | ||
import io.quarkus.grpc.GrpcService; | ||
|
||
@GrpcService | ||
public class LegacyHelloGrpcService extends LegacyHelloGrpcGrpc.LegacyHelloGrpcImplBase { | ||
@Override | ||
public void legacySayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) { | ||
// it NEEDS to be plain StatusException, and NOT StatusRuntimeException ?! | ||
final StatusException t = new StatusException(Status.INVALID_ARGUMENT); | ||
responseObserver.onError(t); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...on-tests/grpc-exceptions/src/main/java/com/example/grpc/exc/SmallryeHelloGrpcService.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,14 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.grpc.GrpcService; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@GrpcService | ||
public class SmallryeHelloGrpcService implements HelloGrpc { | ||
|
||
@Override | ||
public Uni<HelloReply> sayHello(HelloRequest request) { | ||
throw new IllegalArgumentException("test"); | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
integration-tests/grpc-exceptions/src/main/proto/hello.proto
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,23 @@ | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "com.example.grpc.exc"; | ||
option java_outer_classname = "HelloGrpcProto"; | ||
|
||
package hello; | ||
|
||
service HelloGrpc { | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
service LegacyHelloGrpc { | ||
rpc LegacySayHello (HelloRequest) returns (HelloReply) {} | ||
} | ||
|
||
message HelloRequest { | ||
string name = 1; | ||
} | ||
|
||
message HelloReply { | ||
string message = 1; | ||
} |
31 changes: 31 additions & 0 deletions
31
integration-tests/grpc-exceptions/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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
## --- servers | ||
|
||
%vertx.quarkus.grpc.server.use-separate-server=false | ||
%n2o.quarkus.grpc.server.use-separate-server=true | ||
%o2n.quarkus.grpc.server.use-separate-server=false | ||
|
||
## --- clients | ||
|
||
quarkus.grpc.clients.hello.host=localhost | ||
quarkus.grpc.clients.hello.port=9001 | ||
|
||
%vertx.quarkus.grpc.clients.hello.port=8081 | ||
%vertx.quarkus.grpc.clients.hello.use-quarkus-grpc-client=true | ||
|
||
%n2o.quarkus.grpc.clients.hello.port=9001 | ||
%n2o.quarkus.grpc.clients.hello.use-quarkus-grpc-client=true | ||
|
||
%o2n.quarkus.grpc.clients.hello.port=8081 | ||
%o2n.quarkus.grpc.clients.hello.use-quarkus-grpc-client=false | ||
|
||
quarkus.grpc.clients.stub.host=localhost | ||
quarkus.grpc.clients.stub.port=9001 | ||
|
||
%vertx.quarkus.grpc.clients.stub.port=8081 | ||
%vertx.quarkus.grpc.clients.stub.use-quarkus-grpc-client=true | ||
|
||
%n2o.quarkus.grpc.clients.stub.port=9001 | ||
%n2o.quarkus.grpc.clients.stub.use-quarkus-grpc-client=true | ||
|
||
%o2n.quarkus.grpc.clients.stub.port=8081 | ||
%o2n.quarkus.grpc.clients.stub.use-quarkus-grpc-client=false |
7 changes: 7 additions & 0 deletions
7
...-tests/grpc-exceptions/src/test/java/com/example/grpc/exc/LegacyHelloGrpcServiceTest.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,7 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
class LegacyHelloGrpcServiceTest extends LegacyHelloGrpcServiceTestBase { | ||
} |
24 changes: 24 additions & 0 deletions
24
...ts/grpc-exceptions/src/test/java/com/example/grpc/exc/LegacyHelloGrpcServiceTestBase.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,24 @@ | ||
package com.example.grpc.exc; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.grpc.Status; | ||
import io.grpc.StatusRuntimeException; | ||
import io.quarkus.grpc.GrpcClient; | ||
|
||
class LegacyHelloGrpcServiceTestBase { | ||
@SuppressWarnings("CdiInjectionPointsInspection") | ||
@GrpcClient | ||
LegacyHelloGrpcGrpc.LegacyHelloGrpcBlockingStub stub; | ||
|
||
@SuppressWarnings("ResultOfMethodCallIgnored") | ||
@Test | ||
void legacySayHello() { | ||
final StatusRuntimeException exception = assertThrows(StatusRuntimeException.class, | ||
() -> stub.legacySayHello(HelloRequest.newBuilder().setName("Neo").build())); | ||
assertEquals(Status.Code.INVALID_ARGUMENT, exception.getStatus().getCode()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...sts/grpc-exceptions/src/test/java/com/example/grpc/exc/N2OLegacyHelloGrpcServiceTest.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,10 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.grpc.test.utils.N2OGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(N2OGRPCTestProfile.class) | ||
class N2OLegacyHelloGrpcServiceTest extends LegacyHelloGrpcServiceTestBase { | ||
} |
10 changes: 10 additions & 0 deletions
10
...s/grpc-exceptions/src/test/java/com/example/grpc/exc/N2OSmallryeHelloGrpcServiceTest.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,10 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.grpc.test.utils.N2OGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(N2OGRPCTestProfile.class) | ||
public class N2OSmallryeHelloGrpcServiceTest extends SmallryeHelloGrpcServiceTestBase { | ||
} |
10 changes: 10 additions & 0 deletions
10
...sts/grpc-exceptions/src/test/java/com/example/grpc/exc/O2NLegacyHelloGrpcServiceTest.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,10 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.grpc.test.utils.O2NGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(O2NGRPCTestProfile.class) | ||
class O2NLegacyHelloGrpcServiceTest extends LegacyHelloGrpcServiceTestBase { | ||
} |
10 changes: 10 additions & 0 deletions
10
...s/grpc-exceptions/src/test/java/com/example/grpc/exc/O2NSmallryeHelloGrpcServiceTest.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,10 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.grpc.test.utils.O2NGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(O2NGRPCTestProfile.class) | ||
public class O2NSmallryeHelloGrpcServiceTest extends SmallryeHelloGrpcServiceTestBase { | ||
} |
7 changes: 7 additions & 0 deletions
7
...ests/grpc-exceptions/src/test/java/com/example/grpc/exc/SmallryeHelloGrpcServiceTest.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,7 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
public class SmallryeHelloGrpcServiceTest extends SmallryeHelloGrpcServiceTestBase { | ||
} |
28 changes: 28 additions & 0 deletions
28
.../grpc-exceptions/src/test/java/com/example/grpc/exc/SmallryeHelloGrpcServiceTestBase.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,28 @@ | ||
package com.example.grpc.exc; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import java.time.Duration; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.grpc.Status; | ||
import io.grpc.StatusRuntimeException; | ||
import io.quarkus.grpc.GrpcClient; | ||
|
||
public class SmallryeHelloGrpcServiceTestBase { | ||
|
||
@SuppressWarnings("CdiInjectionPointsInspection") | ||
@GrpcClient | ||
HelloGrpc hello; | ||
|
||
@Test | ||
public void testHello() { | ||
final StatusRuntimeException exception = assertThrows(StatusRuntimeException.class, () -> hello | ||
.sayHello(HelloRequest.newBuilder().setName("Neo").build()).await() | ||
.atMost(Duration.ofSeconds(5))); | ||
assertEquals(Status.Code.INVALID_ARGUMENT, exception.getStatus().getCode()); | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
...s/grpc-exceptions/src/test/java/com/example/grpc/exc/VertxLegacyHelloGrpcServiceTest.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,10 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.grpc.test.utils.VertxGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(VertxGRPCTestProfile.class) | ||
class VertxLegacyHelloGrpcServiceTest extends LegacyHelloGrpcServiceTestBase { | ||
} |
10 changes: 10 additions & 0 deletions
10
...grpc-exceptions/src/test/java/com/example/grpc/exc/VertxSmallryeHelloGrpcServiceTest.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,10 @@ | ||
package com.example.grpc.exc; | ||
|
||
import io.quarkus.grpc.test.utils.VertxGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(VertxGRPCTestProfile.class) | ||
public class VertxSmallryeHelloGrpcServiceTest extends SmallryeHelloGrpcServiceTestBase { | ||
} |
11 changes: 10 additions & 1 deletion
11
integration-tests/grpc-interceptors/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,8 +1,17 @@ | ||
quarkus.grpc.server.port=9001 | ||
|
||
%vertx.quarkus.grpc.server.use-separate-server=false | ||
%n2o.quarkus.grpc.server.use-separate-server=true | ||
%o2n.quarkus.grpc.server.use-separate-server=false | ||
|
||
quarkus.grpc.clients.hello.host=localhost | ||
quarkus.grpc.clients.hello.port=9001 | ||
|
||
%vertx.quarkus.grpc.clients.hello.port=8081 | ||
%vertx.quarkus.grpc.clients.hello.use-quarkus-grpc-client=true | ||
%vertx.quarkus.grpc.server.use-separate-server=false | ||
|
||
%n2o.quarkus.grpc.clients.hello.port=9001 | ||
%n2o.quarkus.grpc.clients.hello.use-quarkus-grpc-client=true | ||
|
||
%o2n.quarkus.grpc.clients.hello.port=8081 | ||
%o2n.quarkus.grpc.clients.hello.use-quarkus-grpc-client=false |
11 changes: 11 additions & 0 deletions
11
...erceptors/src/test/java/io/quarkus/grpc/example/interceptors/N2OHelloWorldEndpointIT.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,11 @@ | ||
package io.quarkus.grpc.example.interceptors; | ||
|
||
import io.quarkus.grpc.test.utils.N2OGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusIntegrationTest | ||
@TestProfile(N2OGRPCTestProfile.class) | ||
class N2OHelloWorldEndpointIT extends HelloWorldEndpointTestBase { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...ceptors/src/test/java/io/quarkus/grpc/example/interceptors/N2OHelloWorldEndpointTest.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,11 @@ | ||
package io.quarkus.grpc.example.interceptors; | ||
|
||
import io.quarkus.grpc.test.utils.N2OGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(N2OGRPCTestProfile.class) | ||
class N2OHelloWorldEndpointTest extends HelloWorldEndpointTestBase { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...erceptors/src/test/java/io/quarkus/grpc/example/interceptors/O2NHelloWorldEndpointIT.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,11 @@ | ||
package io.quarkus.grpc.example.interceptors; | ||
|
||
import io.quarkus.grpc.test.utils.O2NGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusIntegrationTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusIntegrationTest | ||
@TestProfile(O2NGRPCTestProfile.class) | ||
class O2NHelloWorldEndpointIT extends HelloWorldEndpointTestBase { | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...ceptors/src/test/java/io/quarkus/grpc/example/interceptors/O2NHelloWorldEndpointTest.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,11 @@ | ||
package io.quarkus.grpc.example.interceptors; | ||
|
||
import io.quarkus.grpc.test.utils.O2NGRPCTestProfile; | ||
import io.quarkus.test.junit.QuarkusTest; | ||
import io.quarkus.test.junit.TestProfile; | ||
|
||
@QuarkusTest | ||
@TestProfile(O2NGRPCTestProfile.class) | ||
class O2NHelloWorldEndpointTest extends HelloWorldEndpointTestBase { | ||
|
||
} |
Oops, something went wrong.