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.ExternalResourceManages 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
Nested Classes Modifier and Type Class Description static classInboundAgentRule.AgentArgumentsstatic classInboundAgentRule.OptionsThe options used to (re)start an inbound agent.
-
Constructor Summary
Constructors Constructor Description InboundAgentRule()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafter()hudson.model.SlavecreateAgent(JenkinsRule r, String name)Creates, attaches, and starts a new inbound agent.hudson.model.SlavecreateAgent(JenkinsRule r, InboundAgentRule.Options options)Creates, attaches, and optionally starts a new inbound agent.voidcreateAgent(RealJenkinsRule rr, String name)voidcreateAgent(RealJenkinsRule rr, InboundAgentRule.Options options)booleanisAlive(String name)Checks whether an existing inbound agent process is currently running.voidstart(InboundAgentRule.AgentArguments agentArguments, InboundAgentRule.Options options)voidstart(JenkinsRule r, String name)(Re-)starts an existing inbound agent.voidstart(JenkinsRule r, InboundAgentRule.Options options)(Re-)starts an existing inbound agent.voidstart(RealJenkinsRule r, InboundAgentRule.Options options)(Re-)starts an existing inbound agent.voidstop(String name)Stops an existing inbound agent.voidstop(JenkinsRule r, String name)Stop an existing inbound agent and wait for it to go offline.voidstop(RealJenkinsRule rjr, String name)Stop an existing inbound agent and wait for it to go offline.
-
-
-
Method Detail
-
createAgent
public hudson.model.Slave createAgent(@NonNull JenkinsRule r, @CheckForNull String name) throws ExceptionCreates, 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 ExceptionCreates, attaches, and optionally starts a new inbound agent.- Parameters:
options- the options- Throws:
Exception
-
createAgent
public void createAgent(@NonNull RealJenkinsRule rr, @CheckForNull String name) throws Throwable- Throws:
Throwable
-
createAgent
public void createAgent(@NonNull RealJenkinsRule rr, InboundAgentRule.Options options) throws Throwable- Throws:
Throwable
-
start
public void start(@NonNull JenkinsRule r, @NonNull String name) throws Exception(Re-)starts an existing inbound agent.- Throws:
Exception
-
start
public void start(@NonNull JenkinsRule r, InboundAgentRule.Options options) throws Exception(Re-)starts an existing inbound agent.- Throws:
Exception
-
start
public void start(@NonNull RealJenkinsRule r, InboundAgentRule.Options options) throws Throwable(Re-)starts an existing inbound agent.- Throws:
Throwable
-
start
public void start(InboundAgentRule.AgentArguments agentArguments, InboundAgentRule.Options options) throws Exception
- Throws:
Exception
-
stop
public void stop(@NonNull JenkinsRule r, @NonNull String name) throws InterruptedExceptionStop an existing inbound agent and wait for it to go offline.- Throws:
InterruptedException
-
stop
public void stop(@NonNull RealJenkinsRule rjr, @NonNull String name) throws ThrowableStop an existing inbound agent and wait for it to go offline.- Throws:
Throwable
-
stop
public void stop(@NonNull String name) throws InterruptedExceptionStops 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
public boolean isAlive(String name)
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:
afterin classorg.junit.rules.ExternalResource
-
-