Skip to content

Commit 4e07f74

Browse files
authored
Merge pull request #283 from rabbitmq/tcnative
Add --tls-tcnative option
2 parents c781e61 + 3e93c96 commit 4e07f74

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

pom.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<slf4j.version>2.0.17</slf4j.version>
5050
<logback.version>1.5.18</logback.version>
5151
<netty.version>4.2.3.Final</netty.version>
52+
<netty-tcnative.version>2.0.72.Final</netty-tcnative.version>
5253
<metrics.version>4.2.33</metrics.version>
5354
<micrometer.version>1.15.2</micrometer.version>
5455
<picocli.version>4.7.7</picocli.version>
@@ -154,6 +155,13 @@
154155
<classifier>linux-x86_64</classifier>
155156
</dependency>
156157

158+
<dependency>
159+
<groupId>io.netty</groupId>
160+
<artifactId>netty-tcnative-boringssl-static</artifactId>
161+
<version>${netty-tcnative.version}</version>
162+
<classifier>linux-x86_64</classifier>
163+
</dependency>
164+
157165
<dependency>
158166
<groupId>org.jgroups</groupId>
159167
<artifactId>jgroups</artifactId>
@@ -204,6 +212,14 @@
204212
<scope>provided</scope>
205213
</dependency>
206214

215+
<dependency>
216+
<groupId>io.netty</groupId>
217+
<artifactId>netty-tcnative-boringssl-static</artifactId>
218+
<version>${netty-tcnative.version}</version>
219+
<classifier>osx-aarch_64</classifier>
220+
<scope>test</scope>
221+
</dependency>
222+
207223
</dependencies>
208224

209225
<dependencyManagement>

src/main/java/com/rabbitmq/stream/perf/StreamPerfTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import io.netty.channel.uring.IoUringSocketChannel;
5555
import io.netty.handler.ssl.SslContextBuilder;
5656
import io.netty.handler.ssl.SslHandler;
57+
import io.netty.handler.ssl.SslProvider;
5758
import io.netty.util.internal.PlatformDependent;
5859
import java.io.IOException;
5960
import java.io.PrintStream;
@@ -512,6 +513,18 @@ void setNativeIoUring(String input) throws Exception {
512513

513514
volatile boolean nativeIoUring;
514515

516+
@CommandLine.Option(
517+
names = {"--tls-tcnative", "-ttc"},
518+
description = "use Netty's tcnative with BoringSSL (Linux x86-64 only)",
519+
arity = "0..1",
520+
fallbackValue = "true",
521+
defaultValue = "false")
522+
void setTlsTcNative(String input) throws Exception {
523+
this.tlsTcNative = Converters.BOOLEAN_TYPE_CONVERTER.convert(input);
524+
}
525+
526+
volatile boolean tlsTcNative;
527+
515528
@ArgGroup(exclusive = false, multiplicity = "0..1")
516529
InstanceSyncOptions instanceSyncOptions;
517530

@@ -1003,10 +1016,12 @@ public Integer call() throws Exception {
10031016
java.util.function.Consumer<io.netty.channel.Channel> channelCustomizer = channel -> {};
10041017

10051018
if (tls) {
1019+
SslProvider sslProvider = this.tlsTcNative ? SslProvider.OPENSSL : SslProvider.JDK;
10061020
TlsConfiguration tlsConfiguration = environmentBuilder.tls();
10071021
tlsConfiguration =
10081022
tlsConfiguration.sslContext(
10091023
SslContextBuilder.forClient()
1024+
.sslProvider(sslProvider)
10101025
.trustManager(Utils.TRUST_EVERYTHING_TRUST_MANAGER)
10111026
.build());
10121027
environmentBuilder = tlsConfiguration.environmentBuilder();

src/test/java/com/rabbitmq/stream/perf/Host.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static Process rabbitmqctl(String command) throws IOException {
9494
}
9595

9696
static String rabbitmqctlCommand() {
97-
String rabbitmqCtl = System.getProperty("rabbitmqctl.bin", DOCKER_PREFIX);
97+
String rabbitmqCtl = System.getProperty("rabbitmqctl.bin", DOCKER_PREFIX + "rabbitmq");
9898
if (rabbitmqCtl.startsWith(DOCKER_PREFIX)) {
9999
String containerId = rabbitmqCtl.split(":")[1];
100100
return "docker exec " + containerId + " rabbitmqctl";

src/test/java/com/rabbitmq/stream/perf/StreamPerfTestTest.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
import org.junit.jupiter.api.extension.ExtendWith;
7171
import org.junit.jupiter.params.ParameterizedTest;
7272
import org.junit.jupiter.params.provider.CsvSource;
73+
import org.junit.jupiter.params.provider.ValueSource;
7374

7475
@ExtendWith(TestUtils.StreamTestInfrastructureExtension.class)
7576
public class StreamPerfTestTest {
@@ -285,12 +286,14 @@ void publishingSequenceShouldNotBeStoredWhenProducerNamesAreNotSet() throws Exce
285286
waitRunEnds();
286287
}
287288

288-
@Test
289+
@ParameterizedTest
290+
@ValueSource(booleans = {true, false})
289291
@DisabledIfTlsNotEnabled
290-
void shouldConnectWithTls() throws Exception {
292+
void shouldConnectWithTls(boolean tlsTcNative) throws Exception {
293+
ArgumentsBuilder builder = builder().tlsTcNative(tlsTcNative);
291294
Future<?> run =
292295
run(
293-
builder()
296+
builder
294297
.uris("rabbitmq-stream+tls://guest:guest@localhost:5551/%2f")
295298
.serverNameIndication("localhost"));
296299
waitUntilStreamExists(s);
@@ -641,6 +644,11 @@ ArgumentsBuilder uris(String url) {
641644
return this;
642645
}
643646

647+
public ArgumentsBuilder tlsTcNative(boolean tlsTcNative) {
648+
arguments.put("tls-tcnative", String.valueOf(tlsTcNative));
649+
return this;
650+
}
651+
644652
ArgumentsBuilder serverNameIndication(String sni) {
645653
arguments.put("server-name-indication", sni);
646654
return this;

0 commit comments

Comments
 (0)