TestContainers Oracle 超时异常
TestContainers Oracle TimeoutException
我尝试使用 testcontainers 库与 Oracle 进行集成测试。这是简单的测试:
public class SimpleTest {
@Rule
public OracleContainer oracle = new OracleContainer();
@Test
public void simpleTest() throws SQLException {
HikariDataSource ds = buildHikariDataSource();
Statement statement = ds.getConnection().createStatement();
statement.execute("SELECT 1 FROM dual");
ResultSet resultSet = statement.getResultSet();
resultSet.next();
int resultSetInt = resultSet.getInt(1);
assertEquals("A basic SELECT query succeeds", 1, resultSetInt);
}
private HikariDataSource buildHikariDataSource() {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(oracle.getJdbcUrl());
hikariConfig.setUsername(oracle.getUsername());
hikariConfig.setPassword(oracle.getPassword());
return new HikariDataSource(hikariConfig);
}
}
But it fails with TimeoutException:
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:256)
at org.testcontainers.containers.GenericContainer.lambda$start[=10=](GenericContainer.java:184)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
... 18 more
Caused by: org.rnorth.ducttape.TimeoutException: org.rnorth.ducttape.TimeoutException: java.util.concurrent.TimeoutException
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:53)
at org.testcontainers.containers.JdbcDatabaseContainer.waitUntilContainerStarted(JdbcDatabaseContainer.java:81)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:235)
... 20 more
我的 Docker 安装适用于 testcontainers-oracle-xe 并且 os 是 macOS Sierra 10.12.6。
如何解决这个问题?
P.S。 Full console output
总而言之,我在 testcontainers-java-module-oracle-xe 存储库中创建了一个 issue。
解决方案是在“系统偏好设置”中将位置更改为美国并将语言更改为英语。
测试容器工程师的回答:
My colleague have faced the same problem. We have debugged and
understood that problem with oracle TNS (ORA-12514). In order to
resolve it, there is a need to change language to English and location
to US.
我尝试使用 testcontainers 库与 Oracle 进行集成测试。这是简单的测试:
public class SimpleTest {
@Rule
public OracleContainer oracle = new OracleContainer();
@Test
public void simpleTest() throws SQLException {
HikariDataSource ds = buildHikariDataSource();
Statement statement = ds.getConnection().createStatement();
statement.execute("SELECT 1 FROM dual");
ResultSet resultSet = statement.getResultSet();
resultSet.next();
int resultSetInt = resultSet.getInt(1);
assertEquals("A basic SELECT query succeeds", 1, resultSetInt);
}
private HikariDataSource buildHikariDataSource() {
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl(oracle.getJdbcUrl());
hikariConfig.setUsername(oracle.getUsername());
hikariConfig.setPassword(oracle.getPassword());
return new HikariDataSource(hikariConfig);
}
}
But it fails with TimeoutException:
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:256)
at org.testcontainers.containers.GenericContainer.lambda$start[=10=](GenericContainer.java:184)
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:76)
... 18 more
Caused by: org.rnorth.ducttape.TimeoutException: org.rnorth.ducttape.TimeoutException: java.util.concurrent.TimeoutException
at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:53)
at org.testcontainers.containers.JdbcDatabaseContainer.waitUntilContainerStarted(JdbcDatabaseContainer.java:81)
at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:235)
... 20 more
我的 Docker 安装适用于 testcontainers-oracle-xe 并且 os 是 macOS Sierra 10.12.6。
如何解决这个问题?
P.S。 Full console output
总而言之,我在 testcontainers-java-module-oracle-xe 存储库中创建了一个 issue。
解决方案是在“系统偏好设置”中将位置更改为美国并将语言更改为英语。
测试容器工程师的回答:
My colleague have faced the same problem. We have debugged and understood that problem with oracle TNS (ORA-12514). In order to resolve it, there is a need to change language to English and location to US.