Вот моя базовая тестовая конфигурация:
Java
Код: Выделить всё
@ContextConfiguration(initializers = AbstractIntegrationTest.Initializer.class)
public class AbstractIntegrationTest {
static class Initializer implements ApplicationContextInitializer {
static PostgreSQLContainer postgresSQL = new PostgreSQLContainer("postgres:18");
private static void startContainers() {
Startables.deepStart(Stream.of(postgresSQL)).join();
}
private static Map createConnectionConfiguration() {
return Map.of(
"spring.datasource.url", postgresSQL.getJdbcUrl(),
"spring.datasource.username", postgresSQL.getUsername(),
"spring.datasource.password", postgresSQL.getPassword()
);
}
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
startContainers();
ConfigurableEnvironment environment = applicationContext.getEnvironment();
MapPropertySource testcontainers = new MapPropertySource("testcontainers",
(Map) createConnectionConfiguration());
environment.getPropertySources().addFirst(testcontainers);
}
}
}
Открытый текст
Код: Выделить всё
java.lang.IllegalStateException: Could not find a valid Docker environment. Please check configuration. Attempted configurations were:
EnvironmentAndSystemPropertyClientProviderStrategy: failed with exception BadRequestException (Status 400: {"ID":"","Containers":0...})
NpipeSocketClientProviderStrategy: failed with exception BadRequestException (Status 400: ...)
Код: Выделить всё
TESTCONTAINERS_RYUK_DISABLED=trueПодробнее здесь: https://stackoverflow.com/questions/798 ... -11-status
Мобильная версия