Package org.jvnet.hudson.test
Class InboundAgentRule
java.lang.Object
org.junit.rules.ExternalResource
org.jvnet.hudson.test.InboundAgentRule
- All Implemented Interfaces:
org.junit.rules.TestRule
public final class InboundAgentRule
extends org.junit.rules.ExternalResource
Manages inbound agents.
While these run on the local host, they are launched outside of Jenkins.
To avoid flakiness when tearing down the test, ensure that the agent has gone offline with:
Slave agent = inboundAgents.createAgent(r, […]); try { […] } finally { inboundAgents.stop(r, agent.getNodeName()); }
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final record
static final class
The options used to (re)start an inbound agent. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
after()
hudson.model.Slave
createAgent
(JenkinsRule r, String name) Creates, attaches, and starts a new inbound agent.hudson.model.Slave
createAgent
(JenkinsRule r, InboundAgentRule.Options options) Creates, attaches, and optionally starts a new inbound agent.void
createAgent
(RealJenkinsRule rr, String name) void
createAgent
(RealJenkinsRule rr, InboundAgentRule.Options options) boolean
Checks whether an existing inbound agent process is currently running.void
start
(InboundAgentRule.AgentArguments agentArguments, InboundAgentRule.Options options) void
start
(JenkinsRule r, String name) (Re-)starts an existing inbound agent.void
start
(JenkinsRule r, InboundAgentRule.Options options) (Re-)starts an existing inbound agent.void
start
(RealJenkinsRule r, InboundAgentRule.Options options) (Re-)starts an existing inbound agent.void
Stops an existing inbound agent.void
stop
(JenkinsRule r, String name) Stop an existing inbound agent and wait for it to go offline.void
stop
(RealJenkinsRule rjr, String name) Stop an existing inbound agent and wait for it to go offline.Methods inherited from class org.junit.rules.ExternalResource
apply, before
-
Constructor Details
-
InboundAgentRule
public InboundAgentRule()
-
-
Method Details
-
createAgent
public hudson.model.Slave createAgent(@NonNull JenkinsRule r, @CheckForNull String name) throws Exception Creates, attaches, and starts a new inbound agent.- Parameters:
name
- an optionalSlave.getNodeName()
- Throws:
Exception
-
createAgent
public hudson.model.Slave createAgent(@NonNull JenkinsRule r, InboundAgentRule.Options options) throws Exception Creates, attaches, and optionally starts a new inbound agent.- Parameters:
options
- the options- Throws:
Exception
-
createAgent
- Throws:
Throwable
-
createAgent
public void createAgent(@NonNull RealJenkinsRule rr, InboundAgentRule.Options options) throws Throwable - Throws:
Throwable
-
start
(Re-)starts an existing inbound agent.- Throws:
Exception
-
start
(Re-)starts an existing inbound agent.- Throws:
Exception
-
start
(Re-)starts an existing inbound agent.- Throws:
Throwable
-
start
public void start(InboundAgentRule.AgentArguments agentArguments, InboundAgentRule.Options options) throws Exception - Throws:
Exception
-
stop
Stop an existing inbound agent and wait for it to go offline.- Throws:
InterruptedException
-
stop
Stop an existing inbound agent and wait for it to go offline.- Throws:
Throwable
-
stop
Stops an existing inbound agent. You need only call this to simulate an agent crash, followed bystart(org.jvnet.hudson.test.JenkinsRule, java.lang.String)
.- Throws:
InterruptedException
-
isAlive
Checks whether an existing inbound agent process is currently running. (This is distinct from whether Jenkins considers the computer to be connected.) -
after
protected void after()- Overrides:
after
in classorg.junit.rules.ExternalResource
-