From 84c62a264c51b9a5a85cf63ee3787f16f8f27c65 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Thu, 13 Sep 2018 16:24:23 -0700 Subject: [PATCH] Avoid using Jetty ALPN We still want Netty to test that it continues working with Jetty ALPN, but otherwise we don't want to use it. Fixes #2266 --- benchmarks/build.gradle | 10 +--------- .../io/grpc/benchmarks/driver/LoadWorker.java | 5 +++++ .../java/io/grpc/benchmarks/qps/AsyncClient.java | 3 +++ .../java/io/grpc/benchmarks/qps/AsyncServer.java | 2 ++ .../io/grpc/benchmarks/qps/OpenLoopClient.java | 3 +++ build.gradle | 6 ------ interop-testing/build.gradle | 16 ++-------------- netty/build.gradle | 6 ++++++ 8 files changed, 22 insertions(+), 29 deletions(-) diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle index 809f34ee57ba..c88f4d5a9065 100644 --- a/benchmarks/build.gradle +++ b/benchmarks/build.gradle @@ -34,6 +34,7 @@ dependencies { libraries.netty_epoll, libraries.math compileOnly libraries.javax_annotation + runtime libraries.conscrypt } compileJava { @@ -53,9 +54,6 @@ def vmArgs = [ task qps_client(type: CreateStartScripts) { mainClassName = "io.grpc.benchmarks.qps.AsyncClient" applicationName = "qps_client" - defaultJvmOpts = [ - "-javaagent:" + configurations.alpnagent.asPath - ].plus(vmArgs) outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime } @@ -63,9 +61,6 @@ task qps_client(type: CreateStartScripts) { task openloop_client(type: CreateStartScripts) { mainClassName = "io.grpc.benchmarks.qps.OpenLoopClient" applicationName = "openloop_client" - defaultJvmOpts = [ - "-javaagent:" + configurations.alpnagent.asPath - ].plus(vmArgs) outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime } @@ -80,9 +75,6 @@ task qps_server(type: CreateStartScripts) { task benchmark_worker(type: CreateStartScripts) { mainClassName = "io.grpc.benchmarks.driver.LoadWorker" applicationName = "benchmark_worker" - defaultJvmOpts = [ - "-javaagent:" + configurations.alpnagent.asPath - ].plus(vmArgs) outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + project.configurations.runtime } diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java b/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java index 30968e53e9d0..f94284da8698 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/driver/LoadWorker.java @@ -24,6 +24,7 @@ import io.grpc.benchmarks.proto.Control.ServerArgs; import io.grpc.benchmarks.proto.Control.ServerArgs.ArgtypeCase; import io.grpc.benchmarks.proto.WorkerServiceGrpc; +import io.grpc.internal.testing.TestUtils; import io.grpc.netty.NettyServerBuilder; import io.grpc.stub.StreamObserver; import io.netty.channel.nio.NioEventLoopGroup; @@ -105,6 +106,10 @@ public static void main(String[] args) throws Exception { + "\n Port to start load servers on. Defaults to any available port"); System.exit(1); } + + // Let Netty or OkHttp use Conscrypt if it is available. + TestUtils.installConscryptIfAvailable(); + LoadWorker loadWorker = new LoadWorker(driverPort, serverPort); loadWorker.start(); loadWorker.driverServer.awaitTermination(); diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java index 413fe889c66d..5462ab838848 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncClient.java @@ -44,6 +44,7 @@ import io.grpc.benchmarks.proto.Messages.Payload; import io.grpc.benchmarks.proto.Messages.SimpleRequest; import io.grpc.benchmarks.proto.Messages.SimpleResponse; +import io.grpc.internal.testing.TestUtils; import io.grpc.stub.StreamObserver; import java.util.ArrayList; import java.util.List; @@ -303,6 +304,8 @@ private static void shutdown(List channels) { * checkstyle complains if there is no javadoc comment here. */ public static void main(String... args) throws Exception { + // Let Netty or OkHttp use Conscrypt if it is available. + TestUtils.installConscryptIfAvailable(); ClientConfiguration.Builder configBuilder = ClientConfiguration.newBuilder( ADDRESS, CHANNELS, OUTSTANDING_RPCS, CLIENT_PAYLOAD, SERVER_PAYLOAD, TLS, TESTCA, TRANSPORT, DURATION, WARMUP_DURATION, DIRECTEXECUTOR, diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java index d73ffdf96be3..9d90246d4cbf 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/AsyncServer.java @@ -54,6 +54,8 @@ public class AsyncServer { * checkstyle complains if there is no javadoc comment here. */ public static void main(String... args) throws Exception { + // Let Netty or OkHttp use Conscrypt if it is available. + TestUtils.installConscryptIfAvailable(); new AsyncServer().run(args); } diff --git a/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java b/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java index f366bc344ff2..a171a12f0329 100644 --- a/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java +++ b/benchmarks/src/main/java/io/grpc/benchmarks/qps/OpenLoopClient.java @@ -37,6 +37,7 @@ import io.grpc.benchmarks.proto.BenchmarkServiceGrpc; import io.grpc.benchmarks.proto.Messages.SimpleRequest; import io.grpc.benchmarks.proto.Messages.SimpleResponse; +import io.grpc.internal.testing.TestUtils; import io.grpc.stub.StreamObserver; import java.util.Random; import java.util.concurrent.Callable; @@ -63,6 +64,8 @@ public OpenLoopClient(ClientConfiguration config) { * Comment for checkstyle. */ public static void main(String... args) throws Exception { + // Let Netty or OkHttp use Conscrypt if it is available. + TestUtils.installConscryptIfAvailable(); ClientConfiguration.Builder configBuilder = ClientConfiguration.newBuilder( ADDRESS, TARGET_QPS, CLIENT_PAYLOAD, SERVER_PAYLOAD, TLS, TESTCA, TRANSPORT, DURATION, SAVE_HISTOGRAM, FLOW_CONTROL_WINDOW); diff --git a/build.gradle b/build.gradle index 2297beda02c5..de2a9d7ac3e6 100644 --- a/build.gradle +++ b/build.gradle @@ -244,10 +244,7 @@ subprojects { ] } - // Define a separate configuration for managing the dependency on Jetty ALPN agent. configurations { - alpnagent - compile { // Detect Maven Enforcer's dependencyConvergence failures. We only // care for artifacts used as libraries by others. @@ -267,9 +264,6 @@ subprojects { libraries.mockito, libraries.truth - // Configuration for modules that use Jetty ALPN agent - alpnagent libraries.jetty_alpn_agent - jmh 'org.openjdk.jmh:jmh-core:1.19', 'org.openjdk.jmh:jmh-generator-bytecode:1.19' } diff --git a/interop-testing/build.gradle b/interop-testing/build.gradle index e0f60ef1f331..1b4f4a79f975 100644 --- a/interop-testing/build.gradle +++ b/interop-testing/build.gradle @@ -32,7 +32,8 @@ dependencies { } compileOnly libraries.javax_annotation runtime libraries.opencensus_impl, - libraries.netty_tcnative + libraries.netty_tcnative, + libraries.conscrypt // for OkHttp testCompile project(':grpc-context').sourceSets.test.output } @@ -43,27 +44,14 @@ compileJava { it.options.compilerArgs += ["-Xep:BetaApi:OFF"] } -test { - // For the automated tests, use Jetty ALPN. - jvmArgs "-javaagent:" + configurations.alpnagent.asPath -} - // For the generated scripts, use Netty tcnative (i.e. OpenSSL). // Note that OkHttp currently only supports ALPN, so OpenSSL version >= 1.0.2 is required. task test_client(type: CreateStartScripts) { mainClassName = "io.grpc.testing.integration.TestServiceClient" applicationName = "test-client" - defaultJvmOpts = [ - "-javaagent:JAVAAGENT_APP_HOME" + configurations.alpnagent.singleFile.name - ] outputDir = new File(project.buildDir, 'tmp') classpath = jar.outputs.files + configurations.runtime - dependencies { runtime configurations.alpnagent } - doLast { - unixScript.text = unixScript.text.replace('JAVAAGENT_APP_HOME', '\$APP_HOME/lib/') - windowsScript.text = windowsScript.text.replace('JAVAAGENT_APP_HOME', '%APP_HOME%\\lib\\') - } } task test_server(type: CreateStartScripts) { diff --git a/netty/build.gradle b/netty/build.gradle index 82f5085e9db5..ebcb2f015acb 100644 --- a/netty/build.gradle +++ b/netty/build.gradle @@ -1,4 +1,9 @@ description = "gRPC: Netty" + +configurations { + alpnagent +} + dependencies { compile project(':grpc-core'), libraries.netty, @@ -11,6 +16,7 @@ dependencies { testRuntime libraries.netty_tcnative, libraries.conscrypt signature "org.codehaus.mojo.signature:java17:1.0@signature" + alpnagent libraries.jetty_alpn_agent } [compileJava, compileTestJava].each() {