testcontainers / testcontainers/testcontainers-java

[Bug]: Error in running test on kube-jenkins

Open
#5,602 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

resolution/waiting-for-info type/bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.