Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
jenkins
提交
69dcf231
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,发现更多精彩内容 >>
提交
69dcf231
编写于
1月 06, 2020
作者:
J
Jeff Thompson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add back in AgentProtocolTest.
Add back what was actually being used and remains.
上级
50921ccb
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
317 addition
and
0 deletion
+317
-0
test/src/test/java/jenkins/AgentProtocolTest.java
test/src/test/java/jenkins/AgentProtocolTest.java
+94
-0
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol.java
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol.java
+58
-0
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol2.java
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol2.java
+59
-0
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol3.java
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol3.java
+59
-0
test/src/test/resources/jenkins/AgentProtocolTest/config.xml
test/src/test/resources/jenkins/AgentProtocolTest/config.xml
+47
-0
未找到文件。
test/src/test/java/jenkins/AgentProtocolTest.java
0 → 100644
浏览文件 @
69dcf231
/*
* The MIT License
*
* Copyright (c) 2017 CloudBees, 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
jenkins
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
javax.annotation.CheckForNull
;
import
jenkins.model.Jenkins
;
import
org.apache.commons.lang.StringUtils
;
import
static
org
.
junit
.
Assert
.
fail
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.jvnet.hudson.test.Issue
;
import
org.jvnet.hudson.test.JenkinsRule
;
import
org.jvnet.hudson.test.recipes.LocalData
;
/**
* Tests for {@link AgentProtocol}.
*
* @author Oleg Nenashev
*/
public
class
AgentProtocolTest
{
@Rule
public
JenkinsRule
j
=
new
JenkinsRule
();
@Test
@LocalData
@Issue
(
"JENKINS-45841"
)
public
void
testShouldNotOverrideUserConfiguration
()
throws
Exception
{
assertEnabled
(
"JNLP-connect"
,
"JNLP3-connect"
);
assertDisabled
(
"JNLP2-connect"
,
"JNLP4-connect"
);
assertProtocols
(
true
,
"System protocols should be always enabled"
,
"Ping"
);
}
private
void
assertEnabled
(
String
...
protocolNames
)
throws
AssertionError
{
assertProtocols
(
true
,
null
,
protocolNames
);
}
private
void
assertDisabled
(
String
...
protocolNames
)
throws
AssertionError
{
assertProtocols
(
false
,
null
,
protocolNames
);
}
private
void
assertProtocols
(
boolean
shouldBeEnabled
,
@CheckForNull
String
why
,
String
...
protocolNames
)
{
assertProtocols
(
j
.
jenkins
,
shouldBeEnabled
,
why
,
protocolNames
);
}
public
static
void
assertProtocols
(
Jenkins
jenkins
,
boolean
shouldBeEnabled
,
@CheckForNull
String
why
,
String
...
protocolNames
)
throws
AssertionError
{
Set
<
String
>
agentProtocols
=
jenkins
.
getAgentProtocols
();
List
<
String
>
failedChecks
=
new
ArrayList
<>();
for
(
String
protocol
:
protocolNames
)
{
if
(
shouldBeEnabled
&&
!(
agentProtocols
.
contains
(
protocol
)))
{
failedChecks
.
add
(
protocol
);
}
if
(!
shouldBeEnabled
&&
agentProtocols
.
contains
(
protocol
))
{
failedChecks
.
add
(
protocol
);
}
}
if
(!
failedChecks
.
isEmpty
())
{
String
message
=
String
.
format
(
"Protocol(s) are not %s: %s. %sEnabled protocols: %s"
,
shouldBeEnabled
?
"enabled"
:
"disabled"
,
StringUtils
.
join
(
failedChecks
,
','
),
why
!=
null
?
"Reason: "
+
why
+
". "
:
""
,
StringUtils
.
join
(
agentProtocols
,
','
));
fail
(
message
);
}
}
}
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol.java
0 → 100644
浏览文件 @
69dcf231
/*
* The MIT License
*
* Copyright (c) 2020 CloudBees, 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
jenkins
;
import
hudson.Extension
;
import
java.net.Socket
;
import
org.jenkinsci.Symbol
;
@Extension
@Symbol
(
"jnlp"
)
public
class
TestJnlpSlaveAgentProtocol
extends
AgentProtocol
{
@Override
public
boolean
isOptIn
()
{
return
true
;
}
@Override
public
boolean
isDeprecated
()
{
return
true
;
}
@Override
public
String
getName
()
{
return
"JNLP-connect"
;
}
@Override
public
String
getDisplayName
()
{
return
"JNLP-connect"
;
}
@Override
public
void
handle
(
Socket
socket
)
{
}
}
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol2.java
0 → 100644
浏览文件 @
69dcf231
/*
* The MIT License
*
* Copyright (c) 2020 CloudBees, 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
jenkins
;
import
hudson.Extension
;
import
org.jenkinsci.Symbol
;
import
java.net.Socket
;
@Extension
@Symbol
(
"jnlp2"
)
public
class
TestJnlpSlaveAgentProtocol2
extends
AgentProtocol
{
@Override
public
boolean
isOptIn
()
{
return
true
;
}
@Override
public
boolean
isDeprecated
()
{
return
true
;
}
@Override
public
String
getName
()
{
return
"JNLP2-connect"
;
}
@Override
public
String
getDisplayName
()
{
return
"JNLP2-connect"
;
}
@Override
public
void
handle
(
Socket
socket
)
{
}
}
test/src/test/java/jenkins/TestJnlpSlaveAgentProtocol3.java
0 → 100644
浏览文件 @
69dcf231
/*
* The MIT License
*
* Copyright (c) 2020 CloudBees, 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
jenkins
;
import
hudson.Extension
;
import
org.jenkinsci.Symbol
;
import
java.net.Socket
;
@Extension
@Symbol
(
"jnlp3"
)
public
class
TestJnlpSlaveAgentProtocol3
extends
AgentProtocol
{
@Override
public
boolean
isOptIn
()
{
return
true
;
}
@Override
public
boolean
isDeprecated
()
{
return
true
;
}
@Override
public
String
getName
()
{
return
"JNLP3-connect"
;
}
@Override
public
String
getDisplayName
()
{
return
"JNLP3-connect"
;
}
@Override
public
void
handle
(
Socket
socket
)
{
}
}
test/src/test/resources/jenkins/AgentProtocolTest/config.xml
0 → 100644
浏览文件 @
69dcf231
<?xml version='1.0' encoding='UTF-8'?>
<hudson>
<disabledAdministrativeMonitors/>
<version>
1.0
</version>
<numExecutors>
2
</numExecutors>
<mode>
NORMAL
</mode>
<useSecurity>
true
</useSecurity>
<authorizationStrategy
class=
"hudson.security.AuthorizationStrategy$Unsecured"
/>
<securityRealm
class=
"hudson.security.SecurityRealm$None"
/>
<disableRememberMe>
false
</disableRememberMe>
<projectNamingStrategy
class=
"jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"
/>
<workspaceDir>
${ITEM_ROOTDIR}/workspace
</workspaceDir>
<buildsDir>
${ITEM_ROOTDIR}/builds
</buildsDir>
<markupFormatter
class=
"hudson.markup.EscapedMarkupFormatter"
/>
<jdks/>
<viewsTabBar
class=
"hudson.views.DefaultViewsTabBar"
/>
<myViewsTabBar
class=
"hudson.views.DefaultMyViewsTabBar"
/>
<clouds/>
<scmCheckoutRetryCount>
0
</scmCheckoutRetryCount>
<views>
<hudson.model.AllView>
<owner
class=
"hudson"
reference=
"../../.."
/>
<name>
all
</name>
<filterExecutors>
false
</filterExecutors>
<filterQueue>
false
</filterQueue>
<properties
class=
"hudson.model.View$PropertyList"
/>
</hudson.model.AllView>
</views>
<primaryView>
all
</primaryView>
<slaveAgentPort>
0
</slaveAgentPort>
<!-- YOLO: unstable configuration -->
<enabledAgentProtocols>
<!-- Since removed, but may as well test robustness of load: -->
<string>
CLI-connect
</string>
<string>
JNLP-connect
</string>
<string>
JNLP3-connect
</string>
</enabledAgentProtocols>
<disabledAgentProtocols>
<string>
JNLP4-connect
</string>
<string>
JNLP2-connect
</string>
<!-- Ditto: -->
<string>
CLI2-connect
</string>
</disabledAgentProtocols>
<label></label>
<nodeProperties/>
<globalNodeProperties/>
</hudson>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录