testcontainers / testcontainers/testcontainers-java
[Bug]: Error in running test on kube-jenkins
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
Module
PostgreSQL
Testcontainers version
1.16.3
Using the latest Testcontainers version?
Yes
Host OS
linux
Host Arch
x86
Docker version
Container Runtime Version: docker://20.10.7
What happened?
I am using testcontainers for my unit test for repository, it passes locally but failed in the jenkins, and it only have one line log trace:
EntityRepositoryTest > initializationError FAILED
com.github.dockerjava.api.exception.InternalServerErrorException at DefaultInvocationBuilder.java:247
Here are my code, I retaged and pushed postgres:13.2 to company's private jfrog
public class MyRepositoryPostgresqlContainer extends PostgreSQLContainer<MyRepositoryPostgresqlContainer> {
static private DockerImageName myImage = DockerImageName.parse("comany./postgres:13.2").asCompatibleSubstituteFor("postgres");
private static MyRepositoryPostgresqlContainer container;
private MyRepositoryPostgresqlContainer(DockerImageName myImage) {
super(myImage);
}
public static MyRepositoryPostgresqlContainer getInstance() {
if (container == null) {
container = new MyRepositoryPostgresqlContainer(myImage)
.withDatabaseName("XXX")
.withUsername("XXX")
.withPassword("XXX);
}
return container;
}
...
}
@ContextConfiguration(initializers = {MyTest.Initializer.class})
public class MyTest {
@ClassRule
public static PostgreSQLContainer postgreSQLContainer = MyRepositoryPostgresqlContainer.getInstance();
static class Initializer
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
TestPropertyValues.of(
"spring.datasource.url=" + postgreSQLContainer.getJdbcUrl(),
"spring.datasource.username=" + postgreSQLContainer.getUsername(),
"spring.datasource.password=" + postgreSQLContainer.getPassword()
).applyTo(configurableApplicationContext.getEnvironment());
}
}
}
@SpringBootTest
@RunWith(SpringRunner.class)
public class EntityRepositoryTest extends MyTest{
@Autowired
private MyRepository repo;
@Test
public void test() {
MyEntity myEntity = MyEntity.builder().
....
.build();
repo.saveAndFlush(myEntity);
assertEquals(1, repo.findAll().size());
}
}
Any suggestion helps, Thanks
Relevant log output
EntityRepositoryTest > initializationError FAILED
com.github.dockerjava.api.exception.InternalServerErrorException at DefaultInvocationBuilder.java:247
### Additional Information
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with EntityRepositoryTest and MyRepositoryPostgresqlContainer, then reproduce the failure on the kube-jenkins environment using the reported Docker and PostgreSQL image setup. Collect the complete Docker and Jenkins logs beyond the single InternalServerErrorException line and compare them with a successful local run. Done means identifying the environment-specific cause and documenting or implementing a verified resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java, postgresql
- Domain
- ci-cd, databases, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100