diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java index 010b9c442bbd3..610a83b5b6137 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcServerRecorder.java @@ -1,6 +1,7 @@ package io.quarkus.grpc.runtime; import static io.quarkus.grpc.runtime.GrpcSslUtils.applySslOptions; +import static io.quarkus.grpc.runtime.GrpcTestPortUtils.testPort; import java.io.File; import java.io.IOException; @@ -57,6 +58,7 @@ import io.quarkus.runtime.RuntimeValue; import io.quarkus.runtime.ShutdownContext; import io.quarkus.runtime.annotations.Recorder; +import io.quarkus.vertx.http.runtime.PortSystemProperties; import io.vertx.core.AbstractVerticle; import io.vertx.core.AsyncResult; import io.vertx.core.DeploymentOptions; @@ -226,7 +228,7 @@ private void prodStart(GrpcContainer grpcContainer, Vertx vertx, GrpcServerConfi private void postStartup(GrpcServerConfiguration configuration, GrpcBuilderProvider provider, boolean test) { initHealthStorage(); - int port = test ? configuration.testPort : configuration.port; + int port = test ? testPort(configuration) : configuration.port; String msg = "Started "; if (provider != null) msg += provider.serverInfo(configuration.host, port, configuration); @@ -555,6 +557,7 @@ private class GrpcServerVerticle extends AbstractVerticle { private final GrpcBuilderProvider provider; private final LaunchMode launchMode; private final Map> blockingMethodsPerService; + private volatile PortSystemProperties portSystemProperties; private Server grpcServer; @@ -591,6 +594,11 @@ public void start(Promise startPromise) { } startPromise.fail(effectiveCause); } else { + int actualPort = grpcServer.getPort(); + if (actualPort != portToServer.getKey()) { + portSystemProperties = new PortSystemProperties(); + portSystemProperties.set("grpc.server", actualPort, launchMode); + } startPromise.complete(); grpcVerticleCount.incrementAndGet(); } @@ -600,6 +608,11 @@ public void start(Promise startPromise) { vertx.executeBlocking((Handler>) event -> { try { grpcServer.start(); + int actualPort = grpcServer.getPort(); + if (actualPort != portToServer.getKey()) { + portSystemProperties = new PortSystemProperties(); + portSystemProperties.set("grpc.server", actualPort, launchMode); + } startPromise.complete(); } catch (Exception e) { LOGGER.error("Unable to start gRPC server", e); @@ -623,6 +636,9 @@ public void stop(Promise stopPromise) { stopPromise.complete(); grpcVerticleCount.decrementAndGet(); } + if (portSystemProperties != null) { + portSystemProperties.restore(); + } }); } else { try { @@ -635,6 +651,10 @@ public void stop(Promise stopPromise) { } catch (Exception e) { LOGGER.errorf(e, "Unable to stop the gRPC server gracefully"); stopPromise.fail(e); + } finally { + if (portSystemProperties != null) { + portSystemProperties.restore(); + } } } } diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcTestPortUtils.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcTestPortUtils.java new file mode 100644 index 0000000000000..56d5384b9dc3e --- /dev/null +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/GrpcTestPortUtils.java @@ -0,0 +1,50 @@ +package io.quarkus.grpc.runtime; + +import java.util.List; + +import org.eclipse.microprofile.config.ConfigProvider; + +import io.quarkus.grpc.runtime.config.GrpcServerConfiguration; +import io.quarkus.grpc.runtime.config.SslServerConfig; +import io.vertx.core.http.ClientAuth; + +public final class GrpcTestPortUtils { + private GrpcTestPortUtils() { + } + + public static int testPort(GrpcServerConfiguration serverConfiguration) { + if (serverConfiguration.useSeparateServer) { + if (serverConfiguration.testPort == 0) { + return testPort("grpc.server"); + } + return serverConfiguration.testPort; + } + if (isHttpsConfigured(serverConfiguration.ssl) || !serverConfiguration.plainText) { + int httpsTestPort = port("quarkus.http.test-ssl-port"); + if (httpsTestPort == 0) { + return testPort("https"); + } + return httpsTestPort; + } + return testPort("http"); + } + + private static boolean isHttpsConfigured(SslServerConfig ssl) { + return ssl.certificate.isPresent() || ssl.key.isPresent() || ssl.keyStore.isPresent() + || ssl.keyStoreType.isPresent() || ssl.keyStorePassword.isPresent() || ssl.trustStore.isPresent() + || ssl.trustStoreType.isPresent() || ssl.cipherSuites.isPresent() || ssl.clientAuth != ClientAuth.NONE + || !isDefaultProtocols(ssl.protocols); + } + + private static boolean isDefaultProtocols(List protocols) { + return protocols.size() == 2 && protocols.contains("TLSv1.3") && protocols.contains("TLSv1.2"); + } + + private static int testPort(String subProperty) { + return port("quarkus." + subProperty + ".test-port"); + } + + private static int port(String property) { + return ConfigProvider.getConfig().getValue(property, Integer.class); + } +} diff --git a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java index ecd4b3c67cfcc..6a6ebbd0c5214 100644 --- a/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java +++ b/extensions/grpc/runtime/src/main/java/io/quarkus/grpc/runtime/supports/Channels.java @@ -3,6 +3,7 @@ import static io.grpc.internal.GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE; import static io.grpc.internal.GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE; import static io.grpc.netty.NettyChannelBuilder.DEFAULT_FLOW_CONTROL_WINDOW; +import static io.quarkus.grpc.runtime.GrpcTestPortUtils.testPort; import static io.quarkus.grpc.runtime.config.GrpcClientConfiguration.DNS; import java.io.IOException; @@ -101,6 +102,10 @@ public static Channel createChannel(String name, Set perClientIntercepto throw new IllegalStateException("gRPC client " + name + " is missing configuration."); } + if (LaunchMode.current() == LaunchMode.TEST) { + config.port = testPort(configProvider.getServerConfiguration()); + } + GrpcBuilderProvider provider = GrpcBuilderProvider.findChannelBuilderProvider(config); boolean vertxGrpc = config.useQuarkusGrpcClient; diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PortSystemProperties.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PortSystemProperties.java new file mode 100644 index 0000000000000..40fa135373900 --- /dev/null +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/PortSystemProperties.java @@ -0,0 +1,49 @@ +package io.quarkus.vertx.http.runtime; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import io.quarkus.runtime.LaunchMode; + +public class PortSystemProperties { + private final Map portPropertiesToRestore = new HashMap<>(); + + public void set(String subProperty, int actualPort, LaunchMode launchMode) { + String portPropertyValue = String.valueOf(actualPort); + //we always set the .port property, even if we are in test mode, so this will always + //reflect the current port + String portPropertyName = "quarkus." + subProperty + ".port"; + String prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue); + if (!Objects.equals(prevPortPropertyValue, portPropertyValue)) { + portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue); + } + if (launchMode == LaunchMode.TEST) { + //we also set the test-port property in a test + String testPropName = "quarkus." + subProperty + ".test-port"; + String prevTestPropPrevValue = System.setProperty(testPropName, portPropertyValue); + if (!Objects.equals(prevTestPropPrevValue, portPropertyValue)) { + portPropertiesToRestore.put(testPropName, prevTestPropPrevValue); + } + } + if (launchMode.isDevOrTest()) { + // set the profile property as well to make sure we don't have any inconsistencies + portPropertyName = "%" + launchMode.getDefaultProfile() + "." + portPropertyName; + prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue); + if (!Objects.equals(prevPortPropertyValue, portPropertyValue)) { + portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue); + } + } + } + + public void restore() { + portPropertiesToRestore.forEach((key, value) -> { + if (value == null) { + System.clearProperty(key); + } else { + System.setProperty(key, value); + } + }); + portPropertiesToRestore.clear(); + } +} diff --git a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java index 96dd8be5d5ae5..7ddb3d0f87021 100644 --- a/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java +++ b/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxHttpRecorder.java @@ -10,10 +10,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; import java.util.TreeMap; import java.util.concurrent.*; @@ -1023,7 +1021,7 @@ private static class WebDeploymentVerticle extends AbstractVerticle implements R private final LaunchMode launchMode; private volatile boolean clearHttpProperty = false; private volatile boolean clearHttpsProperty = false; - private volatile Map portPropertiesToRestore; + private volatile PortSystemProperties portSystemProperties; private final HttpConfiguration.InsecureRequests insecureRequests; private final HttpConfiguration quarkusConfig; private final AtomicInteger connectionCount; @@ -1188,31 +1186,8 @@ public void handle(AsyncResult event) { actualHttpPort = actualPort; schema = "http"; } - portPropertiesToRestore = new HashMap<>(); - String portPropertyValue = String.valueOf(actualPort); - //we always set the .port property, even if we are in test mode, so this will always - //reflect the current port - String portPropertyName = "quarkus." + schema + ".port"; - String prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue); - if (!Objects.equals(prevPortPropertyValue, portPropertyValue)) { - portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue); - } - if (launchMode == LaunchMode.TEST) { - //we also set the test-port property in a test - String testPropName = "quarkus." + schema + ".test-port"; - String prevTestPropPrevValue = System.setProperty(testPropName, portPropertyValue); - if (!Objects.equals(prevTestPropPrevValue, portPropertyValue)) { - portPropertiesToRestore.put(testPropName, prevTestPropPrevValue); - } - } - if (launchMode.isDevOrTest()) { - // set the profile property as well to make sure we don't have any inconsistencies - portPropertyName = propertyWithProfilePrefix(portPropertyName); - prevPortPropertyValue = System.setProperty(portPropertyName, portPropertyValue); - if (!Objects.equals(prevPortPropertyValue, portPropertyValue)) { - portPropertiesToRestore.put(portPropertyName, prevPortPropertyValue); - } - } + portSystemProperties = new PortSystemProperties(); + portSystemProperties.set(schema, actualPort, launchMode); } startFuture.complete(null); } @@ -1256,14 +1231,8 @@ public void stop(Promise stopFuture) { System.clearProperty(propertyWithProfilePrefix(portPropertyName)); } } - if (portPropertiesToRestore != null) { - for (Map.Entry entry : portPropertiesToRestore.entrySet()) { - if (entry.getValue() == null) { - System.clearProperty(entry.getKey()); - } else { - System.setProperty(entry.getKey(), entry.getValue()); - } - } + if (portSystemProperties != null) { + portSystemProperties.restore(); } stopFuture.complete(); diff --git a/integration-tests/grpc-test-random-port/pom.xml b/integration-tests/grpc-test-random-port/pom.xml new file mode 100644 index 0000000000000..254af0a50bc11 --- /dev/null +++ b/integration-tests/grpc-test-random-port/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + + + quarkus-integration-tests-parent + io.quarkus + 999-SNAPSHOT + + + quarkus-integration-test-grpc-test-random-port + Quarkus - Integration Tests - gRPC - Test Random Port + + + + io.quarkus + quarkus-grpc + + + io.quarkus + quarkus-junit5 + test + + + org.assertj + assertj-core + test + + + + + io.quarkus + quarkus-grpc-deployment + ${project.version} + pom + test + + + * + * + + + + + + + + + io.quarkus + quarkus-maven-plugin + + + + generate-code + build + + + + + + + + diff --git a/integration-tests/grpc-test-random-port/src/main/java/io/quarkus/grpc/examples/hello/HelloWorldService.java b/integration-tests/grpc-test-random-port/src/main/java/io/quarkus/grpc/examples/hello/HelloWorldService.java new file mode 100644 index 0000000000000..6b13fdf54462d --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/java/io/quarkus/grpc/examples/hello/HelloWorldService.java @@ -0,0 +1,23 @@ +package io.quarkus.grpc.examples.hello; + +import java.util.concurrent.atomic.AtomicInteger; + +import examples.HelloReply; +import examples.HelloRequest; +import examples.MutinyGreeterGrpc; +import io.quarkus.grpc.GrpcService; +import io.smallrye.mutiny.Uni; + +@GrpcService +public class HelloWorldService extends MutinyGreeterGrpc.GreeterImplBase { + + AtomicInteger counter = new AtomicInteger(); + + @Override + public Uni sayHello(HelloRequest request) { + int count = counter.incrementAndGet(); + String name = request.getName(); + return Uni.createFrom().item("Hello " + name) + .map(res -> HelloReply.newBuilder().setMessage(res).setCount(count).build()); + } +} diff --git a/integration-tests/grpc-test-random-port/src/main/proto/helloworld.proto b/integration-tests/grpc-test-random-port/src/main/proto/helloworld.proto new file mode 100644 index 0000000000000..504c84ccf6c40 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/proto/helloworld.proto @@ -0,0 +1,22 @@ + +syntax = "proto2"; + +option java_multiple_files = true; +option java_package = "examples"; +option java_outer_classname = "HelloWorldProto"; +option objc_class_prefix = "HLW"; + +package helloworld; + +service Greeter { + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +message HelloRequest { + required string name = 1; +} + +message HelloReply { + required string message = 1; + optional int32 count = 2; +} diff --git a/integration-tests/grpc-test-random-port/src/main/resources/tls/README.md b/integration-tests/grpc-test-random-port/src/main/resources/tls/README.md new file mode 100644 index 0000000000000..3d6af99d99dc0 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/resources/tls/README.md @@ -0,0 +1,54 @@ +# Generating the certificates and keys + +The ca is self-signed: +---------------------- + +```bash +openssl req -x509 -new -newkey rsa:4096 -nodes -keyout ca.key -out ca.pem \ +-config ca-openssl.cnf -days 3650 -extensions v3_req +``` + +When prompted for certificate information, everything is default. + +Client is issued by CA: +----------------------- + +```bash +openssl genrsa -out client.key.rsa 4096 +openssl pkcs8 -topk8 -in client.key.rsa -out client.key -nocrypt +openssl req -new -key client.key -out client.csr +``` + +When prompted for certificate information, everything is default except the +common name which is set to `testclient`. + +```bash +openssl x509 -req -CA ca.pem -CAkey ca.key -CAcreateserial -in client.csr \ + -out client.pem -days 3650 +``` + +server is issued by CA with a special config for subject alternative names: +---------------------------------------------------------------------------- + +```bash +openssl genrsa -out server1.key.rsa 4096 +openssl pkcs8 -topk8 -in server1.key.rsa -out server.key -nocrypt +openssl req -new -key server.key -out server.csr -config server-openssl.cnf +``` + +When prompted for certificate information, everything is default except the +common name which is set to `localhost`. + +```bash +openssl x509 -req -CA ca.pem -CAkey ca.key -CAcreateserial -in server.csr \ + -out server.pem -extfile server-openssl.cnf -days 3650 +``` + +Cleanup +------- + +```bash +rm *.rsa +rm *.csr +rm ca.srl +``` \ No newline at end of file diff --git a/integration-tests/grpc-test-random-port/src/main/resources/tls/ca-openssl.cnf b/integration-tests/grpc-test-random-port/src/main/resources/tls/ca-openssl.cnf new file mode 100644 index 0000000000000..7a8528ec2304a --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/resources/tls/ca-openssl.cnf @@ -0,0 +1,17 @@ +[req] +distinguished_name = req_distinguished_name +req_extensions = v3_req + +[req_distinguished_name] +countryName = Country Name (2 letter code) +countryName_default = FR +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State +organizationName = Organization Name (eg, company) +organizationName_default = Acme Corp +commonName = Common Name (eg, YOUR name) +commonName_default = testca + +[v3_req] +basicConstraints = CA:true +keyUsage = critical, keyCertSign \ No newline at end of file diff --git a/integration-tests/grpc-test-random-port/src/main/resources/tls/ca.pem b/integration-tests/grpc-test-random-port/src/main/resources/tls/ca.pem new file mode 100644 index 0000000000000..a4a48b8a02406 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/resources/tls/ca.pem @@ -0,0 +1,31 @@ +-----BEGIN CERTIFICATE----- +MIIFWzCCA0OgAwIBAgIULWtJ2TRjfRiHVupTn5BaOA0GS5UwDQYJKoZIhvcNAQEL +BQAwRzELMAkGA1UEBhMCRlIxEzARBgNVBAgMClNvbWUtU3RhdGUxEjAQBgNVBAoM +CUFjbWUgQ29ycDEPMA0GA1UEAwwGdGVzdGNhMB4XDTIyMDEyNTE2MzgwM1oXDTMy +MDEyMzE2MzgwM1owRzELMAkGA1UEBhMCRlIxEzARBgNVBAgMClNvbWUtU3RhdGUx +EjAQBgNVBAoMCUFjbWUgQ29ycDEPMA0GA1UEAwwGdGVzdGNhMIICIjANBgkqhkiG +9w0BAQEFAAOCAg8AMIICCgKCAgEAv1CZpbAuUjDiRT7ozkp9FtPjEKdQv+iPiE3N +slJMIsG0KNRNhTKiNkLfW/lA+FSXT6of6yugNEJiq75UlBt+fYBv7DXKiNkd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yBCFCGRakOCJtWmW7PprkAYpT5nhNuiv6ySkoviH/0LSQgA +2vL90Vsb65hQOcnKxCT+EOWcgGpmeOh7o7Q/dPf5Mamv0eIjkaM4+TZrEsRI4OfX +Zv+ywt4fyzZ8fS7dR2R/mY1fi9yX1UH9yF2JjQ/lzoU7Fg+0xa+8L7XmE3gotD5e +eCurLqBbbt5HV5uQOHWRCKJmQvHnlYLNqN4kfXGMDswTlBGWhkIhZ098lCDdXNx8 +ZAtOidDm9i08bmKhfQ0U33EJU4oI3p5IifJIIJCs9W++VsQgmKscZWyoXkzcnRrV +CZ581QYcLVGmQo09jmqIZTadp8Rz62+9dUnHsN+z6w== +-----END CERTIFICATE----- diff --git a/integration-tests/grpc-test-random-port/src/main/resources/tls/server-openssl.cnf b/integration-tests/grpc-test-random-port/src/main/resources/tls/server-openssl.cnf new file mode 100644 index 0000000000000..3962a52d790d4 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/resources/tls/server-openssl.cnf @@ -0,0 +1,80 @@ +[req] +distinguished_name = req_distinguished_name +req_extensions = v3_req + +[req_distinguished_name] +countryName = Country Name (2 letter code) +countryName_default = FR +stateOrProvinceName = State or Province Name (full name) +stateOrProvinceName_default = Some-State +localityName = Locality Name (eg, city) +localityName_default = Valence +organizationName = Organization Name (eg, company) +organizationName_default = Acme Corp +commonName = Common Name (eg, YOUR name) +commonName_max = 64 + +#################################################################### +[ ca ] +default_ca = CA_default # The default ca section + +#################################################################### +[ CA_default ] + +dir = . # Where everything is kept +certs = $dir # Where the issued certs are kept +crl_dir = $dir # Where the issued crl are kept +database = $dir/index.txt # database index file. +new_certs_dir = $dir # default place for new certs. + +certificate = $dir/ca.pem # The CA certificate +serial = $dir/serial # The current serial number +crlnumber = $dir/crlnumber # the current crl number + # must be commented out to leave a V1 CRL +crl = $dir/crl.pem # The current CRL +private_key = $dir/private/cakey.pem# The private key +RANDFILE = $dir/private/.rand # private random number file + +x509_extensions = usr_cert + +# Comment out the following two lines for the "traditional" +# (and highly broken) format. +name_opt = ca_default # Subject Name options +cert_opt = ca_default # Certificate field options + +# Extension copying option: use with caution. +# copy_extensions = copy + +# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs +# so this is commented out by default to leave a V1 CRL. +# crlnumber must also be commented out to leave a V1 CRL. +# crl_extensions = crl_ext + +default_days = 365 # how long to certify for +default_crl_days= 30 # how long before next CRL +default_md = default # use public key default MD +preserve = no # keep passed DN ordering + +# A few difference way of specifying how similar the request should look +# For type CA, the listed attributes must be the same, and the optional +# and supplied fields are just that :-) +policy = policy_anything +[ policy_anything ] +countryName = optional +stateOrProvinceName = optional +localityName = optional +organizationName = optional +organizationalUnitName = optional +commonName = supplied +emailAddress = optional + +[v3_req] +basicConstraints = CA:FALSE +keyUsage = nonRepudiation, digitalSignature, keyEncipherment +subjectAltName = @alt_names + +[alt_names] +DNS.1 = localhost +DNS.2 = *.test.com +IP.1 = "127.0.0.1" +IP.2 = "192.168.1.3" \ No newline at end of file diff --git a/integration-tests/grpc-test-random-port/src/main/resources/tls/server.key b/integration-tests/grpc-test-random-port/src/main/resources/tls/server.key new file mode 100644 index 0000000000000..62560725b6c0a --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/resources/tls/server.key @@ -0,0 +1,52 @@ +-----BEGIN PRIVATE KEY----- +MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQC/uh1ElFBRMVtW +JiPFG52P6zeUVxOHthiTnITlyLpjMAs92xBbVSBg7NCsA/KS/NEBawosTcQcLDSq +43hwv56wjRWMaN5ERRS8hVAmHOFv30x8EDtVRYnq0HVvG2HpUhU9xkIwUVshoFOP +YKeEJHB3wzJO9bGEJlxnKNgl0e51rGwe8RU4SkFz/3M0rvhda2/AReRMssNKwBxr +kLbgnm51Ps0AkDLbHp5g2oxR833qGDI2wgJK3wpKokEiWvMNRD1KC89VNGm0iinH +gOOmMXl4weE86eyu9In10NeHSTHc/Xtvim8OejuHpUr5+KheTaKA51Ykuqq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PcBwziByraM0AtTbk0Kb42/UyPqO/fKZrhHvw4HpIh83C/OQ+UZcAKk +9Ka3D4JKtI4/h5aihO/Lp2zaL451K1OMM6c0RburcZkmq495xY4inlmGc6VhGdw7 +oPnukEHDlqdav7LQQLZkavDSJKhg/c25Dt+FR6N3esaiRDbBPxlhVN8PD5MPhI7n +8J1OaAU5zYbgZtKpky+oXNBa17gRUc0Ck43rjSdUpuFXFKsBgQGsfd1+eC4BOADi +0ySpTfMBwEl7M0vO6Y2QOKqV9+6apWm4NzlqQ3dCTpUMqPbtkZ5QLr3WZLnS1dAP +pQKCAQBp2cyfTCCMxcNShb+QRDvecWzZl/tW/RR7KkhgNfyKAc9NO0hBqj2V0GQW +Mrz14filqZflfBcFupXjN0juxQfFTs5aSaYq4uSsjkM48qasFu5+Dtkcc4vZYjYa ++9nvEkxnlvrnFN9OVuPg1vBOj4fk6YJLnpBzxomvMtKx+jc7NOCEeue02bDDDK12 +/r1QZKqtn2tky4gSumcL1t0o5anev2bYxkkfe+bLkAvWyxKoq6e9mOexKTaQFQDB +1mN0Zo5ji9HRefsVDklQLL98WzcQJeQ5FnpcMz8ZfJD5J+qFrWR2FhFgGpX77aj7 +4rK5nJlEjMmtG+U7DsUZKoQXOurb +-----END PRIVATE KEY----- diff --git a/integration-tests/grpc-test-random-port/src/main/resources/tls/server.pem b/integration-tests/grpc-test-random-port/src/main/resources/tls/server.pem new file mode 100644 index 0000000000000..e3ea1e5b98864 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/main/resources/tls/server.pem @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFKjCCAxICFHCq389HP/Q6SkyQ8R2Nf8ByOchjMA0GCSqGSIb3DQEBCwUAMEcx +CzAJBgNVBAYTAkZSMRMwEQYDVQQIDApTb21lLVN0YXRlMRIwEAYDVQQKDAlBY21l +IENvcnAxDzANBgNVBAMMBnRlc3RjYTAeFw0yMjAxMjUxNjQzMDBaFw0zMjAxMjMx +NjQzMDBaM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JYaMTXfzR703s +5jJC9Ej+SBDLmEQXNbD98bdWIjgtDdPg9mErEYqhKi8GWHUpxBEncDTIxigfhWjk +JN7ucJLEQF7JwnQXFLqcsbYvi+RGp2wASZ6vtveEENOBQGoxk+zt1zwmCn7mja+U +rukfcLd6scmRWGoW6HqCfyfxQxjtSM378lo3Mz9SM5IFmVxop+b92LBQrnHh0sFL +Mqa41jVjUPyADnDPqX71l7FDrBxKvreEAEHoqIZuVvFZiMzYHsxx6nscRKVMVFHU +23c4SCdc3THI5EYwiqJWB/YbbNr56TClhavmbs8kn5f4gtNPr4IP4E1TT2QblYqv +CQ/yQBncvHzmuTQd+pbSSPfrE7hU2IqNL7ahzHlTmkIzVvxtqR8HhLeRNC7N8ZUQ +HgWkVqtdzw37o/ZzWeD/N8cZ43M2S7DkSHaMS3DWCLkW6S8WyA6sm6JQo83tqgVR +mIbNPYAYjX5WyWK4Fbaswes9ZepXgUAiUGDtKpvd +-----END CERTIFICATE----- diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainIT.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainIT.java new file mode 100644 index 0000000000000..9e8da069b8d21 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainIT.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusIntegrationTest +@TestProfile(RandomPortSeparateServerPlainTestBase.Profile.class) +class RandomPortSeparateServerPlainIT extends RandomPortSeparateServerPlainTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainTest.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainTest.java new file mode 100644 index 0000000000000..7b81f80af8068 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainTest.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestProfile(RandomPortSeparateServerPlainTestBase.Profile.class) +class RandomPortSeparateServerPlainTest extends RandomPortSeparateServerPlainTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainTestBase.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainTestBase.java new file mode 100644 index 0000000000000..b095397685e8e --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerPlainTestBase.java @@ -0,0 +1,21 @@ +package io.quarkus.grpc.examples.hello; + +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTestProfile; + +abstract class RandomPortSeparateServerPlainTestBase extends RandomPortTestBase { + public static class Profile implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of( + "quarkus.grpc.server.test-port", "0", + "quarkus.grpc.clients.hello.host", "localhost"); + } + } + + @Override + protected String serverPortProperty() { + return "quarkus.grpc.server.test-port"; + } +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsIT.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsIT.java new file mode 100644 index 0000000000000..51853a2854b11 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsIT.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusIntegrationTest +@TestProfile(RandomPortSeparateServerTlsTestBase.Profile.class) +class RandomPortSeparateServerTlsIT extends RandomPortSeparateServerTlsTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsTest.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsTest.java new file mode 100644 index 0000000000000..ecba667416c36 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsTest.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestProfile(RandomPortSeparateServerTlsTestBase.Profile.class) +class RandomPortSeparateServerTlsTest extends RandomPortSeparateServerTlsTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsTestBase.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsTestBase.java new file mode 100644 index 0000000000000..4e0dd5d0becf2 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortSeparateServerTlsTestBase.java @@ -0,0 +1,25 @@ +package io.quarkus.grpc.examples.hello; + +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTestProfile; + +abstract class RandomPortSeparateServerTlsTestBase extends RandomPortTestBase { + public static class Profile implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of( + "quarkus.grpc.server.plain-text", "false", + "quarkus.grpc.server.test-port", "0", + "quarkus.grpc.server.ssl.certificate", "tls/server.pem", + "quarkus.grpc.server.ssl.key", "tls/server.key", + "quarkus.grpc.clients.hello.host", "localhost", + "quarkus.grpc.clients.hello.ssl.trust-store", "tls/ca.pem"); + } + } + + @Override + protected String serverPortProperty() { + return "quarkus.grpc.server.test-port"; + } +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortTestBase.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortTestBase.java new file mode 100644 index 0000000000000..5fe588155b622 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortTestBase.java @@ -0,0 +1,38 @@ +package io.quarkus.grpc.examples.hello; + +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +import org.eclipse.microprofile.config.ConfigProvider; +import org.junit.jupiter.api.Test; + +import com.google.common.net.HostAndPort; + +import examples.HelloReply; +import examples.HelloRequest; +import examples.MutinyGreeterGrpc.MutinyGreeterStub; +import io.grpc.Channel; +import io.quarkus.grpc.GrpcClient; + +abstract class RandomPortTestBase { + @GrpcClient("hello") + MutinyGreeterStub client; + + @GrpcClient("hello") + Channel channel; + + @Test + void testRandomPort() { + assertSoftly(softly -> { + HelloRequest request = HelloRequest.newBuilder().setName("neo").build(); + HelloReply reply = client.sayHello(request).await().indefinitely(); + softly.assertThat(reply.getMessage()).startsWith("Hello neo"); + + int clientPort = HostAndPort.fromString(channel.authority()).getPort(); + int serverPort = ConfigProvider.getConfig().getValue(serverPortProperty(), Integer.class); + softly.assertThat(clientPort).isNotEqualTo(0); + softly.assertThat(clientPort).isEqualTo(serverPort); + }); + } + + protected abstract String serverPortProperty(); +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainIT.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainIT.java new file mode 100644 index 0000000000000..bef37a3a9e053 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainIT.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusIntegrationTest +@TestProfile(RandomPortVertxServerPlainTestBase.Profile.class) +class RandomPortVertxServerPlainIT extends RandomPortVertxServerPlainTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainTest.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainTest.java new file mode 100644 index 0000000000000..eb1803fe4fe5a --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainTest.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestProfile(RandomPortVertxServerPlainTestBase.Profile.class) +class RandomPortVertxServerPlainTest extends RandomPortVertxServerPlainTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainTestBase.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainTestBase.java new file mode 100644 index 0000000000000..18c558ad38038 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerPlainTestBase.java @@ -0,0 +1,22 @@ +package io.quarkus.grpc.examples.hello; + +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTestProfile; + +abstract class RandomPortVertxServerPlainTestBase extends RandomPortTestBase { + public static class Profile implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of( + "quarkus.grpc.server.use-separate-server", "false", + "quarkus.http.test-port", "0", + "quarkus.grpc.clients.hello.host", "localhost"); + } + } + + @Override + protected String serverPortProperty() { + return "quarkus.http.test-port"; + } +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsIT.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsIT.java new file mode 100644 index 0000000000000..632306895da84 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsIT.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusIntegrationTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusIntegrationTest +@TestProfile(RandomPortVertxServerTlsTestBase.Profile.class) +class RandomPortVertxServerTlsIT extends RandomPortVertxServerTlsTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsTest.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsTest.java new file mode 100644 index 0000000000000..0915139ad65bf --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsTest.java @@ -0,0 +1,9 @@ +package io.quarkus.grpc.examples.hello; + +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestProfile(RandomPortVertxServerTlsTestBase.Profile.class) +class RandomPortVertxServerTlsTest extends RandomPortVertxServerTlsTestBase { +} diff --git a/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsTestBase.java b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsTestBase.java new file mode 100644 index 0000000000000..93f7d45925c45 --- /dev/null +++ b/integration-tests/grpc-test-random-port/src/test/java/io/quarkus/grpc/examples/hello/RandomPortVertxServerTlsTestBase.java @@ -0,0 +1,26 @@ +package io.quarkus.grpc.examples.hello; + +import java.util.Map; + +import io.quarkus.test.junit.QuarkusTestProfile; + +abstract class RandomPortVertxServerTlsTestBase extends RandomPortTestBase { + public static class Profile implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of( + "quarkus.grpc.server.use-separate-server", "false", + "quarkus.grpc.server.plain-text", "false", + "quarkus.http.test-ssl-port", "0", + "quarkus.http.ssl.certificate.files", "tls/server.pem", + "quarkus.http.ssl.certificate.key-files", "tls/server.key", + "quarkus.grpc.clients.hello.host", "localhost", + "quarkus.grpc.clients.hello.ssl.trust-store", "tls/ca.pem"); + } + } + + @Override + protected String serverPortProperty() { + return "quarkus.https.test-port"; + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 5ef1e6a719139..81ef0c0d0dc85 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -379,6 +379,7 @@ grpc-stork-response-time grpc-stork-simple grpc-exceptions + grpc-test-random-port google-cloud-functions-http google-cloud-functions istio