Go语言 Postgres测试容器停止在GitHub上运行

hs1rzwqc  于 12个月前  发布在  Go
关注(0)|答案(1)|浏览(65)

我正在使用Postgres测试容器模块为Go中的API编写数据库集成测试。此外,我使用GitHub Actions作为CI的一部分来运行这些测试。
测试代码:

pgContainer, err := postgres.RunContainer(ctx,
            testcontainers.WithImage("postgres:14-alpine"),
            postgres.WithDatabase("db"),
            postgres.WithUsername("user"),
            postgres.WithPassword("secret"),
            testcontainers.WithWaitStrategy(
                wait.ForLog("database system is ready to accept connections").
                    WithOccurrence(2).WithStartupTimeout(5*time.Second)),
        )
        if err != nil {
            t.Fatal(err)
        }
        ...
        // get a connection pool for the above container via the connection string.
        // use the connection pool in the tests.

字符串
设置过去工作正常大约一个星期。我对结果相当满意,并为把这一切放在一起而沾沾自喜。
直到今天早上线人突然失败。现在,我所拥有的是以下错误:

2023/07/12 13:59:56 github.com/testcontainers/testcontainers-go - Connected to docker: 
  Server Version: 20.10.25+azure-2
  API Version: 1.41
  Operating System: Ubuntu 22.04.2 LTS
  Total Memory: 6931 MB
2023/07/12 13:59:57 Failed to get image auth for docker.io. Setting empty credentials for the image: docker.io/testcontainers/ryuk:0.5.1. Error is:credentials not found in native keychain
2023/07/12 13:59:59 🐳 Creating container for image docker.io/testcontainers/ryuk:0.5.1
2023/07/12 13:59:59 ✅ Container created: 85df4c97985a
2023/07/12 13:59:59 🐳 Starting container: 85df4c97985a
2023/07/12 14:00:00 ✅ Container started: 85df4c97985a
2023/07/12 14:00:00 🚧 Waiting for container id 85df4c97985a image: docker.io/testcontainers/ryuk:0.5.1. Waiting for: &{Port:8080/tcp timeout:<nil> PollInterval:100ms}
2023/07/12 14:00:00 container logs:
2023/07/12 14:00:00 Pinging Docker...
2023/07/12 14:00:00 Docker daemon is available!
2023/07/12 14:00:00 Starting on port 8080...
2023/07/12 14:00:00 Started!
2023/07/12 14:00:00 New client connected: 172.17.0.1:35910
2023/07/12 14:00:00 EOF
2023/07/12 14:00:00 Client disconnected: 172.17.0.1:35910


任何线索,什么可能导致这一点和/或建议,如何去调试这一点。
请注意:同样的测试仍然在我的macOSX机器上本地工作。他们只是在GitHub Actions runner上失败。

4nkexdtk

4nkexdtk1#

这个问题似乎与Go 1.20.6版本有关。
到目前为止,在测试中将Go版本固定到1.20.5规避了这个问题。
以下是报告类似行为的GitHub问题的链接:https://github.com/moby/moby/issues/45935

相关问题