Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
8d113a10
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,发现更多精彩内容 >>
提交
8d113a10
编写于
10月 01, 2015
作者:
V
Valentina Armenise
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-30084] address feedbacks
上级
7ea21bbf
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
23 addition
and
9 deletion
+23
-9
core/src/main/java/hudson/model/Queue.java
core/src/main/java/hudson/model/Queue.java
+6
-3
test/src/test/java/hudson/model/QueueTest.java
test/src/test/java/hudson/model/QueueTest.java
+17
-6
未找到文件。
core/src/main/java/hudson/model/Queue.java
浏览文件 @
8d113a10
...
...
@@ -879,7 +879,7 @@ public class Queue extends ResourceController implements Saveable {
/**
* Gets the snapshot of all {@link BlockedItem}s.
*/
p
ublic
List
<
BlockedItem
>
getBlockedItems
()
{
p
rotected
List
<
BlockedItem
>
getBlockedItems
()
{
return
new
ArrayList
<
BlockedItem
>(
snapshot
.
blockedProjects
);
}
...
...
@@ -1583,17 +1583,20 @@ public class Queue extends ResourceController implements Saveable {
ConsistentHash
<
Node
>
hash
=
new
ConsistentHash
<
Node
>(
NODE_HASH
);
hash
.
addAll
(
hashSource
);
Label
lbl
=
p
.
getAssignedLabel
();
for
(
Node
n
:
hash
.
list
(
p
.
task
.
getFullDisplayName
()))
{
final
Computer
c
=
n
.
toComputer
();
if
(
c
==
null
||
c
.
isOffline
())
{
continue
;
}
if
(
lbl
!=
null
&&
!
lbl
.
contains
(
n
))
{
continue
;
}
if
(
n
.
canTake
(
p
)
!=
null
)
{
continue
;
}
return
new
Runnable
()
{
@Override
public
void
run
()
{
@Override
public
void
run
()
{
c
.
startFlyWeightTask
(
new
WorkUnitContext
(
p
).
createWorkUnit
(
p
.
task
));
makePending
(
p
);
...
...
test/src/test/java/hudson/model/QueueTest.java
浏览文件 @
8d113a10
...
...
@@ -814,31 +814,42 @@ public class QueueTest {
matrixProject
.
setAxes
(
new
AxisList
(
new
Axis
(
"axis"
,
"a"
,
"b"
)
));
Label
label
=
LabelExpression
.
get
(
"aws-linux-dummy"
);
DummyCloudImpl
dummyCloud
=
new
DummyCloudImpl
(
r
,
0
);
dummyCloud
.
label
=
label
;
PropertyImpl
property
=
new
PropertyImpl
();
BlockDownstreamProjectExecution
property
=
new
BlockDownstreamProjectExecution
();
dummyCloud
.
getNodeProperties
().
add
(
property
);
r
.
jenkins
.
clouds
.
add
(
dummyCloud
);
matrixProject
.
setAssignedLabel
(
label
);
FreeStyleProject
upstreamProject
=
r
.
createFreeStyleProject
(
"upstream"
);
upstreamProject
.
getBuildersList
().
add
(
new
SleepBuilder
(
10000
));
upstreamProject
.
setDisplayName
(
"upstream"
);
//let's assume the flyweighttask has an upstream project and that must be blocked
// when the upstream project is running
matrixProject
.
addTrigger
(
new
ReverseBuildTrigger
(
"upstream"
,
Result
.
SUCCESS
));
matrixProject
.
setBlockBuildWhenUpstreamBuilding
(
true
);
//we schedule the project but we pretend no executors are available thus
//the flyweight task is in the buildable queue without being executed
matrixProject
.
scheduleBuild2
(
0
);
QueueTaskFuture
downstream
=
matrixProject
.
scheduleBuild2
(
0
);
if
(
downstream
==
null
)
{
throw
new
Exception
(
"the flyweight task could not be scheduled, thus the test will be interrupted"
);
}
//let s wait for the Queue instance to be updated
while
(
Queue
.
getInstance
().
getBuildableItems
().
size
()
!=
1
)
{
Thread
.
sleep
(
10
);
}
//in this state the build is not blocked, it's just waiting for an available executor
assertFalse
(
Queue
.
getInstance
().
getItems
()[
0
].
isBlocked
());
//we start the upstream project that should block the downstream one
upstreamProject
.
getBuildersList
().
add
(
new
SleepBuilder
(
10000
));
upstreamProject
.
setDisplayName
(
"upstream"
);
QueueTaskFuture
upstream
=
upstreamProject
.
scheduleBuild2
(
0
);
if
(
upstream
==
null
)
{
throw
new
Exception
(
"the upstream task could not be scheduled, thus the test will be interrupted"
);
}
//let s wait for the Upstream to enter the buildable Queue
boolean
enteredTheQueue
=
false
;
while
(!
enteredTheQueue
)
{
...
...
@@ -856,8 +867,8 @@ public class QueueTest {
assertTrue
(
Queue
.
getInstance
().
getItems
()[
0
].
isBlocked
());
assertTrue
(
Queue
.
getInstance
().
getBlockedItems
().
get
(
0
).
task
.
getDisplayName
().
equals
(
matrixProject
.
displayName
));
r
.
assertBuildStatusSuccess
(
upstream
);
//once the upstream is completed, the downstream can join the buildable queue again.
r
.
assertBuildStatusSuccess
(
upstream
);
while
(
Queue
.
getInstance
().
getBuildableItems
().
isEmpty
())
{
Thread
.
sleep
(
10
);
}
...
...
@@ -868,7 +879,7 @@ public class QueueTest {
//let's make sure that the downstram project is not started before the upstream --> we want to simulate
// the case: buildable-->blocked-->buildable
public
static
class
PropertyImpl
extends
NodeProperty
<
Slave
>
{
public
static
class
BlockDownstreamProjectExecution
extends
NodeProperty
<
Slave
>
{
@Override
public
CauseOfBlockage
canTake
(
Queue
.
BuildableItem
item
)
{
if
(
item
.
task
.
getName
().
equals
(
"downstream"
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录