use of io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder in project pravega by pravega.
the class ControllerImplTest method testKeepAliveWithServer.
@Test
public void testKeepAliveWithServer() throws Exception {
// Verify that the same RPC with permissible keepalive time succeeds.
int serverPort2 = TestUtils.getAvailableListenPort();
NettyServerBuilder testServerBuilder = NettyServerBuilder.forPort(serverPort2).addService(testServerImpl).permitKeepAliveTime(KEEP_ALIVE_TEST_PERMIT_TIME_MILLIS, TimeUnit.MILLISECONDS);
if (testSecure) {
testServerBuilder = testServerBuilder.useTransportSecurity(new File(SecurityConfigDefaults.TLS_SERVER_CERT_PATH), new File(SecurityConfigDefaults.TLS_SERVER_PRIVATE_KEY_PATH));
}
@Cleanup("shutdownNow") Server testServer = testServerBuilder.build().start();
NettyChannelBuilder builder = NettyChannelBuilder.forAddress("localhost", serverPort2).keepAliveTime(KEEP_ALIVE_TEST_KEEP_ALIVE_MILLIS, TimeUnit.MILLISECONDS);
if (testSecure) {
builder = builder.sslContext(GrpcSslContexts.forClient().trustManager(new File(SecurityConfigDefaults.TLS_CA_CERT_PATH)).build());
} else {
builder = builder.usePlaintext();
}
@Cleanup final ControllerImpl controller1 = new ControllerImpl(builder, ControllerImplConfig.builder().clientConfig(ClientConfig.builder().trustStore(SecurityConfigDefaults.TLS_CA_CERT_PATH).controllerURI(URI.create((testSecure ? "tls://" : "tcp://") + "localhost:" + serverPort)).build()).retryAttempts(1).initialBackoffMillis(1).build(), this.executor);
val createStreamStatus = controller1.createStream("scope1", "streamdelayed", StreamConfiguration.builder().scalingPolicy(ScalingPolicy.fixed(1)).build());
assertTrue(createStreamStatus.get());
testServer.shutdownNow();
}
Aggregations