Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FIY695
jenkins
提交
1a80973a
J
jenkins
项目概览
FIY695
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
1a80973a
编写于
1月 06, 2015
作者:
J
Jesse Glick
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into FlyweightTask-JENKINS-10944
上级
3e344a94
86ed7771
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
64 addition
and
15 deletion
+64
-15
changelog.html
changelog.html
+3
-1
core/src/main/java/hudson/model/queue/FutureImpl.java
core/src/main/java/hudson/model/queue/FutureImpl.java
+8
-0
core/src/main/java/hudson/slaves/ComputerRetentionWork.java
core/src/main/java/hudson/slaves/ComputerRetentionWork.java
+1
-1
test/src/test/java/hudson/model/QueueTest.java
test/src/test/java/hudson/model/QueueTest.java
+30
-0
test/src/test/java/lib/form/NameRefTest.java
test/src/test/java/lib/form/NameRefTest.java
+22
-13
test/src/test/resources/lib/form/NameRefTest/JenkinsRuleWithJelly/test1.jelly
...ces/lib/form/NameRefTest/JenkinsRuleWithJelly/test1.jelly
+0
-0
未找到文件。
changelog.html
浏览文件 @
1a80973a
...
...
@@ -55,7 +55,9 @@ Upcoming changes</a>
<!-- Record your changes in the trunk here. -->
<div
id=
"trunk"
style=
"display:none"
>
<!--=TRUNK-BEGIN=-->
<ul
class=
image
>
<li
class=
>
<li
class=
bug
>
FutureImpl does not cancel its start future.
(
<a
href=
"https://issues.jenkins-ci.org/browse/JENKINS-25514"
>
issue 25514
</a>
)
</ul>
</div>
<!--=TRUNK-END=-->
...
...
core/src/main/java/hudson/model/queue/FutureImpl.java
浏览文件 @
1a80973a
...
...
@@ -84,6 +84,14 @@ public final class FutureImpl extends AsyncFutureImpl<Executable> implements Que
}
}
@Override
public
synchronized
void
setAsCancelled
()
{
super
.
setAsCancelled
();
if
(!
start
.
isDone
())
{
start
.
setAsCancelled
();
}
}
synchronized
void
addExecutor
(
@Nonnull
Executor
executor
)
{
this
.
executors
.
add
(
executor
);
}
...
...
core/src/main/java/hudson/slaves/ComputerRetentionWork.java
浏览文件 @
1a80973a
...
...
@@ -63,7 +63,7 @@ public class ComputerRetentionWork extends PeriodicWork {
if
(!
nextCheck
.
containsKey
(
c
)
||
startRun
>
nextCheck
.
get
(
c
))
{
// at the moment I don't trust strategies to wait more than 60 minutes
// strategies need to wait at least one minute
final
long
waitInMins
=
Math
.
m
in
(
1
,
Math
.
max
(
60
,
c
.
getRetentionStrategy
().
check
(
c
)));
final
long
waitInMins
=
Math
.
m
ax
(
1
,
Math
.
min
(
60
,
c
.
getRetentionStrategy
().
check
(
c
)));
nextCheck
.
put
(
c
,
startRun
+
waitInMins
*
1000
*
60
/*MINS->MILLIS*/
);
}
}
...
...
test/src/test/java/hudson/model/QueueTest.java
浏览文件 @
1a80973a
...
...
@@ -62,6 +62,7 @@ import java.util.List;
import
java.util.concurrent.CancellationException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeoutException
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
@@ -612,4 +613,33 @@ public class QueueTest {
}
catch
(
CancellationException
e
)
{
}
}
@Test
public
void
waitForStartAndCancelBeforeStart
()
throws
Exception
{
final
OneShotEvent
ev
=
new
OneShotEvent
();
FreeStyleProject
p
=
r
.
createFreeStyleProject
();
QueueTaskFuture
<
FreeStyleBuild
>
f
=
p
.
scheduleBuild2
(
10
);
final
Queue
.
Item
item
=
Queue
.
getInstance
().
getItem
(
p
);
assertNotNull
(
item
);
final
ScheduledThreadPoolExecutor
executor
=
new
ScheduledThreadPoolExecutor
(
1
);
executor
.
schedule
(
new
Runnable
()
{
@Override
public
void
run
()
{
try
{
Queue
.
getInstance
().
doCancelItem
(
item
.
id
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
ServletException
e
)
{
e
.
printStackTrace
();
}
}
},
2
,
TimeUnit
.
SECONDS
);
try
{
f
.
waitForStart
();
fail
(
"Expected an CancellationException to be thrown"
);
}
catch
(
CancellationException
e
)
{}
}
}
test/src/test/java/lib/form/NameRefTest.java
浏览文件 @
1a80973a
...
...
@@ -25,27 +25,36 @@ package lib.form;
import
com.gargoylesoftware.htmlunit.html.HtmlPage
;
import
net.sf.json.JSONObject
;
import
org.jvnet.hudson.test.HudsonTestCase
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.kohsuke.stapler.HttpResponse
;
import
org.kohsuke.stapler.HttpResponses
;
import
org.kohsuke.stapler.StaplerRequest
;
/**
* Tests the handling of @nameRef in the form tree.
*
* @author Kohsuke Kawaguchi
*/
public
class
NameRefTest
extends
HudsonTestCase
{
public
void
test1
()
throws
Exception
{
jenkins
.
setCrumbIssuer
(
null
);
HtmlPage
p
=
createWebClient
().
goTo
(
"self/test1"
);
submit
(
p
.
getFormByName
(
"config"
));
public
class
NameRefTest
{
@Rule
public
JenkinsRule
r
=
new
JenkinsRuleWithJelly
();
@Test
public
void
test
()
throws
Exception
{
r
.
jenkins
.
setCrumbIssuer
(
null
);
HtmlPage
p
=
r
.
createWebClient
().
goTo
(
"self/test1"
);
r
.
submit
(
p
.
getFormByName
(
"config"
));
}
public
HttpResponse
doSubmitTest1
(
StaplerRequest
req
)
throws
Exception
{
JSONObject
f
=
req
.
getSubmittedForm
();
System
.
out
.
println
(
f
);
assertEquals
(
"{\"foo\":{\"bar\":{\"zot\":\"zot\"}}}"
,
f
.
toString
());
return
HttpResponses
.
ok
();
public
static
class
JenkinsRuleWithJelly
extends
JenkinsRule
{
public
HttpResponse
doSubmitTest1
(
StaplerRequest
req
)
throws
Exception
{
JSONObject
f
=
req
.
getSubmittedForm
();
System
.
out
.
println
(
f
);
assertEquals
(
"{\"foo\":{\"bar\":{\"zot\":\"zot\"}}}"
,
f
.
toString
());
return
HttpResponses
.
ok
();
}
}
}
test/src/test/resources/lib/form/NameRefTest/test1.jelly
→
test/src/test/resources/lib/form/NameRefTest/
JenkinsRuleWithJelly/
test1.jelly
浏览文件 @
1a80973a
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录