diff --git a/dependencies/pom.xml b/dependencies/pom.xml index dc5b780c4b6..aa98aab438b 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -59,7 +59,7 @@ 17.5 17.1 2.9.0 - 1.49.2 + 1.54.1 31.1-jre 2.1.212 1.3 diff --git a/grpc/io.grpc/src/main/java/io/grpc/util/OutlierDetectionLoadBalancerProvider.java b/grpc/io.grpc/src/main/java/io/grpc/util/OutlierDetectionLoadBalancerProvider.java new file mode 100644 index 00000000000..77a9713ba20 --- /dev/null +++ b/grpc/io.grpc/src/main/java/io/grpc/util/OutlierDetectionLoadBalancerProvider.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.grpc.util; + +import io.grpc.LoadBalancerProvider; + +/** + * A dummy class to allow the re-packaging of grpc-java + * with a module-info.java file to work. + *

+ * This file will be replaced by the real implementation from grpc-java + * as part of the re-packaging process. + */ +public class OutlierDetectionLoadBalancerProvider + extends LoadBalancerProvider { +} diff --git a/grpc/io.grpc/src/main/java/module-info.java b/grpc/io.grpc/src/main/java/module-info.java index 6ed4c563b1f..42a64e8949a 100644 --- a/grpc/io.grpc/src/main/java/module-info.java +++ b/grpc/io.grpc/src/main/java/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022 Oracle and/or its affiliates. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,8 @@ provides io.grpc.LoadBalancerProvider with io.grpc.internal.PickFirstLoadBalancerProvider, - io.grpc.util.SecretRoundRobinLoadBalancerProvider.Provider; + io.grpc.util.SecretRoundRobinLoadBalancerProvider.Provider, + io.grpc.util.OutlierDetectionLoadBalancerProvider; provides io.grpc.NameResolverProvider with io.grpc.internal.DnsNameResolverProvider; diff --git a/grpc/server/src/test/java/io/helidon/grpc/server/SslIT.java b/grpc/server/src/test/java/io/helidon/grpc/server/SslIT.java index ac6e8d2bf4f..08d5e4bfe5a 100644 --- a/grpc/server/src/test/java/io/helidon/grpc/server/SslIT.java +++ b/grpc/server/src/test/java/io/helidon/grpc/server/SslIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020 Oracle and/or its affiliates. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,6 @@ import com.oracle.bedrock.runtime.LocalPlatform; import com.oracle.bedrock.runtime.network.AvailablePortIterator; -import io.grpc.Channel; import io.grpc.ManagedChannel; import io.grpc.StatusRuntimeException; import io.grpc.netty.GrpcSslContexts; @@ -41,7 +40,7 @@ import io.grpc.netty.NettyChannelBuilder; import io.netty.handler.ssl.SslContext; import io.netty.handler.ssl.SslContextBuilder; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -86,7 +85,7 @@ public class SslIT { // ----- test lifecycle ------------------------------------------------- @BeforeAll - public static void setup() throws Exception { + public static void setup() { LogConfig.configureRuntime(); AvailablePortIterator ports = LocalPlatform.get().getAvailablePorts(); @@ -100,7 +99,7 @@ public static void setup() throws Exception { grpcServer_2WaySSLConfig = startGrpcServer(port2WaySSLConfig, true/*mutual*/, true /*useConfig*/); } - @AfterClass + @AfterAll public static void cleanup() throws Exception { CompletableFuture[] futures = @@ -120,7 +119,7 @@ public void shouldConnectWithoutClientCertsFor1Way() throws Exception { // client do not have to provide certs for 1way ssl SslContext sslContext = clientSslContext(tlsCaCert, null, null); - Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port()) + ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port()) .negotiationType(NegotiationType.TLS) .sslContext(sslContext) .build(); @@ -129,7 +128,7 @@ public void shouldConnectWithoutClientCertsFor1Way() throws Exception { Echo.EchoResponse response = EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()); assertThat(response.getMessage(), is("foo")); - ((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS); + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } @Test @@ -137,7 +136,7 @@ public void shouldNotConnectWithoutCAFor1Way() throws Exception { // client do not have to provide certs for 1way ssl SslContext sslContext = clientSslContext(null, null, null); - Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port()) + ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port()) .negotiationType(NegotiationType.TLS) .sslContext(sslContext) .build(); @@ -146,7 +145,7 @@ public void shouldNotConnectWithoutCAFor1Way() throws Exception { Assertions.assertThrows(StatusRuntimeException.class, ()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build())); - ((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS); + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } @Test @@ -157,7 +156,7 @@ public void shouldConnectWithClientCertsFor2Way() throws Exception { SslContext sslContext = clientSslContext(tlsCaCert, tlsClientCert, tlsClientKey); - Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port()) + ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port()) .negotiationType(NegotiationType.TLS) .sslContext(sslContext) .build(); @@ -166,7 +165,7 @@ public void shouldConnectWithClientCertsFor2Way() throws Exception { Echo.EchoResponse response = EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()); assertThat(response.getMessage(), is("foo")); - ((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS); + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } @Test @@ -175,7 +174,7 @@ public void shouldNotConnectWithoutCAFor2Way() throws Exception { Resource tlsClientKey = Resource.create(CLIENT_KEY); SslContext sslContext = clientSslContext(null, tlsClientCert, tlsClientKey); - Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port()) + ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port()) .negotiationType(NegotiationType.TLS) .sslContext(sslContext) .build(); @@ -184,7 +183,7 @@ public void shouldNotConnectWithoutCAFor2Way() throws Exception { Assertions.assertThrows(StatusRuntimeException.class, ()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build())); - ((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS); + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } @Test @@ -193,7 +192,7 @@ public void shouldNotConnectWithoutClientCertFor2Way() throws Exception { Resource tlsClientKey = Resource.create(CLIENT_KEY); SslContext sslContext = clientSslContext(tlsCaCert, null, tlsClientKey); - Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port()) + ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port()) .negotiationType(NegotiationType.TLS) .sslContext(sslContext) .build(); @@ -202,7 +201,7 @@ public void shouldNotConnectWithoutClientCertFor2Way() throws Exception { Assertions.assertThrows(StatusRuntimeException.class, ()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build())); - ((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS); + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } @Test @@ -212,7 +211,7 @@ public void shouldConnectWithClientCertsFor2WayUseConfig() throws Exception{ Resource tlsClientKey = Resource.create(CLIENT_KEY); SslContext sslContext = clientSslContext(tlsCaCert, tlsClientCert, tlsClientKey); - Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port()) + ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port()) .negotiationType(NegotiationType.TLS) .sslContext(sslContext) .build(); @@ -221,7 +220,7 @@ public void shouldConnectWithClientCertsFor2WayUseConfig() throws Exception{ Echo.EchoResponse response = EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()); assertThat(response.getMessage(), is("foo")); - ((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS); + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } @Test @@ -230,7 +229,7 @@ public void shouldNotConnectWithoutClientCertFor2WayUseConfig() throws Exception Resource tlsClientKey = Resource.create(CLIENT_KEY); SslContext sslContext = clientSslContext(tlsCaCert, null, tlsClientKey); - Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port()) + ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port()) .negotiationType(NegotiationType.TLS) .sslContext(sslContext) .build(); @@ -239,7 +238,7 @@ public void shouldNotConnectWithoutClientCertFor2WayUseConfig() throws Exception Assertions.assertThrows(StatusRuntimeException.class, ()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build())); - ((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS); + channel.shutdown().awaitTermination(5, TimeUnit.SECONDS); } // ----- helper methods ------------------------------------------------- @@ -260,10 +259,8 @@ private static SslContext clientSslContext(Resource trustCertCollectionFilePath, /** * Start the gRPC Server listening on the specified nPort. - * - * @throws Exception in case of an error */ - private static GrpcServer startGrpcServer(int nPort, boolean mutual, boolean useConfig ) throws Exception { + private static GrpcServer startGrpcServer(int nPort, boolean mutual, boolean useConfig ) { Resource tlsCert = Resource.create(SERVER_CERT); Resource tlsKey = Resource.create(SERVER_KEY); Resource tlsCaCert = Resource.create(CA_CERT); diff --git a/grpc/server/src/test/java/io/helidon/grpc/server/TracingIT.java b/grpc/server/src/test/java/io/helidon/grpc/server/TracingIT.java index 5e5c6a9d250..5f9cb3c0102 100644 --- a/grpc/server/src/test/java/io/helidon/grpc/server/TracingIT.java +++ b/grpc/server/src/test/java/io/helidon/grpc/server/TracingIT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022 Oracle and/or its affiliates. + * Copyright (c) 2019, 2023 Oracle and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,7 +46,6 @@ import zipkin2.Span; import zipkin2.junit.ZipkinRule; -import static com.oracle.bedrock.deferred.DeferredHelper.invoking; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; @@ -110,7 +109,7 @@ public void shouldTraceMethodNameAndHeaders() { // call the gRPC Echo service so that there should be tracing span sent to zipkin server EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()); - Eventually.assertThat(invoking(this).getSpanCount(), is(not(0))); + Eventually.assertDeferred(() -> zipkin.collectorMetrics().spans(), is(not(0))); List> listTraces = zipkin.getTraces(); assertThat(listTraces, is(notNullValue())); @@ -183,13 +182,6 @@ private static void startGrpcServer() throws Exception { LOGGER.info("Started gRPC server at: localhost:" + grpcServer.port()); } - /** - * Return the span count collect. - */ - public int getSpanCount() { - return zipkin.collectorMetrics().spans(); - } - /** * A {@link io.grpc.ServerInterceptor} that captures the context set when * the request executed. diff --git a/pom.xml b/pom.xml index 4103b58cb0f..11d50587713 100644 --- a/pom.xml +++ b/pom.xml @@ -79,7 +79,7 @@ 2.3.0 7.7.0 2.12.5 - 5.0.11 + 7.0.1 3.1.6 3.0.0.Final 1.23