Package org.jvnet.hudson.test.fixtures
Class InboundAgentFixture
java.lang.Object
org.jvnet.hudson.test.fixtures.InboundAgentFixture
Manages inbound agents.
While these run on the local host, they are launched outside of Jenkins.
Usage:
private static final InboundAgentFixture FIXTURE = InboundAgentFixture.newBuilder().build();
public void method() {
try {
Slave agent = FIXTURE.createAgent(r, […]);
[…]
} finally {
FIXTURE.tearDown();
}
}
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());
}- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classArgument for an Agent.static classThe options used to (re)start an inbound agent. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionhudson.model.SlavecreateAgent(JenkinsRule r, String name) Creates, attaches, and starts a new inbound agent.hudson.model.SlavecreateAgent(JenkinsRule r, InboundAgentFixture.Options options) Creates, attaches, and optionally starts a new inbound agent.static String[]createAgentRJR(JenkinsRule r, InboundAgentFixture.Options options) getAgentArguments(JenkinsRule r, String name) getJars()booleanChecks whether an existing inbound agent process is currently running.voidstart(InboundAgentFixture.AgentArguments agentArguments, InboundAgentFixture.Options options) voidstart(InboundAgentFixture.AgentArguments agentArguments, InboundAgentFixture.Options options, boolean stop) voidstart(JenkinsRule r, String name) (Re-)starts an existing inbound agent.voidstart(JenkinsRule r, InboundAgentFixture.Options options) (Re-)starts an existing inbound agent.voidStops an existing inbound agent.voidstop(JenkinsRule r, String name) Stop an existing inbound agent and wait for it to go offline.voidtearDown()static voidwaitForAgentOffline(JenkinsRule r, String name) static voidwaitForAgentOnline(JenkinsRule r, String name, Map<String, Level> loggers)
-
Constructor Details
-
InboundAgentFixture
public InboundAgentFixture()
-
-
Method Details
-
getWorkDirs
-
getJars
-
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, InboundAgentFixture.Options options) throws Exception Creates, attaches, and optionally starts a new inbound agent.- Parameters:
options- the options- Throws:
Exception
-
start
(Re-)starts an existing inbound agent.- Throws:
Exception
-
start
(Re-)starts an existing inbound agent.- Throws:
Exception
-
start
public void start(InboundAgentFixture.AgentArguments agentArguments, InboundAgentFixture.Options options) throws Exception - Throws:
Exception
-
start
public void start(InboundAgentFixture.AgentArguments agentArguments, InboundAgentFixture.Options options, boolean stop) throws IOException - Throws:
IOException
-
stop
Stop an existing inbound agent and wait for it to go offline.- Throws:
InterruptedException
-
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). -
isAlive
Checks whether an existing inbound agent process is currently running. (This is distinct from whether Jenkins considers the computer to be connected.) -
tearDown
public void tearDown() -
getAgentArguments
public static InboundAgentFixture.AgentArguments getAgentArguments(JenkinsRule r, String name) throws IOException - Throws:
IOException
-
waitForAgentOnline
public static void waitForAgentOnline(JenkinsRule r, String name, Map<String, Level> loggers) throws Exception- Throws:
Exception
-
waitForAgentOffline
- Throws:
InterruptedException
-
createAgentRJR
public static String[] createAgentRJR(JenkinsRule r, InboundAgentFixture.Options options) throws Throwable - Throws:
Throwable
-