Protect autoconfigure module against slow starting test containers

pull/18095/head
Andy Wilkinson 5 years ago
parent 3a417eec52
commit 20b6656ba7

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.data.cassandra;
import java.time.Duration;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session;
import org.junit.jupiter.api.AfterEach;
@ -45,7 +47,8 @@ import static org.assertj.core.api.Assertions.assertThat;
class CassandraDataAutoConfigurationIntegrationTests {
@Container
static final CassandraContainer<?> cassandra = new CassandraContainer<>();
static final CassandraContainer<?> cassandra = new CassandraContainer<>().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private AnnotationConfigApplicationContext context;

@ -15,6 +15,7 @@
*/
package org.springframework.boot.autoconfigure.data.elasticsearch;
import java.time.Duration;
import java.util.List;
import org.elasticsearch.client.Client;
@ -46,7 +47,8 @@ import static org.mockito.Mockito.mock;
class ElasticsearchAutoConfigurationTests {
@Container
public static ElasticsearchContainer elasticsearch = new ElasticsearchContainer();
public static ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private AnnotationConfigApplicationContext context;

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.data.elasticsearch;
import java.time.Duration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -51,7 +53,8 @@ import static org.mockito.Mockito.mock;
class ElasticsearchDataAutoConfigurationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer();
static ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner().withConfiguration(
AutoConfigurations.of(ElasticsearchAutoConfiguration.class, RestClientAutoConfiguration.class,

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.data.elasticsearch;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.testcontainers.elasticsearch.ElasticsearchContainer;
import org.testcontainers.junit.jupiter.Container;
@ -46,7 +48,8 @@ import static org.assertj.core.api.Assertions.assertThat;
class ElasticsearchRepositoriesAutoConfigurationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer();
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.data.elasticsearch;
import java.time.Duration;
import org.junit.jupiter.api.Test;
import org.testcontainers.elasticsearch.ElasticsearchContainer;
import org.testcontainers.junit.jupiter.Container;
@ -45,7 +47,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ReactiveElasticsearchRepositoriesAutoConfigurationTests {
@Container
static ElasticsearchContainer elasticsearch = new ElasticsearchContainer();
static ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ReactiveRestClientAutoConfiguration.class,

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.data.elasticsearch;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
@ -46,7 +47,8 @@ import static org.mockito.Mockito.mock;
public class ReactiveRestClientAutoConfigurationTests {
@Container
static ElasticsearchContainer elasticsearch = new ElasticsearchContainer();
static ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ReactiveRestClientAutoConfiguration.class));

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.data.redis;
import java.time.Duration;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@ -45,7 +47,8 @@ import static org.assertj.core.api.Assertions.assertThat;
class RedisRepositoriesAutoConfigurationTests {
@Container
public static RedisContainer redis = new RedisContainer();
public static RedisContainer redis = new RedisContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();

@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.elasticsearch.jest;
import java.io.IOException;
import java.time.Duration;
import java.util.HashMap;
import java.util.Map;
@ -54,7 +55,8 @@ import static org.mockito.Mockito.mock;
class JestAutoConfigurationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer();
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(GsonAutoConfiguration.class, JestAutoConfiguration.class));

@ -50,7 +50,8 @@ import static org.mockito.Mockito.mock;
class RestClientAutoConfigurationTests {
@Container
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer();
static final ElasticsearchContainer elasticsearch = new ElasticsearchContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
private ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(RestClientAutoConfiguration.class));

@ -16,6 +16,7 @@
package org.springframework.boot.autoconfigure.session;
import java.time.Duration;
import java.util.Map;
import org.junit.jupiter.api.Test;
@ -54,7 +55,8 @@ import static org.assertj.core.api.Assertions.entry;
class SessionAutoConfigurationRedisTests extends AbstractSessionAutoConfigurationTests {
@Container
public static RedisContainer redis = new RedisContainer();
public static RedisContainer redis = new RedisContainer().withStartupAttempts(5)
.withStartupTimeout(Duration.ofMinutes(2));
protected final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(SessionAutoConfiguration.class));

Loading…
Cancel
Save