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

未关闭
#5,602 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
docker, java, postgresql

调研方向

从 EntityRepositoryTest 和 MyRepositoryPostgresqlContainer 开始,然后使用报告中的 Docker 和 PostgreSQL 镜像配置在 kube-jenkins 环境中重现失败。收集完整的 Docker 和 Jenkins 日志,不要只收集单独的 InternalServerErrorException 行,并将其与一次成功的本地运行进行比较。完成的标准是确定特定于环境的原因,并记录或实现经过验证的解决方案。

由索引模型根据 Issue 内容生成。

描述

resolution/waiting-for-info type/bug
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_
主要语言
Java
星标
8.7k
派生
1.9k
平均合并
2 天 17 小时
30 天内合并 PR
9

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

testcontainers/testcontainers-java 的其他 Issue

查看 testcontainers/testcontainers-java 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。