英文:
Postgres Test Containers stopped working on GitHub Actions
问题
我正在使用Postgres Test Container模块为Go中的API编写数据库集成测试。此外,我还在CI的一部分中使用GitHub Actions来运行这些测试。
测试代码:
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)
}
...
// 通过连接字符串获取上述容器的连接池。
// 在测试中使用连接池。
这个设置在大约一周前还能正常工作。我对结果感到非常满意,并且对将所有内容整合在一起感到自豪。
然而,直到今天早上,CI突然开始失败了。
现在,我只能看到以下错误信息:
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上失败了。
英文:
I'm using the Postgres Test Container module for writing DB integration tests for an API in Go. Also, I'm using GitHub Actions as part of CI to run these tests.
Test code:
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.
The setup used to work fine for about a week.
I was quite happy with the results, and smug about putting it all together.
That is, until this morning when the CI started failing out of the blue.
Now, all I have are the following errors:
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
Any clues on what could have caused this and/or suggestions on how to go about debugging this.
Please note: The same tests still work locally on my macOSX machine. They just fail on GitHub Actions runner.
答案1
得分: 1
这个问题似乎与Go版本1.20.6发布有关。
在测试中将Go版本固定为1.20.5可以绕过这个问题。
这是一个报告类似行为的GitHub问题链接:https://github.com/moby/moby/issues/45935
英文:
This issue seems to be related to the Go version 1.20.6 release.
Pinning the Go version to 1.20.5 in the tests circumvented the issue so far.
Here is a link to GitHub issue that reports similar behavior: https://github.com/moby/moby/issues/45935
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论