构建后的单元测试期间 Jenkins 无法连接到数据库

发布于 2024-12-20 02:14:15 字数 300 浏览 1 评论 0原文

我正在将我的 ant 构建移动到新的 Jenkins 服务器。它可以访问 SVN、编译等等。一切都很好,直到开始运行单元测试。一些测试需要访问数据库才能执行。

我已经登录到运行 Jenkins 的服务器,并通过在数据库端口上使用 telnet,我可以知道该路径是开放的。 (IT 人员也说道路是开放的)。我知道这是一个数据库问题,因为当我弄乱配置文件时,我可以在本地重现该问题,因此构建无法找到数据库。

我的问题是这样的。我真的需要詹金斯告诉我为什么它无法连接到数据库。我一直不知道该怎么做。控制台输出只是显示它永远尝试测试。任何和所有建议都将受到赞赏。

I'm moving my ant build to a new Jenkins server. It can access SVN, compile and all that. Everything is great until it starts running unit tests. A few of the tests need access to a database to be able to execute.

I've logged into the server that Jenkins runs from, and by using telnet on the database port, I can tell that the path is open. (The IT guys also say the path is open). I know it's a database issue because I can reproduce the issue locally when I mess up the config file so the build cannot find the database.

My problem is this. I really need Jenkins to tell me why it can't connect to the database. I have not been able to figure out how to do this. The console output simply shows it trying the test forever. Any and all suggestions are appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

地狱即天堂 2024-12-27 02:14:15

您是否将 DB 参数从 Ant 传递到 junit 目标?如果是这样,请将 -v 参数添加到 jenkins 配置中的 ant 构建步骤中以获取额外的日志记录和信息。因此请查看正在设置哪些数据库参数。

或者,您的测试是否自行加载数据库参数?根据它们的读取方式,您可能会遇到类路径或路径问题。在这种情况下,记录测试中的路径、类路径和任何其他相关变量。

请记住,junit 任务有一个 timeout 参数,如果您不希望它永远挂起,您可以设置它。

最后,您可以登录 jenkins 主机并从执行测试触发线程转储。这是通过向 java 进程(在 *nix 上)发送 kill -3 信号来完成的,或者,如果您在 Windows 上运行 jenkins 并且您的 JVM 不太旧,您可以执行 jstack。生成的堆栈跟踪(应该出现在 Jenkins 构建日志中)可能会带来一些见解。

Do you pass the DB parameters from Ant to the junit target? If so, add the -v parameter to the ant build step in your jenkins config to get extra logging & therefore see what DB parameters are being set.

Alternatively, do your tests load the DB parameters themselves? Depending on how they are read, you may have a classpath or path issue. In this case, log the path, classpath and any other relevant variables in your test.

Keep in mind that the junit task has a timeout parameter you can set if you don't want it to hang forever.

Finally, you can log onto the jenkins host and trigger a thread dump from the executing test. This is done by sending a kill -3 signal to the java process (on *nix) or, if you are running jenkins on windows and your JVM is not too old you can execute jstack. The resulting stack trace (which should appear in the Jenkins build log) may lead to some insight.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文