Optimize Redis integration tests

This commit ensures that Redis Testcontainers used for integration testing are managed by Spring to ensure proper ordering on shutdown.

Previously, Redis Testcontainer was closed before LettuceConnectionFactory which caused pending commands to hang and added a lot of wait to project build.

Closes gh-1086
This commit is contained in:
Vedran Pavic
2018-06-01 11:50:01 +02:00
parent f55b793185
commit 63f105082a
13 changed files with 159 additions and 228 deletions

View File

@@ -28,11 +28,14 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
@Profile("embedded-redis")
public class EmbeddedRedisConfig {
private static final String REDIS_DOCKER_IMAGE = "redis:4.0.9";
private static final String DOCKER_IMAGE = "redis:4.0.9";
@Bean(initMethod = "start")
@Bean
public GenericContainer redisContainer() {
return new GenericContainer(REDIS_DOCKER_IMAGE).withExposedPorts(6379);
GenericContainer redisContainer = new GenericContainer(DOCKER_IMAGE)
.withExposedPorts(6379);
redisContainer.start();
return redisContainer;
}
@Bean