Skip to content

Commit

Permalink
Rework shutdown in lettuce 5.0 tests (#12927)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Dec 19, 2024
1 parent a84ade1 commit f612bf8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension;
import io.opentelemetry.instrumentation.testing.junit.AgentInstrumentationExtension;
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -78,4 +79,16 @@ protected static StatefulRedisConnection<String, String> newContainerConnection(

return statefulConnection;
}

static void shutdown(RedisClient redisClient) {
// using shutdownAsync instead of redisClient.shutdown() because there is a bug in the redis
// client that can cause the shutdown to hang
try {
redisClient.shutdownAsync(0, 15, TimeUnit.SECONDS).get(15, TimeUnit.SECONDS);
} catch (InterruptedException exception) {
Thread.currentThread().interrupt();
} catch (Exception exception) {
// ignore
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void setUp() throws UnknownHostException {
@AfterAll
static void cleanUp() {
connection.close();
redisClient.shutdown();
shutdown(redisClient);
redisServer.stop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void setUp() throws UnknownHostException {
@AfterAll
static void cleanUp() {
connection.close();
redisClient.shutdown();
shutdown(redisClient);
redisServer.stop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static void setUp() throws UnknownHostException {
@AfterAll
static void cleanUp() {
connection.close();
redisClient.shutdown();
shutdown(redisClient);
redisServer.stop();
}

Expand Down

0 comments on commit f612bf8

Please sign in to comment.