Skip to content

Commit d4352c2

Browse files
authored
Update grpc-java version to 1.54.1 and clean up grpc tests (helidon-io#6685)
* Update grpc-java version to 1.54.1 and clean up grpc tests
1 parent b8a5df7 commit d4352c2

6 files changed

Lines changed: 56 additions & 36 deletions

File tree

dependencies/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<version.lib.graphql-java>17.5</version.lib.graphql-java>
6060
<version.lib.graphql-java.extended.scalars>17.1</version.lib.graphql-java.extended.scalars>
6161
<version.lib.gson>2.9.0</version.lib.gson>
62-
<version.lib.grpc>1.49.2</version.lib.grpc>
62+
<version.lib.grpc>1.54.1</version.lib.grpc>
6363
<version.lib.guava>31.1-jre</version.lib.guava>
6464
<version.lib.h2>2.1.212</version.lib.h2>
6565
<version.lib.hamcrest>1.3</version.lib.hamcrest>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2023 Oracle and/or its affiliates.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.grpc.util;
18+
19+
import io.grpc.LoadBalancerProvider;
20+
21+
/**
22+
* A dummy class to allow the re-packaging of grpc-java
23+
* with a module-info.java file to work.
24+
* <p>
25+
* This file will be replaced by the real implementation from grpc-java
26+
* as part of the re-packaging process.
27+
*/
28+
public class OutlierDetectionLoadBalancerProvider
29+
extends LoadBalancerProvider {
30+
}

grpc/io.grpc/src/main/java/module-info.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,8 @@
3737

3838
provides io.grpc.LoadBalancerProvider
3939
with io.grpc.internal.PickFirstLoadBalancerProvider,
40-
io.grpc.util.SecretRoundRobinLoadBalancerProvider.Provider;
40+
io.grpc.util.SecretRoundRobinLoadBalancerProvider.Provider,
41+
io.grpc.util.OutlierDetectionLoadBalancerProvider;
4142

4243
provides io.grpc.NameResolverProvider
4344
with io.grpc.internal.DnsNameResolverProvider;

grpc/server/src/test/java/io/helidon/grpc/server/SslIT.java

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,15 +33,14 @@
3333

3434
import com.oracle.bedrock.runtime.LocalPlatform;
3535
import com.oracle.bedrock.runtime.network.AvailablePortIterator;
36-
import io.grpc.Channel;
3736
import io.grpc.ManagedChannel;
3837
import io.grpc.StatusRuntimeException;
3938
import io.grpc.netty.GrpcSslContexts;
4039
import io.grpc.netty.NegotiationType;
4140
import io.grpc.netty.NettyChannelBuilder;
4241
import io.netty.handler.ssl.SslContext;
4342
import io.netty.handler.ssl.SslContextBuilder;
44-
import org.junit.AfterClass;
43+
import org.junit.jupiter.api.AfterAll;
4544
import org.junit.jupiter.api.Assertions;
4645
import org.junit.jupiter.api.BeforeAll;
4746
import org.junit.jupiter.api.Test;
@@ -86,7 +85,7 @@ public class SslIT {
8685
// ----- test lifecycle -------------------------------------------------
8786

8887
@BeforeAll
89-
public static void setup() throws Exception {
88+
public static void setup() {
9089
LogConfig.configureRuntime();
9190

9291
AvailablePortIterator ports = LocalPlatform.get().getAvailablePorts();
@@ -100,7 +99,7 @@ public static void setup() throws Exception {
10099
grpcServer_2WaySSLConfig = startGrpcServer(port2WaySSLConfig, true/*mutual*/, true /*useConfig*/);
101100
}
102101

103-
@AfterClass
102+
@AfterAll
104103
public static void cleanup() throws Exception
105104
{
106105
CompletableFuture<?>[] futures =
@@ -120,7 +119,7 @@ public void shouldConnectWithoutClientCertsFor1Way() throws Exception {
120119
// client do not have to provide certs for 1way ssl
121120
SslContext sslContext = clientSslContext(tlsCaCert, null, null);
122121

123-
Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port())
122+
ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port())
124123
.negotiationType(NegotiationType.TLS)
125124
.sslContext(sslContext)
126125
.build();
@@ -129,15 +128,15 @@ public void shouldConnectWithoutClientCertsFor1Way() throws Exception {
129128
Echo.EchoResponse response = EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build());
130129
assertThat(response.getMessage(), is("foo"));
131130

132-
((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS);
131+
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
133132
}
134133

135134
@Test
136135
public void shouldNotConnectWithoutCAFor1Way() throws Exception {
137136
// client do not have to provide certs for 1way ssl
138137
SslContext sslContext = clientSslContext(null, null, null);
139138

140-
Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port())
139+
ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_1WaySSL.port())
141140
.negotiationType(NegotiationType.TLS)
142141
.sslContext(sslContext)
143142
.build();
@@ -146,7 +145,7 @@ public void shouldNotConnectWithoutCAFor1Way() throws Exception {
146145
Assertions.assertThrows(StatusRuntimeException.class,
147146
()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()));
148147

149-
((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS);
148+
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
150149
}
151150

152151
@Test
@@ -157,7 +156,7 @@ public void shouldConnectWithClientCertsFor2Way() throws Exception {
157156

158157
SslContext sslContext = clientSslContext(tlsCaCert, tlsClientCert, tlsClientKey);
159158

160-
Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port())
159+
ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port())
161160
.negotiationType(NegotiationType.TLS)
162161
.sslContext(sslContext)
163162
.build();
@@ -166,7 +165,7 @@ public void shouldConnectWithClientCertsFor2Way() throws Exception {
166165
Echo.EchoResponse response = EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build());
167166
assertThat(response.getMessage(), is("foo"));
168167

169-
((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS);
168+
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
170169
}
171170

172171
@Test
@@ -175,7 +174,7 @@ public void shouldNotConnectWithoutCAFor2Way() throws Exception {
175174
Resource tlsClientKey = Resource.create(CLIENT_KEY);
176175
SslContext sslContext = clientSslContext(null, tlsClientCert, tlsClientKey);
177176

178-
Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port())
177+
ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port())
179178
.negotiationType(NegotiationType.TLS)
180179
.sslContext(sslContext)
181180
.build();
@@ -184,7 +183,7 @@ public void shouldNotConnectWithoutCAFor2Way() throws Exception {
184183
Assertions.assertThrows(StatusRuntimeException.class,
185184
()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()));
186185

187-
((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS);
186+
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
188187
}
189188

190189
@Test
@@ -193,7 +192,7 @@ public void shouldNotConnectWithoutClientCertFor2Way() throws Exception {
193192
Resource tlsClientKey = Resource.create(CLIENT_KEY);
194193
SslContext sslContext = clientSslContext(tlsCaCert, null, tlsClientKey);
195194

196-
Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port())
195+
ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSL.port())
197196
.negotiationType(NegotiationType.TLS)
198197
.sslContext(sslContext)
199198
.build();
@@ -202,7 +201,7 @@ public void shouldNotConnectWithoutClientCertFor2Way() throws Exception {
202201
Assertions.assertThrows(StatusRuntimeException.class,
203202
()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()));
204203

205-
((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS);
204+
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
206205
}
207206

208207
@Test
@@ -212,7 +211,7 @@ public void shouldConnectWithClientCertsFor2WayUseConfig() throws Exception{
212211
Resource tlsClientKey = Resource.create(CLIENT_KEY);
213212
SslContext sslContext = clientSslContext(tlsCaCert, tlsClientCert, tlsClientKey);
214213

215-
Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port())
214+
ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port())
216215
.negotiationType(NegotiationType.TLS)
217216
.sslContext(sslContext)
218217
.build();
@@ -221,7 +220,7 @@ public void shouldConnectWithClientCertsFor2WayUseConfig() throws Exception{
221220
Echo.EchoResponse response = EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build());
222221
assertThat(response.getMessage(), is("foo"));
223222

224-
((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS);
223+
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
225224
}
226225

227226
@Test
@@ -230,7 +229,7 @@ public void shouldNotConnectWithoutClientCertFor2WayUseConfig() throws Exception
230229
Resource tlsClientKey = Resource.create(CLIENT_KEY);
231230
SslContext sslContext = clientSslContext(tlsCaCert, null, tlsClientKey);
232231

233-
Channel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port())
232+
ManagedChannel channel = NettyChannelBuilder.forAddress("localhost", grpcServer_2WaySSLConfig.port())
234233
.negotiationType(NegotiationType.TLS)
235234
.sslContext(sslContext)
236235
.build();
@@ -239,7 +238,7 @@ public void shouldNotConnectWithoutClientCertFor2WayUseConfig() throws Exception
239238
Assertions.assertThrows(StatusRuntimeException.class,
240239
()->EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build()));
241240

242-
((ManagedChannel) channel).shutdown().awaitTermination(5, TimeUnit.SECONDS);
241+
channel.shutdown().awaitTermination(5, TimeUnit.SECONDS);
243242
}
244243

245244
// ----- helper methods -------------------------------------------------
@@ -260,10 +259,8 @@ private static SslContext clientSslContext(Resource trustCertCollectionFilePath,
260259

261260
/**
262261
* Start the gRPC Server listening on the specified nPort.
263-
*
264-
* @throws Exception in case of an error
265262
*/
266-
private static GrpcServer startGrpcServer(int nPort, boolean mutual, boolean useConfig ) throws Exception {
263+
private static GrpcServer startGrpcServer(int nPort, boolean mutual, boolean useConfig ) {
267264
Resource tlsCert = Resource.create(SERVER_CERT);
268265
Resource tlsKey = Resource.create(SERVER_KEY);
269266
Resource tlsCaCert = Resource.create(CA_CERT);

grpc/server/src/test/java/io/helidon/grpc/server/TracingIT.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2019, 2023 Oracle and/or its affiliates.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -46,7 +46,6 @@
4646
import zipkin2.Span;
4747
import zipkin2.junit.ZipkinRule;
4848

49-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
5049
import static org.hamcrest.CoreMatchers.containsString;
5150
import static org.hamcrest.CoreMatchers.is;
5251
import static org.hamcrest.CoreMatchers.not;
@@ -110,7 +109,7 @@ public void shouldTraceMethodNameAndHeaders() {
110109
// call the gRPC Echo service so that there should be tracing span sent to zipkin server
111110
EchoServiceGrpc.newBlockingStub(channel).echo(Echo.EchoRequest.newBuilder().setMessage("foo").build());
112111

113-
Eventually.assertThat(invoking(this).getSpanCount(), is(not(0)));
112+
Eventually.assertDeferred(() -> zipkin.collectorMetrics().spans(), is(not(0)));
114113

115114
List<List<Span>> listTraces = zipkin.getTraces();
116115
assertThat(listTraces, is(notNullValue()));
@@ -183,13 +182,6 @@ private static void startGrpcServer() throws Exception {
183182
LOGGER.info("Started gRPC server at: localhost:" + grpcServer.port());
184183
}
185184

186-
/**
187-
* Return the span count collect.
188-
*/
189-
public int getSpanCount() {
190-
return zipkin.collectorMetrics().spans();
191-
}
192-
193185
/**
194186
* A {@link io.grpc.ServerInterceptor} that captures the context set when
195187
* the request executed.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<version.lib.test.containers.keycloak>2.3.0</version.lib.test.containers.keycloak>
8080
<version.lib.testng>7.7.0</version.lib.testng>
8181
<version.lib.zipkin.junit>2.12.5</version.lib.zipkin.junit>
82-
<version.lib.bedrock>5.0.11</version.lib.bedrock>
82+
<version.lib.bedrock>7.0.1</version.lib.bedrock>
8383
<version.lib.awaitility>3.1.6</version.lib.awaitility>
8484
<version.lib.weld-junit>3.0.0.Final</version.lib.weld-junit>
8585
<version.lib.jmh>1.23</version.lib.jmh>

0 commit comments

Comments
 (0)