Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
17fdfab3
J
jenkins
项目概览
LinuxSuRen
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
17fdfab3
编写于
7月 29, 2014
作者:
S
Stephen Connolly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIXED JENKINS-240006] Customize number of Junit test failures that affect weather
- Implemented as an amplification factor.
上级
5b7d59a7
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
83 addition
and
4 deletion
+83
-4
core/src/main/java/hudson/tasks/junit/JUnitResultArchiver.java
...src/main/java/hudson/tasks/junit/JUnitResultArchiver.java
+30
-2
core/src/main/java/hudson/tasks/junit/TestResultAction.java
core/src/main/java/hudson/tasks/junit/TestResultAction.java
+12
-1
core/src/main/java/hudson/tasks/test/AbstractTestResultAction.java
...main/java/hudson/tasks/test/AbstractTestResultAction.java
+20
-1
core/src/main/resources/hudson/tasks/junit/JUnitResultArchiver/config.jelly
...urces/hudson/tasks/junit/JUnitResultArchiver/config.jelly
+3
-0
core/src/main/resources/hudson/tasks/junit/JUnitResultArchiver/help-healthScaleFactor.html
...sks/junit/JUnitResultArchiver/help-healthScaleFactor.html
+17
-0
core/src/main/resources/hudson/tasks/junit/Messages.properties
...src/main/resources/hudson/tasks/junit/Messages.properties
+1
-0
未找到文件。
core/src/main/java/hudson/tasks/junit/JUnitResultArchiver.java
浏览文件 @
17fdfab3
...
...
@@ -52,6 +52,7 @@ import org.kohsuke.stapler.QueryParameter;
import
org.kohsuke.stapler.StaplerRequest
;
import
java.io.IOException
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
...
...
@@ -82,6 +83,8 @@ public class JUnitResultArchiver extends Recorder {
*/
private
final
DescribableList
<
TestDataPublisher
,
Descriptor
<
TestDataPublisher
>>
testDataPublishers
;
private
final
Double
healthScaleFactor
;
/**
* left for backwards compatibility
* @deprecated since 2009-08-09.
...
...
@@ -97,14 +100,24 @@ public class JUnitResultArchiver extends Recorder {
this
(
testResults
,
false
,
testDataPublishers
);
}
@D
ataBoundConstructor
@D
eprecated
public
JUnitResultArchiver
(
String
testResults
,
boolean
keepLongStdio
,
DescribableList
<
TestDataPublisher
,
Descriptor
<
TestDataPublisher
>>
testDataPublishers
)
{
this
(
testResults
,
keepLongStdio
,
testDataPublishers
,
1.0
);
}
@DataBoundConstructor
public
JUnitResultArchiver
(
String
testResults
,
boolean
keepLongStdio
,
DescribableList
<
TestDataPublisher
,
Descriptor
<
TestDataPublisher
>>
testDataPublishers
,
double
healthScaleFactor
)
{
this
.
testResults
=
testResults
;
this
.
keepLongStdio
=
keepLongStdio
;
this
.
testDataPublishers
=
testDataPublishers
;
this
.
healthScaleFactor
=
Math
.
max
(
0.0
,
healthScaleFactor
);
}
/**
...
...
@@ -133,6 +146,7 @@ public class JUnitResultArchiver extends Recorder {
}
catch
(
NullPointerException
npe
)
{
throw
new
AbortException
(
Messages
.
JUnitResultArchiver_BadXML
(
testResults
));
}
action
.
setHealthScaleFactor
(
getHealthScaleFactor
());
// TODO do we want to move this to the constructor?
result
.
freeze
(
action
);
if
(
result
.
isEmpty
())
{
// most likely a configuration error in the job - e.g. false pattern to match the JUnit result files
...
...
@@ -192,7 +206,11 @@ public class JUnitResultArchiver extends Recorder {
return
testResults
;
}
public
DescribableList
<
TestDataPublisher
,
Descriptor
<
TestDataPublisher
>>
getTestDataPublishers
()
{
public
double
getHealthScaleFactor
()
{
return
healthScaleFactor
==
null
?
1.0
:
healthScaleFactor
;
}
public
DescribableList
<
TestDataPublisher
,
Descriptor
<
TestDataPublisher
>>
getTestDataPublishers
()
{
return
testDataPublishers
;
}
...
...
@@ -248,5 +266,15 @@ public class JUnitResultArchiver extends Recorder {
public
boolean
isApplicable
(
Class
<?
extends
AbstractProject
>
jobType
)
{
return
true
;
}
public
FormValidation
doCheckHealthScaleFactor
(
@QueryParameter
double
value
)
{
if
(
value
<
1
e
-
7
)
return
FormValidation
.
warning
(
"Test health reporting disabled"
);
return
FormValidation
.
ok
(
Messages
.
JUnitResultArchiver_HealthScaleFactorAnalysis
(
1
,
(
int
)
(
100.0
-
Math
.
max
(
0.0
,
Math
.
min
(
100.0
,
1
*
value
))),
5
,
(
int
)
(
100.0
-
Math
.
max
(
0.0
,
Math
.
min
(
100.0
,
5
*
value
)))
));
}
}
}
core/src/main/java/hudson/tasks/junit/TestResultAction.java
浏览文件 @
17fdfab3
...
...
@@ -26,6 +26,7 @@ package hudson.tasks.junit;
import
com.thoughtworks.xstream.XStream
;
import
hudson.XmlFile
;
import
hudson.model.AbstractBuild
;
import
hudson.model.AbstractProject
;
import
hudson.model.Action
;
import
hudson.model.BuildListener
;
import
hudson.tasks.test.AbstractTestResultAction
;
...
...
@@ -60,6 +61,7 @@ public class TestResultAction extends AbstractTestResultAction<TestResultAction>
private
int
failCount
;
private
int
skipCount
;
private
Integer
totalCount
;
private
Double
healthScaleFactor
;
private
List
<
Data
>
testData
=
new
ArrayList
<
Data
>();
@Deprecated
...
...
@@ -139,7 +141,16 @@ public class TestResultAction extends AbstractTestResultAction<TestResultAction>
return
totalCount
;
}
@Override
@Override
public
double
getHealthScaleFactor
()
{
return
healthScaleFactor
==
null
?
1.0
:
healthScaleFactor
;
}
public
void
setHealthScaleFactor
(
double
healthScaleFactor
)
{
this
.
healthScaleFactor
=
Math
.
max
(
0.0
,
healthScaleFactor
);
}
@Override
public
List
<
CaseResult
>
getFailedTests
()
{
return
getResult
().
getFailedTests
();
}
...
...
core/src/main/java/hudson/tasks/test/AbstractTestResultAction.java
浏览文件 @
17fdfab3
...
...
@@ -133,9 +133,15 @@ public abstract class AbstractTestResultAction<T extends AbstractTestResultActio
}
public
HealthReport
getBuildHealth
()
{
final
double
scaleFactor
=
getHealthScaleFactor
();
if
(
scaleFactor
<
1
e
-
7
)
{
return
null
;
}
final
int
totalCount
=
getTotalCount
();
final
int
failCount
=
getFailCount
();
int
score
=
(
totalCount
==
0
)
?
100
:
(
int
)
(
100.0
*
(
1.0
-
((
double
)
failCount
)
/
totalCount
));
int
score
=
(
totalCount
==
0
)
?
100
:
(
int
)
(
100.0
*
Math
.
max
(
1.0
,
Math
.
min
(
0.0
,
1.0
-
(
scaleFactor
*
failCount
)
/
totalCount
)));
Localizable
description
,
displayName
=
Messages
.
_AbstractTestResultAction_getDisplayName
();
if
(
totalCount
==
0
)
{
description
=
Messages
.
_AbstractTestResultAction_zeroTestDescription
(
displayName
);
...
...
@@ -145,6 +151,19 @@ public abstract class AbstractTestResultAction<T extends AbstractTestResultActio
return
new
HealthReport
(
score
,
description
);
}
/**
* Returns how much to scale the test related health by.
* @return a factor of {@code 1.0} to have the test health be the percentage of tests passing so 20% of tests
* failing will report as 80% health. A factor of {@code 2.0} will mean that 20% of tests failing will report as 60%
* health. A factor of {@code 2.5} will mean that 20% of test failing will report as 50% health. A factor of
* {@code 4.0} will mean that 20% of tests failing will report as 20% health. A factor of {@code 5.0} will mean
* that 20% (or more) of tests failing will report as 0% health. A factor of {@code 0.0} will disable test health
* reporting.
*/
public
double
getHealthScaleFactor
()
{
return
1.0
;
}
/**
* Exposes this object to the remote API.
*/
...
...
core/src/main/resources/hudson/tasks/junit/JUnitResultArchiver/config.jelly
浏览文件 @
17fdfab3
...
...
@@ -33,6 +33,9 @@ THE SOFTWARE.
<f:entry field="keepLongStdio" title="">
<f:checkbox name="keepLongStdio" checked="${instance.keepLongStdio}" title="${%Retain long standard output/error}"/>
</f:entry>
<f:entry field="healthScaleFactor" title="${%Health report amplification factor}">
<f:number default="1.0" min="0" step="0.1" size="10"/>
</f:entry>
<j:invokeStatic var="testDataPublisherDescriptors"
className="hudson.tasks.junit.TestDataPublisher" method="all" />
<j:if test="${testDataPublisherDescriptors.size() > 0}">
...
...
core/src/main/resources/hudson/tasks/junit/JUnitResultArchiver/help-healthScaleFactor.html
0 → 100644
浏览文件 @
17fdfab3
<div>
The amplification factor to apply to test failures when computing the test result contribution to the build health
score.
<br
/>
The default factor is
<code>
1.0
</code>
<ul>
<li>
A factor of
<code>
0.0
</code>
will disable the test result contribution to build health score.
</li>
<li>
A factor of
<code>
0.1
</code>
means that 10% of tests failing will score 99% health
</li>
<li>
A factor of
<code>
0.5
</code>
means that 10% of tests failing will score 95% health
</li>
<li>
A factor of
<code>
1.0
</code>
means that 10% of tests failing will score 10% health
</li>
<li>
A factor of
<code>
2.0
</code>
means that 10% of tests failing will score 20% health
</li>
<li>
A factor of
<code>
2.5
</code>
means that 10% of tests failing will score 25% health
</li>
<li>
A factor of
<code>
5.0
</code>
means that 10% of tests failing will score 50% health
</li>
<li>
A factor of
<code>
10.0
</code>
means that 10% of tests failing will score 0% health
</li>
</ul>
The factor is persisted with the build results, so changes will only be reflected in new builds.
</div>
\ No newline at end of file
core/src/main/resources/hudson/tasks/junit/Messages.properties
浏览文件 @
17fdfab3
...
...
@@ -36,6 +36,7 @@ JUnitResultArchiver.NoTestReportFound=No test report files were found. Configura
JUnitResultArchiver.Recording
=
Recording test results
JUnitResultArchiver.ResultIsEmpty
=
None of the test reports contained any result
JUnitResultArchiver.BadXML
=
Incorrect XML attributes for test results found in {0}
JUnitResultArchiver.HealthScaleFactorAnalysis
=
{0}% failing tests scores as {1}% health. {2}% failing tests scores as {3}% health
CaseResult.Status.Passed
=
Passed
CaseResult.Status.Failed
=
Failed
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录