forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gRPC: add an option to not start server in dev mode
fixes quarkusio#19721
- Loading branch information
1 parent
f87e933
commit 5fde84d
Showing
5 changed files
with
83 additions
and
4 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
26 changes: 26 additions & 0 deletions
26
...ployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeServerStartDisabledTest.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,26 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.response.Response; | ||
|
||
public class DevModeServerStartDisabledTest { | ||
@RegisterExtension | ||
public static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(IsUpEndpoint.class) | ||
.add(new StringAsset("quarkus.grpc.dev-force-server-start=false\n"), "application.properties")); | ||
|
||
@Test | ||
public void test() { | ||
Response response = when().get("/grpc-status"); | ||
response.then().statusCode(204); // 200 is returned when server started, 204 otherwise | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
.../grpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/DevModeServerStartTest.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,25 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import static io.restassured.RestAssured.when; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusDevModeTest; | ||
import io.restassured.response.Response; | ||
|
||
public class DevModeServerStartTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusDevModeTest config = new QuarkusDevModeTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(IsUpEndpoint.class)); | ||
|
||
@Test | ||
public void test() { | ||
Response response = when().get("/grpc-status"); | ||
response.then().statusCode(200); // 200 is returned when server started, 204 otherwise | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
extensions/grpc/deployment/src/test/java/io/quarkus/grpc/server/devmode/IsUpEndpoint.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,18 @@ | ||
package io.quarkus.grpc.server.devmode; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.core.Response; | ||
|
||
import io.quarkus.grpc.runtime.GrpcServerRecorder; | ||
|
||
@Path("/grpc-status") | ||
@ApplicationScoped | ||
public class IsUpEndpoint { | ||
@GET | ||
public Response isGrpcUp() { | ||
return GrpcServerRecorder.getVerticleCount() > 0 ? Response.ok().build() : Response.noContent().build(); | ||
} | ||
|
||
} |