Class SlaveController
- All Implemented Interfaces:
Closeable
,AutoCloseable
,AutoCleaned
,CapybaraPortingLayer
- Direct Known Subclasses:
LocalSlaveController
Jenkins supports different ways of launching slaves, and sometimes this affects behaviours of plugins. This abstraction hides the details of where the slaves are running (local machine? EC2? Docker?) and how slaves are hooked up to Jenkins.
Test authors write tests by injecting SlaveController
and calling install(org.jenkinsci.test.acceptance.po.Jenkins)
.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
CapybaraPortingLayerImpl.Finder<R>, CapybaraPortingLayerImpl.Resolver
-
Field Summary
Fields inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
driver, injector, LABEL_TO_INPUT_XPATH, time
Fields inherited from interface org.jenkinsci.test.acceptance.po.CapybaraPortingLayer
by
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
Convey the intention that this machine is no longer needed.Uses the given page object to create a new node and connect the slave to that Jenkins instance.final void
restart()
Just a convenience method for stop+start.Future<?>
start()
Reconnects a previously stopped slave.void
stop()
Stops the slave from the slave side, for those slave launch methods that support it.Methods inherited from class org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
all, blur, check, check, check, choose, clickButton, clickLink, confirmAlert, elasticSleep, executeScript, fillIn, find, findCaption, findCaption, findIfNotVisible, getCurrentUrl, getCurrentUrlWithFragment, getElement, getPageContent, getPageSource, getPageSource, getPath, handleAlert, isHiddenOrStale, isStale, last, lastIfNotVisible, newInstance, resource, runThenConfirmAlert, runThenConfirmAlert, runThenHandleAlert, runThenHandleAlert, runThenHandleDialog, sleep, visit, waitFor, waitFor, waitFor, waitFor, waitFor, waitForCond, waitForCond
-
Constructor Details
-
SlaveController
protected SlaveController()
-
-
Method Details
-
install
Uses the given page object to create a new node and connect the slave to that Jenkins instance.Since the actual launch of slave can take some time and it often involves a busy loop until the slave gets fully launched, this method returns
Future
and it can return before the slave is fully connected.However, this does not mean the setup process can run entirely in another thread, as
WebDriver
do not support concurrent use by multiple threads.For example, SSH slaves might synchronously interact with Jenkins to create a slave, and let Jenkins begin connecting to it, but this method would return without waiting for the slave to fully come online. Then later when
Future.get()
method is invoked, it'll check back the slave status and block until the slave becomes online.This design improves the speed of connecting multiple slaves.
TODO: for EC2 based providers where there's also another initial delay of allocating a new machine, this abstraction doesn't hide all the latencies sufficiently.
When the
Future.get()
method returns successfully, the slave is fully online and ready to use. -
stop
public void stop()Stops the slave from the slave side, for those slave launch methods that support it.Most notably JNLP slaves can control their own lifecycles, and for those slaves this method lets you disconnect this slave. A stopped slave can be later reconnected via
start()
. -
start
Reconnects a previously stopped slave. -
restart
public final void restart()Just a convenience method for stop+start. -
close
Convey the intention that this machine is no longer needed. The implementation will releases this machine / recycle the machine, etc.Once this method is called, no other methods should be called.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-