Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
67e4e88b
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,发现更多精彩内容 >>
提交
67e4e88b
编写于
5月 07, 2015
作者:
I
Ing. Pavel Janousek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[JENKINS-28041] Extended delete-node CLI command to accept multiple names to delete
上级
4ddc5aa3
变更
21
隐藏空白更改
内联
并排
Showing
21 changed file
with
255 addition
and
12 deletion
+255
-12
core/src/main/java/hudson/cli/DeleteNodeCommand.java
core/src/main/java/hudson/cli/DeleteNodeCommand.java
+90
-0
core/src/main/java/hudson/model/Computer.java
core/src/main/java/hudson/model/Computer.java
+1
-1
core/src/main/resources/hudson/cli/Messages.properties
core/src/main/resources/hudson/cli/Messages.properties
+4
-0
core/src/main/resources/hudson/cli/Messages_da.properties
core/src/main/resources/hudson/cli/Messages_da.properties
+1
-0
core/src/main/resources/hudson/cli/Messages_de.properties
core/src/main/resources/hudson/cli/Messages_de.properties
+1
-0
core/src/main/resources/hudson/cli/Messages_es.properties
core/src/main/resources/hudson/cli/Messages_es.properties
+1
-0
core/src/main/resources/hudson/cli/Messages_it.properties
core/src/main/resources/hudson/cli/Messages_it.properties
+1
-0
core/src/main/resources/hudson/cli/Messages_ja.properties
core/src/main/resources/hudson/cli/Messages_ja.properties
+3
-1
core/src/main/resources/hudson/cli/Messages_pt_BR.properties
core/src/main/resources/hudson/cli/Messages_pt_BR.properties
+3
-0
core/src/main/resources/hudson/cli/Messages_zh_CN.properties
core/src/main/resources/hudson/cli/Messages_zh_CN.properties
+1
-0
core/src/main/resources/hudson/cli/Messages_zh_TW.properties
core/src/main/resources/hudson/cli/Messages_zh_TW.properties
+2
-0
core/src/main/resources/hudson/model/Messages.properties
core/src/main/resources/hudson/model/Messages.properties
+0
-1
core/src/main/resources/hudson/model/Messages_da.properties
core/src/main/resources/hudson/model/Messages_da.properties
+0
-1
core/src/main/resources/hudson/model/Messages_de.properties
core/src/main/resources/hudson/model/Messages_de.properties
+0
-1
core/src/main/resources/hudson/model/Messages_es.properties
core/src/main/resources/hudson/model/Messages_es.properties
+0
-1
core/src/main/resources/hudson/model/Messages_it.properties
core/src/main/resources/hudson/model/Messages_it.properties
+0
-1
core/src/main/resources/hudson/model/Messages_ja.properties
core/src/main/resources/hudson/model/Messages_ja.properties
+0
-1
core/src/main/resources/hudson/model/Messages_pt_BR.properties
...src/main/resources/hudson/model/Messages_pt_BR.properties
+0
-2
core/src/main/resources/hudson/model/Messages_zh_CN.properties
...src/main/resources/hudson/model/Messages_zh_CN.properties
+0
-1
core/src/main/resources/hudson/model/Messages_zh_TW.properties
...src/main/resources/hudson/model/Messages_zh_TW.properties
+0
-1
test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
+147
-0
未找到文件。
core/src/main/java/hudson/cli/DeleteNodeCommand.java
0 → 100644
浏览文件 @
67e4e88b
/*
* The MIT License
*
* Copyright (c) 2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package
hudson.cli
;
import
hudson.Extension
;
import
hudson.model.Computer
;
import
hudson.model.Node
;
import
jenkins.model.Jenkins
;
import
org.kohsuke.args4j.Argument
;
import
java.util.HashSet
;
import
java.util.List
;
/**
* @author pjanouse
* @since TODO
*/
@Extension
public
class
DeleteNodeCommand
extends
CLICommand
{
@Argument
(
usage
=
"Nodes name to delete"
,
required
=
true
,
multiValued
=
true
)
private
List
<
String
>
nodes
;
@Override
public
String
getShortDescription
()
{
return
Messages
.
DeleteNodeCommand_ShortDescription
();
}
@Override
protected
int
run
()
throws
Exception
{
boolean
errorOccurred
=
false
;
HashSet
<
String
>
hs
=
new
HashSet
<
String
>();
hs
.
addAll
(
nodes
);
for
(
String
node_s
:
hs
)
{
Node
node
=
Jenkins
.
getInstance
().
getNode
(
node_s
);
if
(
node
==
null
)
{
stderr
.
format
(
"No such node '%s'\n"
,
node_s
);
errorOccurred
=
true
;
continue
;
}
try
{
node
.
checkPermission
(
Computer
.
DELETE
);
}
catch
(
Exception
e
)
{
stderr
.
println
(
e
.
getMessage
());
errorOccurred
=
true
;
continue
;
}
try
{
Jenkins
.
getInstance
().
removeNode
(
node
);
}
catch
(
Exception
e
)
{
stderr
.
format
(
"Unexpected exception occurred during deletion of node '%s': %s\n"
,
node
.
getDisplayName
(),
e
.
getMessage
()
);
errorOccurred
=
true
;
continue
;
}
}
return
errorOccurred
?
-
1
:
0
;
}
}
core/src/main/java/hudson/model/Computer.java
浏览文件 @
67e4e88b
...
...
@@ -1292,7 +1292,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
/**
* Really deletes the slave.
*/
@CLIMethod
(
name
=
"delete-node"
)
//
@CLIMethod(name="delete-node")
@RequirePOST
public
HttpResponse
doDoDelete
()
throws
IOException
{
checkPermission
(
DELETE
);
...
...
core/src/main/resources/hudson/cli/Messages.properties
浏览文件 @
67e4e88b
...
...
@@ -78,3 +78,7 @@ BuildCommand.CLICause.CannotBuildConfigNotSaved=\
Cannot build {0} because its configuration has not been saved.
BuildCommand.CLICause.CannotBuildUnknownReasons
=
\
Cannot build {0} for unknown reasons.
DeleteNodeCommand.ShortDescription
=
\
Deletes node(s)
core/src/main/resources/hudson/cli/Messages_da.properties
0 → 100644
浏览文件 @
67e4e88b
DeleteNodeCommand.ShortDescription
=
Sletter en node
core/src/main/resources/hudson/cli/Messages_de.properties
0 → 100644
浏览文件 @
67e4e88b
DeleteNodeCommand.ShortDescription
=
Knoten l
\u
00f6schen.
core/src/main/resources/hudson/cli/Messages_es.properties
浏览文件 @
67e4e88b
...
...
@@ -48,3 +48,4 @@ UpdateJobCommand.ShortDescription=Actualiza el fichero XML de la definici
GroovyshCommand.ShortDescription
=
Ejecuta una shell interactiva de groovy.
SetBuildDescriptionCommand.ShortDescription
=
Establece la descripcin de una ejecucin.
DeleteNodeCommand.ShortDescription
=
Borrar un nodo
core/src/main/resources/hudson/cli/Messages_it.properties
0 → 100644
浏览文件 @
67e4e88b
DeleteNodeCommand.ShortDescription
=
Cancella un nodo
core/src/main/resources/hudson/cli/Messages_ja.properties
浏览文件 @
67e4e88b
...
...
@@ -68,4 +68,6 @@ BuildCommand.CLICause.CannotBuildDisabled=\
BuildCommand.CLICause.CannotBuildConfigNotSaved
=
\
\u
8a2d
\u
5b9a
\u
304c
\u
4fdd
\u
5b58
\u3055\u
308c
\u3066\u3044\u
306a
\u3044\u
306e
\u3067
{0}
\u3092\u
30d3
\u
30eb
\u
30c9
\u3067\u
304d
\u
307e
\u
305b
\u3093\u3002
BuildCommand.CLICause.CannotBuildUnknownReasons
=
\
\u
30d3
\u
30eb
\u
30c9
\u3067\u
304d
\u
307e
\u
305b
\u3093
(
\u
539f
\u
56e0
\u
4e0d
\u
660e)
\u3002
\ No newline at end of file
\u
30d3
\u
30eb
\u
30c9
\u3067\u
304d
\u
307e
\u
305b
\u3093
(
\u
539f
\u
56e0
\u
4e0d
\u
660e)
\u3002
DeleteNodeCommand.ShortDescription
=
\u
30ce
\u
30fc
\u
30c9
\u3092\u
524a
\u9664\u3057\u
307e
\u3059\u3002
core/src/main/resources/hudson/cli/Messages_pt_BR.properties
浏览文件 @
67e4e88b
...
...
@@ -110,3 +110,6 @@ SessionIdCommand.ShortDescription=Exibe o ID de sess\u00e3o, que muda toda vez q
InstallPluginCommand.InstallingPluginFromUrl
=
Instalando um plugin de {0}
# Installs a plugin either from a file, an URL, or from update center.
InstallPluginCommand.ShortDescription
=
Instala um plugin a partir de um arquivo, uma URL, ou da central de atualiza
\u
00e7
\u
00f5es.
# Deletes a node
CLI.delete-node.shortDescription
=
Remover o n
\u
00f3
core/src/main/resources/hudson/cli/Messages_zh_CN.properties
0 → 100644
浏览文件 @
67e4e88b
DeleteNodeCommand.ShortDescription
=
Deletes a node
core/src/main/resources/hudson/cli/Messages_zh_TW.properties
浏览文件 @
67e4e88b
...
...
@@ -72,3 +72,5 @@ WhoAmICommand.ShortDescription=\
UpdateJobCommand.ShortDescription
=
\
\u7531
stdin
\u
66f4
\u
65b0
\u
4f5c
\u
696d
\u
5b9a
\u
7fa9 XML
\u3002
get-job
\u6307\u
4ee4
\u7684\u
76f8
\u
53cd
BuildCommand.CLICause.ShortDescription
=
\u7531
{0}
\u7684\u
547d
\u
4ee4
\u5217\u
4ecb
\u9762\u
555f
\u
52d5
DeleteNodeCommand.ShortDescription
=
\u
522a
\u9664\u6307\u
5b9a
\u
7bc0
\u
9ede
\u3002
core/src/main/resources/hudson/model/Messages.properties
浏览文件 @
67e4e88b
...
...
@@ -97,7 +97,6 @@ CLI.delete-job.shortDescription=Deletes a job.
CLI.reload-job.shortDescription
=
Reloads this job from disk.
CLI.disable-job.shortDescription
=
Disables a job.
CLI.enable-job.shortDescription
=
Enables a job.
CLI.delete-node.shortDescription
=
Deletes a node.
CLI.disconnect-node.shortDescription
=
Disconnects from a node.
CLI.connect-node.shortDescription
=
Reconnect to a node.
CLI.online-node.shortDescription
=
Resume using a node for performing builds, to cancel out the earlier "offline-node" command.
...
...
core/src/main/resources/hudson/model/Messages_da.properties
浏览文件 @
67e4e88b
...
...
@@ -144,7 +144,6 @@ UpdateCenter.PluginCategory.scm=Kildekodestyring (SCM)
View.ConfigurePermission.Description
=
Denne rettighed tillader brugere at
\u
00e6ndre konfigurationen af visninger.
AbstractProject.NewBuildForWorkspace
=
Skedulerer et nyt byg for at f
\u
00e5 et arbejdsomr
\u
00e5de
Node.LabelMissing
=
{0} har ikke etiket {1}
CLI.delete-node.shortDescription
=
Sletter en node
Queue.BlockedBy
=
Blokeret af {0}
Node.BecauseNodeIsReserved
=
{0} er reserveret til jobs bundet(tied) til den
Job.minutes
=
min
...
...
core/src/main/resources/hudson/model/Messages_de.properties
浏览文件 @
67e4e88b
...
...
@@ -88,7 +88,6 @@ CLI.disable-job.shortDescription=Job deaktivieren.
CLI.enable-job.shortDescription
=
Job aktivieren.
CLI.connect-node.shortDescription
=
Erneut mit Knoten verbinden.
CLI.disconnect-node.shortDescription
=
Knoten trennen.
CLI.delete-node.shortDescription
=
Knoten l
\u
00f6schen.
CLI.offline-node.shortDescription
=
Knoten wird bis zum n
\u
00e4chsten "online-node"-Kommando f
\u
00fcr keine neuen Builds verwendet.
CLI.online-node.shortDescription
=
Knoten wird wieder f
\u
00fcr neue Builds verwendet. Hebt ein vorausgegangenes "offline-node"-Kommando auf.
CLI.safe-restart.shortDescription
=
Startet Jenkins neu.
...
...
core/src/main/resources/hudson/model/Messages_es.properties
浏览文件 @
67e4e88b
...
...
@@ -62,7 +62,6 @@ CLI.clear-queue.shortDescription=Limpiar la cola de trabajos
CLI.delete-job.shortDescription
=
Borrar una tarea
CLI.disable-job.shortDescription
=
Desactivar una tarea
CLI.enable-job.shortDescription
=
Activar una tarea
CLI.delete-node.shortDescription
=
Borrar un nodo
CLI.disconnect-node.shortDescription
=
Desconectarse de un nodo
CLI.connect-node.shortDescription
=
Reconectarse con un nodo
CLI.online-node.shortDescription
=
Continuar usando un nodo y candelar el comando "offline-node" mas reciente.
...
...
core/src/main/resources/hudson/model/Messages_it.properties
浏览文件 @
67e4e88b
...
...
@@ -80,7 +80,6 @@ CLI.clear-queue.shortDescription=Pulisce la coda di lavoro
CLI.delete-job.shortDescription
=
Cancella un job
CLI.disable-job.shortDescription
=
Disabilita un job
CLI.enable-job.shortDescription
=
Abilita un job
CLI.delete-node.shortDescription
=
Cancella un nodo
CLI.disconnect-node.shortDescription
=
Disconnects from a node
CLI.connect-node.shortDescription
=
Riconnettersi ad un nodo
CLI.online-node.shortDescription
=
Resume using a node for performing builds, to cancel out the earlier "offline-node" command.
...
...
core/src/main/resources/hudson/model/Messages_ja.properties
浏览文件 @
67e4e88b
...
...
@@ -323,7 +323,6 @@ CLI.clear-queue.shortDescription=\u30d3\u30eb\u30c9\u30ad\u30e5\u30fc\u3092\u30a
CLI.delete-job.shortDescription
=
\u
30b8
\u
30e7
\u
30d6
\u3092\u
524a
\u9664\u3057\u
307e
\u3059\u3002
CLI.disable-job.shortDescription
=
\u
30b8
\u
30e7
\u
30d6
\u3092\u7121\u
52b9
\u5316\u3057\u
307e
\u3059\u3002
CLI.enable-job.shortDescription
=
\u
30b8
\u
30e7
\u
30d6
\u3092\u6709\u
52b9
\u5316\u3057\u
307e
\u3059\u3002
CLI.delete-node.shortDescription
=
\u
30ce
\u
30fc
\u
30c9
\u3092\u
524a
\u9664\u3057\u
307e
\u3059\u3002
CLI.disconnect-node.shortDescription
=
\u
30ce
\u
30fc
\u
30c9
\u3068\u
306e
\u
63a5
\u
7d9a
\u3092\u5207\u
65ad
\u3057\u
307e
\u3059\u3002
CLI.connect-node.shortDescription
=
\u
30ce
\u
30fc
\u
30c9
\u3068\u
518d
\u
63a5
\u
7d9a
\u3057\u
307e
\u3059\u3002
CLI.online-node.shortDescription
=
\u
76f4
\u
524d
\u
306b
\u
5b9f
\u
884c
\u3057\u
305f"online-node"
\u
30b3
\u
30de
\u
30f3
\u
30c9
\u3092\u
53d6
\u
308a
\u
6d88
\u3057\u3001\u
30d3
\u
30eb
\u
30c9
\u3092\u
5b9f
\u
884c
\u3059\u
308b
\u
30ce
\u
30fc
\u
30c9
\u
306e
\u
4f7f
\u7528\u3092\u
518d
\u
958b
\u3057\u
307e
\u3059\u3002
...
...
core/src/main/resources/hudson/model/Messages_pt_BR.properties
浏览文件 @
67e4e88b
...
...
@@ -278,8 +278,6 @@ View.ConfigurePermission.Description=Permite aos usu\u00e1rios configurar as vie
AbstractProject.NewBuildForWorkspace
=
Agendando uma novo build para obter um novo workspace
# {0} doesn''t have label {1}
Node.LabelMissing
=
R
\u
00f3tulo n
\u
00e3o encontrado
# Deletes a node
CLI.delete-node.shortDescription
=
Remover o n
\u
00f3
# {0} is reserved for jobs tied to it
Node.BecauseNodeIsReserved
=
{0} foi reservado para trabalhos vinculados
# Started by remote host {0} with note: {1}
...
...
core/src/main/resources/hudson/model/Messages_zh_CN.properties
浏览文件 @
67e4e88b
...
...
@@ -66,7 +66,6 @@ CLI.clear-queue.shortDescription=Clears the build queue
CLI.delete-job.shortDescription
=
Deletes a job
CLI.disable-job.shortDescription
=
Disables a job
CLI.enable-job.shortDescription
=
Enables a job
CLI.delete-node.shortDescription
=
Deletes a node
CLI.disconnect-node.shortDescription
=
Disconnects from a node
CLI.connect-node.shortDescription
=
Reconnect to a node
CLI.online-node.shortDescription
=
Resume using a node for performing builds, to cancel out the earlier "offline-node" command.
...
...
core/src/main/resources/hudson/model/Messages_zh_TW.properties
浏览文件 @
67e4e88b
...
...
@@ -85,7 +85,6 @@ CLI.clear-queue.shortDescription=\u6e05\u9664\u5efa\u7f6e\u4f47\u5217\u3002
CLI.delete-job.shortDescription
=
\u
522a
\u9664\u
4f5c
\u
696d
\u3002
CLI.disable-job.shortDescription
=
\u
505c
\u7528\u
4f5c
\u
696d
\u3002
CLI.enable-job.shortDescription
=
\u
555f
\u7528\u
4f5c
\u
696d
\u3002
CLI.delete-node.shortDescription
=
\u
522a
\u9664\u6307\u
5b9a
\u
7bc0
\u
9ede
\u3002
CLI.disconnect-node.shortDescription
=
\u
4e2d
\u
65b7
\u8207\u6307\u
5b9a
\u
7bc0
\u
9ede
\u7684\u9023\u
7dda
\u3002
CLI.connect-node.shortDescription
=
\u9023\u
7dda
\u5230\u6307\u
5b9a
\u
7bc0
\u
9ede
\u3002
CLI.online-node.shortDescription
=
\u
7e7c
\u
7e8c
\u
4f7f
\u7528\u6307\u
5b9a
\u
7bc0
\u
9ede
\u
4f86
\u
5efa
\u
7f6e
\u
ff0c
\u
53d6
\u
6d88
\u5148\u
524d
\u7684
"offline-node"
\u6307\u
4ee4
\u3002
...
...
test/src/test/java/hudson/cli/DeleteNodeCommandTest.java
0 → 100644
浏览文件 @
67e4e88b
/*
* The MIT License
*
* Copyright 2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* @author pjanouse
* @since TODO
*/
package
hudson.cli
;
import
hudson.model.Computer
;
import
hudson.slaves.DumbSlave
;
import
hudson.slaves.NodeProperty
;
import
jenkins.model.Jenkins
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
java.util.ArrayList
;
import
static
hudson
.
cli
.
CLICommandInvoker
.
Matcher
.*;
import
static
org
.
hamcrest
.
MatcherAssert
.
assertThat
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
static
org
.
hamcrest
.
Matchers
.
nullValue
;
import
static
org
.
hamcrest
.
Matchers
.
notNullValue
;
public
class
DeleteNodeCommandTest
{
private
CLICommandInvoker
command
;
@Rule
public
final
JenkinsRule
j
=
new
JenkinsRule
();
@Before
public
void
setUp
()
{
command
=
new
CLICommandInvoker
(
j
,
new
DeleteNodeCommand
());
}
@Test
public
void
deleteNodeShouldFailWithoutNodeDeletePermission
()
throws
Exception
{
j
.
createSlave
(
"aNode"
,
""
,
null
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Jenkins
.
READ
)
.
invokeWithArgs
(
"aNode"
)
;
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
.
stderr
(),
containsString
(
"user is missing the Slave/Delete permission"
));
}
@Test
public
void
deleteNodeShouldSucceed
()
throws
Exception
{
j
.
createSlave
(
"aNode"
,
""
,
null
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
DELETE
,
Jenkins
.
READ
)
.
invokeWithArgs
(
"aNode"
)
;
assertThat
(
result
,
succeededSilently
());
assertThat
(
j
.
jenkins
.
getNode
(
"aNode"
),
nullValue
());
}
@Test
public
void
deleteNodeShouldFailIfNodeDoesNotExist
()
{
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
DELETE
,
Jenkins
.
READ
)
.
invokeWithArgs
(
"never_created"
)
;
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
.
stderr
(),
containsString
(
"No such node 'never_created'"
));
}
@Test
public
void
deleteNodeManyShouldSucceed
()
throws
Exception
{
j
.
createSlave
(
"aNode1"
,
""
,
null
);
j
.
createSlave
(
"aNode2"
,
""
,
null
);
j
.
createSlave
(
"aNode3"
,
""
,
null
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
DELETE
,
Jenkins
.
READ
)
.
invokeWithArgs
(
"aNode1"
,
"aNode2"
,
"aNode3"
);
assertThat
(
result
,
succeededSilently
());
assertThat
(
j
.
jenkins
.
getView
(
"aNode1"
),
nullValue
());
assertThat
(
j
.
jenkins
.
getView
(
"aNode2"
),
nullValue
());
assertThat
(
j
.
jenkins
.
getView
(
"aNode3"
),
nullValue
());
}
@Test
public
void
deleteNodeManyShouldFailIfANodeDoesNotExist
()
throws
Exception
{
j
.
createSlave
(
"aNode1"
,
""
,
null
);
j
.
createSlave
(
"aNode2"
,
""
,
null
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
DELETE
,
Jenkins
.
READ
)
.
invokeWithArgs
(
"aNode1"
,
"aNode2"
,
"never_created"
);
assertThat
(
result
,
failedWith
(-
1
));
assertThat
(
result
,
hasNoStandardOutput
());
assertThat
(
result
.
stderr
(),
containsString
(
"No such node 'never_created'"
));
assertThat
(
j
.
jenkins
.
getView
(
"aNode1"
),
nullValue
());
assertThat
(
j
.
jenkins
.
getView
(
"aNode2"
),
nullValue
());
assertThat
(
j
.
jenkins
.
getView
(
"never_created"
),
nullValue
());
}
@Test
public
void
deleteNodeManyShouldSucceedEvenANodeIsSpecifiedTwice
()
throws
Exception
{
j
.
createSlave
(
"aNode1"
,
""
,
null
);
j
.
createSlave
(
"aNode2"
,
""
,
null
);
final
CLICommandInvoker
.
Result
result
=
command
.
authorizedTo
(
Computer
.
DELETE
,
Jenkins
.
READ
)
.
invokeWithArgs
(
"aNode1"
,
"aNode2"
,
"aNode1"
);
assertThat
(
result
,
succeededSilently
());
assertThat
(
j
.
jenkins
.
getView
(
"aNode1"
),
nullValue
());
assertThat
(
j
.
jenkins
.
getView
(
"aNode2"
),
nullValue
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录