Class SlaveController

java.lang.Object
org.jenkinsci.test.acceptance.po.CapybaraPortingLayerImpl
org.jenkinsci.test.acceptance.slave.SlaveController
All Implemented Interfaces:
Closeable, AutoCloseable, AutoCleaned, CapybaraPortingLayer
Direct Known Subclasses:
LocalSlaveController

public abstract class SlaveController extends CapybaraPortingLayerImpl implements Closeable, AutoCleaned
Controls where/how to run slaves.

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:
  • Constructor Details

    • SlaveController

      protected SlaveController()
  • Method Details

    • install

      public abstract Future<Slave> install(Jenkins jenkinsToInstallTo)
      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

      public Future<?> start()
      Reconnects a previously stopped slave.
    • restart

      public final void restart()
      Just a convenience method for stop+start.
    • close

      public abstract void close() throws IOException
      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 interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException