Skip to content

Commit

Permalink
Using OpenSSL for testing instead of alpn-boot jar
Browse files Browse the repository at this point in the history
See https://github.com/grpc/grpc-java/blob/master/SECURITY.md for more details
See grpc/grpc-java@a99e977 for a change related to the grpc testing envrionment

We need to set up our testing environment with OpenSSL 1.0.2 before checking this in

Adding logging about the provider type.
  • Loading branch information
sduskis committed Oct 12, 2015
1 parent 995ea41 commit 22f3ab3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
import io.grpc.netty.NettyChannelBuilder;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.handler.ssl.OpenSsl;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;
import io.netty.handler.ssl.SslProvider;

import java.io.BufferedWriter;
import java.io.Closeable;
Expand Down Expand Up @@ -120,21 +122,16 @@ public class BigtableSession implements AutoCloseable {
performWarmup();
}

private static SslContextBuilder createGrpcSslBuilder() {
SslContextBuilder sslBuilder = GrpcSslContexts.forClient();
sslBuilder.ciphers(null);
return sslBuilder;
}

private static synchronized SslContextBuilder getSslBuilder() {
private synchronized static SslContext createSslContext() throws SSLException {
if (sslBuilder == null) {
sslBuilder = createGrpcSslBuilder();
sslBuilder = GrpcSslContexts.forClient().ciphers(null);
if (OpenSsl.isAvailable()) {
LOG.info("gRPC is using the OpenSSL provider");
} else {
LOG.info("gRPC is using the JDK provder");
}
}
return sslBuilder;
}

private static SslContext createSslContext() throws SSLException {
return getSslBuilder().build();
return sslBuilder.build();
}

private static void performWarmup() {
Expand All @@ -146,13 +143,6 @@ public void run() {
// The first invocation of createSslContext() is expensive.
// Create a throw away object in order to speed up the creation of the first
// BigtableConnection which uses SslContexts under the covers.
try {
Class.forName("org.eclipse.jetty.alpn.ALPN");
} catch (ClassNotFoundException e1) {
LOG.warn(
"Could not asynchronously create the ssl context, since ALPN is not installed.");
return;
}
try {
// We create multiple channels via refreshing and pooling channel implementation.
// Each one needs its own SslContext.
Expand Down
20 changes: 12 additions & 8 deletions bigtable-hbase-integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ limitations under the License.
<!-- to enable netty logging, include:
-Djava.util.logging.config.file=src/test/resources/logging.properties
-->
<argLine>
-Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn.version}/alpn-boot-${alpn.version}.jar
</argLine>
<forkCount>1</forkCount>
<includes>
<include>**/IntegrationTestsNoKnownGap.java</include>
Expand Down Expand Up @@ -123,9 +120,6 @@ limitations under the License.
<!-- to enable netty logging, include:
-Djava.util.logging.config.file=src/test/resources/logging.properties
-->
<argLine>
-Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn.version}/alpn-boot-${alpn.version}.jar
</argLine>
<forkCount>1</forkCount>
<includes>
<include>**/IntegrationTestsGap.java</include>
Expand Down Expand Up @@ -249,11 +243,21 @@ limitations under the License.
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>1.1.33.Fork9</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>
</dependencies>
<build>
<extensions>
<!-- Use os-maven-plugin to initialize the "os.detected" properties -->
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.1.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
23 changes: 16 additions & 7 deletions bigtable-hbase/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ limitations under the License.
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
</dependency>

<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>1.1.33.Fork9</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -72,12 +80,16 @@ limitations under the License.
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
</dependency>
</dependencies>
<build>
<extensions>
<!-- Use os-maven-plugin to initialize the "os.detected" properties -->
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.4.1.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -106,9 +118,6 @@ limitations under the License.
<!-- to enable netty logging, include:
-Djava.util.logging.config.file=src/test/resources/logging.properties
-->
<argLine>
-Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/alpn/alpn-boot/${alpn.version}/alpn-boot-${alpn.version}.jar
</argLine>
<!-- protobuf and netty are included in the grpc-interface jar -->
<forkCount>1</forkCount>
<includes>
Expand Down

0 comments on commit 22f3ab3

Please sign in to comment.