Skip to content

Commit a347454

Browse files
authoredSep 22, 2023
Shut down lettuce RedisClient (#9537)
1 parent 0dfbd78 commit a347454

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎instrumentation/lettuce/lettuce-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceAsyncClientTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ static void setUp() {
103103
syncCommands.set("TESTKEY", "TESTVAL");
104104

105105
// 1 set + 1 connect trace
106+
testing.waitForTraces(2);
106107
testing.clearData();
107108
}
108109

109110
@AfterAll
110111
static void cleanUp() {
111112
connection.close();
113+
redisClient.shutdown();
112114
redisServer.stop();
113115
}
114116

@@ -121,6 +123,7 @@ void testConnectUsingGetOnConnectionFuture() {
121123
testConnectionClient.connect(
122124
new Utf8StringCodec(), new RedisURI(host, port, 3, TimeUnit.SECONDS));
123125
cleanup.deferCleanup(connection1);
126+
cleanup.deferCleanup(testConnectionClient::shutdown);
124127

125128
assertThat(connection1).isNotNull();
126129

@@ -140,6 +143,7 @@ void testConnectUsingGetOnConnectionFuture() {
140143
void testExceptionInsideTheConnectionFuture() {
141144
RedisClient testConnectionClient = RedisClient.create(dbUriNonExistent);
142145
testConnectionClient.setOptions(CLIENT_OPTIONS);
146+
cleanup.deferCleanup(testConnectionClient::shutdown);
143147

144148
Exception exception =
145149
catchException(
@@ -460,11 +464,14 @@ void testDebugSegfaultCommandWithNoArgumentShouldProduceSpan() {
460464

461465
long serverPort = server.getMappedPort(6379);
462466
RedisClient client = RedisClient.create("redis://" + host + ":" + serverPort + "/" + DB_INDEX);
467+
client.setOptions(CLIENT_OPTIONS);
463468
StatefulRedisConnection<String, String> connection1 = client.connect();
464469
cleanup.deferCleanup(connection1);
470+
cleanup.deferCleanup(client::shutdown);
465471

466472
RedisAsyncCommands<String, String> commands = connection1.async();
467473
// 1 connect trace
474+
testing.waitForTraces(1);
468475
testing.clearData();
469476

470477
commands.debugSegfault();
@@ -491,11 +498,14 @@ void testShutdownCommandShouldProduceSpan() {
491498

492499
RedisClient client =
493500
RedisClient.create("redis://" + host + ":" + shutdownServerPort + "/" + DB_INDEX);
501+
client.setOptions(CLIENT_OPTIONS);
494502
StatefulRedisConnection<String, String> connection1 = client.connect();
495503
cleanup.deferCleanup(connection1);
504+
cleanup.deferCleanup(client::shutdown);
496505

497506
RedisAsyncCommands<String, String> commands = connection1.async();
498507
// 1 connect trace
508+
testing.waitForTraces(1);
499509
testing.clearData();
500510

501511
commands.shutdown(false);

‎instrumentation/lettuce/lettuce-4.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/lettuce/v4_0/LettuceSyncClientTest.java

+9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static void setUp() {
9292
@AfterAll
9393
static void cleanUp() {
9494
connection.close();
95+
redisClient.shutdown();
9596
redisServer.stop();
9697
}
9798

@@ -102,6 +103,7 @@ void testConnect() {
102103

103104
StatefulRedisConnection<String, String> testConnection = testConnectionClient.connect();
104105
cleanup.deferCleanup(() -> testConnection.close());
106+
cleanup.deferCleanup(testConnectionClient::shutdown);
105107

106108
testing.waitAndAssertTraces(
107109
trace ->
@@ -119,6 +121,7 @@ void testConnect() {
119121
void testConnectException() {
120122
RedisClient testConnectionClient = RedisClient.create(dbUriNonExistent);
121123
testConnectionClient.setOptions(CLIENT_OPTIONS);
124+
cleanup.deferCleanup(testConnectionClient::shutdown);
122125

123126
Exception exception = catchException(testConnectionClient::connect);
124127

@@ -258,11 +261,14 @@ void testDebugSegfaultCommandWithNoArgumentShouldProduceSpan() {
258261

259262
long serverPort = server.getMappedPort(6379);
260263
RedisClient client = RedisClient.create("redis://" + host + ":" + serverPort + "/" + DB_INDEX);
264+
client.setOptions(CLIENT_OPTIONS);
261265
StatefulRedisConnection<String, String> connection1 = client.connect();
262266
cleanup.deferCleanup(connection1);
267+
cleanup.deferCleanup(client::shutdown);
263268

264269
RedisCommands<String, String> commands = connection1.sync();
265270
// 1 connect trace
271+
testing.waitForTraces(1);
266272
testing.clearData();
267273

268274
commands.debugSegfault();
@@ -289,11 +295,14 @@ void testShutdownCommandShouldProduceSpan() {
289295

290296
RedisClient client =
291297
RedisClient.create("redis://" + host + ":" + shutdownServerPort + "/" + DB_INDEX);
298+
client.setOptions(CLIENT_OPTIONS);
292299
StatefulRedisConnection<String, String> connection1 = client.connect();
293300
cleanup.deferCleanup(connection1);
301+
cleanup.deferCleanup(client::shutdown);
294302

295303
RedisCommands<String, String> commands = connection1.sync();
296304
// 1 connect trace
305+
testing.waitForTraces(1);
297306
testing.clearData();
298307

299308
commands.shutdown(false);

0 commit comments

Comments
 (0)
Please sign in to comment.