Grails 测试应用程序在 CI 服务器上失败,但在开发人员计算机上失败

发布于 2024-11-08 04:05:31 字数 3099 浏览 0 评论 0原文

我有两台机器,一台持续集成服务器和一台开发人员机器。

两台机器都运行相同版本的 java、maven 和 grails,并且都运行 Ubuntu。 我能想到的唯一区别是 CI 处于虚拟化环境中。

一些证明:

CI java -version

java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) 

DEV java -version

java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) 

CI mvn -version

Apache Maven 2.2.1 (rdebian-1)
Java version: 1.6.0_24
Java home: /usr/lib/jvm/java-6-sun-1.6.0.24/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-31-server" arch: "amd64" Family: "unix" 

DEV mvn -version

Apache Maven 2.2.1 (rdebian-1)
Java version: 1.6.0_24
Java home: /usr/lib/jvm/java-6-sun-1.6.0.24/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-31-generic" arch: "amd64" Family: "unix" 

CI grails

Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/local/lib/grails-1.3.7 

DEV grails

Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /home/netbrain/dev/apps/grails-1.3.7 

我从两台机器上的版本控制中进行了彻底的检查,并删除了文件夹 ~/.m2~/.ivy2< /code> 以避免任何不一致之处。

当我在 CI 服务器上运行 grails test-app 时,6 个测试似乎失败了。当它们在我的 DEV 系统上时都在相同的情况下通过。

CI grails test-app

Tests Completed in 28213ms ...
-------------------------------------------------------
Tests passed: 14
Tests failed: 6
------------------------------------------------------- 

DEV grails test-app

Tests Completed in 25889ms ...
-------------------------------------------------------
Tests passed: 20
Tests failed: 0
------------------------------------------------------- 

当我查看从测试输出中得到的错误消息时,我可以看到如下内容:

junit.framework.AssertionFailedError: expected:<1> but was:<0>
not-null property references a null or transient value

据我所知,测试在逻辑上是正确的,他们不应该得到这些错误,特别是当得到“瞬态值”错误的几个测试没有将任何内容存储到数据库时!

对我来说,问题似乎出在休眠/内存数据库/测试阶段的组合中。

导致此问题的环境之间肯定存在一些差异。有谁对我如何继续进一步调试问题有任何提示?

再次感谢!

编辑

好的,这就是我尝试的方法:

  1. 删除文件夹 ~/.m2~/.ivy2~/。 grails
  2. run grails clean
  3. run grails test-app

但我仍然在 CI 环境中看到失败的测试,但在开发机器上却没有。

编辑

一些新的开发..

我尝试仅运行在 CI 上失败的测试,并且似乎在运行 grails test-app :integration path.to.failing.tests 他们都通过!运行 grails test-app 时会导致这些测试失败! :(

我完全困惑不解,不知道这里发生了什么......

I have two machines, one Continuus integration server and one developer machine.

Both machines run the same version of java, maven, and grails and both are running Ubuntu.
The only difference that i can think of is that the CI is in a virtualized environment.

Some proof:

CI java -version

java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) 

DEV java -version

java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode) 

CI mvn -version

Apache Maven 2.2.1 (rdebian-1)
Java version: 1.6.0_24
Java home: /usr/lib/jvm/java-6-sun-1.6.0.24/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-31-server" arch: "amd64" Family: "unix" 

DEV mvn -version

Apache Maven 2.2.1 (rdebian-1)
Java version: 1.6.0_24
Java home: /usr/lib/jvm/java-6-sun-1.6.0.24/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.32-31-generic" arch: "amd64" Family: "unix" 

CI grails

Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /usr/local/lib/grails-1.3.7 

DEV grails

Welcome to Grails 1.3.7 - http://grails.org/
Licensed under Apache Standard License 2.0
Grails home is set to: /home/netbrain/dev/apps/grails-1.3.7 

I did a clean checkout from version control on both machines and deleted the folders ~/.m2 and ~/.ivy2 in order to avoid any indescrepencies.

When i run grails test-app on my CI server 6 tests seem to fail. When they on my DEV system all passes in the same case.

CI grails test-app

Tests Completed in 28213ms ...
-------------------------------------------------------
Tests passed: 14
Tests failed: 6
------------------------------------------------------- 

DEV grails test-app

Tests Completed in 25889ms ...
-------------------------------------------------------
Tests passed: 20
Tests failed: 0
------------------------------------------------------- 

When i look at the error messages im getting from the test output i can see things like:

junit.framework.AssertionFailedError: expected:<1> but was:<0>
not-null property references a null or transient value

As far as i can see, the tests are logically correct, and they shouldn' get these errors, especially when several tests that get the "transient value" error doesn't store anything to the database!

For me it seems like the problem lies somewhere in the combination of hibernate/memory-database/test phase.

There HAS to be some difference between the environments that is causing this issue. Does anyone have any tips on how i can proceed in order to debug the problem further?

Thanks again!

EDIT

Ok, so here is what i tried:

  1. delete the folders ~/.m2, ~/.ivy2, ~/.grails
  2. run grails clean
  3. run grails test-app

But still im seeing failed tests on my CI environment, but not on dev machine.

EDIT

Some new developments..

I tried running only the tests that failed on the CI, and it seems that when running grails test-app :integration path.to.failing.tests they all PASS! while running grails test-app causes those tests to FAIL! :(

Im totally baffled and clueless of whats going on here...

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

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

发布评论

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

评论(1

我ぃ本無心為│何有愛 2024-11-15 04:05:31

我几乎可以保证这是一个测试污染问题,并且不同的服务器以不同的顺序运行测试。

测试污染的最大线索总是当你可以成功地单独运行测试,但是当你先运行其他测试时,它就会失败。

我已经多次发生过这种情况,在一次测试中我弄乱了类的元类或注入的 spring 单例(如服务 bean),忘记清理它,并且其他测试也受到了影响。观察正在运行的测试的输出并比较它们,以确保它们在两个盒子上以完全相同的顺序运行。如果不是,则属于测试订购问题。

找出哪些测试交互不良的“最简单”方法是运行 grails test-app 并按照失败框上发生的顺序传递每个测试名称(我通常使用文本编辑器从以前的运行中切出测试名称并将它们连接在一起,这样我就知道它们的顺序相同)。

另一个潜在的问题是,如果一台机器正在使用 mysql,并且您错误配置为将“myisam”而不是“innodb”(或其他支持事务的引擎)作为默认存储引擎。您可以输入“显示引擎;”在 mysql 实例上查看默认引擎是什么。听起来您正在使用 hsqldb 或另一个内存数据库进行测试,所以这可能不是您的问题。

I would almost guarantee that this is a test pollution issue and the different servers are running the tests in different order.

The biggest clue of test pollution is always when you can run the test successfully by itself, but when you run other tests first, it fails.

I've had this happen multiple times where I've messed with the metaClass of a Class or an injected spring singleton (like a service bean) in one test, forgot to clean it up, and had other tests impacted by it. Watch the output of which tests are getting run and compare them to make sure they're running in exactly the same order on both boxes. If they aren't it's a test ordering issue.

The "easiest" way to find out what tests are interacting badly is to run grails test-app and pass in each test name in the same order that they are happening on the failing box (I normally use a text editor to slice out the test names from a previous run and concat them together so I know I have them in the same order).

Another potential issue is if one machine is using mysql and you've misconfigured to have "myisam" as the default storage engine rather than "innodb" (or another engine that supports transactions). You can type "show engines;" on the mysql instance to see what engine is default. Sounds like you're using hsqldb or another in memory db for your tests though, so this might not be your problem.

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