Jenkins,Junit和Flaky Test Handler插件

时间:2015-10-16 20:12:57

标签: maven jenkins junit maven-surefire-plugin

我正试图了解Jenkins运行的片状测试。

为了做到这一点,我已经安装了https://wiki.jenkins-ci.org/display/JENKINS/Flaky+Test+Handler+Plugin,似乎有这个目的。

我的安装(Jenkins版本,Junit插件等等)满足了插件页面中指定的所有要求。

安装插件后,建议

  

选中“附加测试”下的“发布JUnit片状测试报告”   报告功能。

和他们的截图显示

enter image description here

我的 Maven项目配置不允许我选择指定测试报告XML ,而是看起来像这样:

enter image description here

虽然,当我为配置的项目运行Jenkins构建时,我得到的只是一个空表:

enter image description here

项目配置的 Build 部分使用-Dsurefire.rerunFailingTestsCount=3选项。

我有点困惑,插件是不是我的Jenkins安装表现还是我错过了什么。

编辑 :我一直在尝试1.0.3版,其中包含其中一个答案中提到的修复程序,并且在作业执行结束时我得到了以下错误:

ERROR: Publisher 'Publish JUnit test result report' aborted due to exception: 
java.io.IOException: Unable to serialize com.google.jenkins.flakyTestHandler.junit.FlakyTestResult@55c1d6e9
    at hudson.remoting.UserRequest.serialize(UserRequest.java:169)
    at hudson.remoting.UserRequest.perform(UserRequest.java:129)
    at hudson.remoting.UserRequest.perform(UserRequest.java:49)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at ......remote call to some.slave.com(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1413)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:221)
    at hudson.remoting.Channel.call(Channel.java:778)
    at com.google.jenkins.flakyTestHandler.plugin.JUnitFlakyTestDataPublisher.getTestData(JUnitFlakyTestDataPublisher.java:49)
    at hudson.tasks.junit.TestDataPublisher.contributeTestData(TestDataPublisher.java:62)
    at hudson.tasks.junit.JUnitResultArchiver.perform(JUnitResultArchiver.java:166)
    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:75)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:726)
    at hudson.model.Build$BuildExecution.post2(Build.java:185)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
    at hudson.model.Run.execute(Run.java:1766)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:408)
Caused by: java.io.NotSerializableException: com.google.jenkins.flakyTestHandler.junit.FlakyCaseResult$FlakyRunInformation
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    at java.util.ArrayList.writeObject(ArrayList.java:762)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    at java.util.ArrayList.writeObject(ArrayList.java:762)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    at java.util.ArrayList.writeObject(ArrayList.java:762)
    at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
    at hudson.remoting.UserRequest._serialize(UserRequest.java:158)
    at hudson.remoting.UserRequest.serialize(UserRequest.java:167)
    at hudson.remoting.UserRequest.perform(UserRequest.java:129)
    at hudson.remoting.UserRequest.perform(UserRequest.java:49)
    at hudson.remoting.Request$2.run(Request.java:326)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

这似乎只发生在奴隶上执行作业时,它似乎在主人身上正常工作。

编辑2 :1.0.4解决了上述问题。

编辑3 :尽管1.0.4修复了序列化问题,但插件报告似乎仍然存在。例如,在以下情况中:

wrong reporting

  • 工作#21成功运行
  • 第22号工作跑了并进行了一次片状测试,第二次测试通过
  • 工作#23成功运行

该项目的报告称有一个片状测试,一个片状,0个失败和0个传递。我会期待2张通票,0张失败和1张片。

我错过了什么吗?

2 个答案:

答案 0 :(得分:2)

我遇到了同样的问题。查看主日志,结果表明该插件并不期望在从属服务器上执行构建。有拉动请求可以解决我的问题 - https://github.com/jenkinsci/flaky-test-handler-plugin/pull/2

答案 1 :(得分:2)

如果我没记错的话,我们会定义一个片状测试:

对于相同的代码修订版,它既失败又通过。

因此,如果你从不修改代码,即使你运行了100次,结果是50遍和50次失败,我们仍然把它算作一个片;如果它通过所有100次,那么它算作一次通过;否则,如果它全部失败100次,那就是一次失败。

如果您进行了一些更改并提交了另一个版本,然后在此基础上进行构建,那么它将是一个新的数字。

我相信如果你点击测试,那么你可以看到详细的通过/失败,这是你想要的吗?

https://wiki.jenkins-ci.org/display/JENKINS/Flaky+Test+Handler+Plugin "通过修订和#34;聚合测试统计数据。