Class LocalController
- java.lang.Object
-
- org.jenkinsci.test.acceptance.controller.JenkinsController
-
- org.jenkinsci.test.acceptance.controller.LocalController
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,IJenkinsController
,AutoCleaned
,LogListenable
- Direct Known Subclasses:
JBossController
,TomcatController
,WinstoneController
,WinstoneDockerController
public abstract class LocalController extends JenkinsController implements LogListenable
Abstract base class for those JenkinsController that runs the JVM locally on the same box as the test harness- Author:
- Vivek Pandey
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LocalController.LocalFactoryImpl
Partial implementation ofJenkinsControllerFactory
for subtypes.
-
Field Summary
Fields Modifier and Type Field Description protected File
jenkinsHome
JENKINS_HOME directory for jenkins.war to be launched.protected JenkinsLogWatcher
logWatcher
protected org.jenkinsci.utils.process.ProcessInputStream
process
protected File
war
jenkins.war.-
Fields inherited from class org.jenkinsci.test.acceptance.controller.JenkinsController
isQuite, STARTUP_TIMEOUT, WORKSPACE
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
LocalController(com.google.inject.Injector i)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addLogListener(LogListener l)
protected Map<String,String>
commonLaunchEnv()
Common environment variables to put toCommandBuilder
when launching Jenkins.void
diagnose(Throwable cause)
Perform controller specific diagnostics for test failure.File
getJavaHome()
File
getJenkinsHome()
File
getSlaveJarPath()
Deprecated.Will not work correctly in Jenkins 2.33 and later.protected String
getSutHostName()
Hostname to use when accessing Jenkins.boolean
isRunInstallWizard()
protected void
onReady()
Called when the Jenkins instance is ready to be used.void
populateJenkinsHome(byte[] _template, boolean clean)
Populates the Jenkins Home with the specified ZIP template.void
postConstruct(com.google.inject.Injector injector)
Called whenJenkinsController
is pulled into a world prior toJenkinsController.start()
void
removeLogListener(LogListener l)
void
setRunInstallWizard(boolean runInstallWizard)
Set the flag to run the install wizard.void
startNow()
Synchronously start Jenkins instance until it starts responding to the specified URL.abstract org.jenkinsci.utils.process.ProcessInputStream
startProcess()
void
stopNow()
Synchronously shutdown Jenkins instance.void
tearDown()
Assuming the instance had already stopped, destroy JENKINS_HOME and release resources used by Jenkins.-
Methods inherited from class org.jenkinsci.test.acceptance.controller.JenkinsController
close, getInitialCredentials, getLogId, getLogPrinter, getUrl, isRunning, restart, start, stop
-
-
-
-
Field Detail
-
war
@Inject @Named("jenkins.war") protected File war
jenkins.war. Subject under test.
-
jenkinsHome
protected final File jenkinsHome
JENKINS_HOME directory for jenkins.war to be launched.
-
process
protected org.jenkinsci.utils.process.ProcessInputStream process
-
logWatcher
protected JenkinsLogWatcher logWatcher
-
-
Method Detail
-
postConstruct
public void postConstruct(com.google.inject.Injector injector)
Description copied from class:JenkinsController
Called whenJenkinsController
is pulled into a world prior toJenkinsController.start()
- Overrides:
postConstruct
in classJenkinsController
-
addLogListener
public void addLogListener(LogListener l)
- Specified by:
addLogListener
in interfaceLogListenable
-
removeLogListener
public void removeLogListener(LogListener l)
- Specified by:
removeLogListener
in interfaceLogListenable
-
getSlaveJarPath
@Deprecated public File getSlaveJarPath()
Deprecated.Will not work correctly in Jenkins 2.33 and later. Apparently unused anyway.
-
getJenkinsHome
public File getJenkinsHome()
-
populateJenkinsHome
public void populateJenkinsHome(byte[] _template, boolean clean) throws IOException
Description copied from interface:IJenkinsController
Populates the Jenkins Home with the specified ZIP template. Jenkins will not be restarted, so if the content would require a restart you have to do this yourself.- Specified by:
populateJenkinsHome
in interfaceIJenkinsController
- Parameters:
_template
- The template (ZIP format).clean
- iftrue
then the home will be wiped clean before the template is applied. If false then the template will simply overwrite the existing (if any) home.- Throws:
IOException
-
getJavaHome
public File getJavaHome()
-
startProcess
public abstract org.jenkinsci.utils.process.ProcessInputStream startProcess() throws IOException
- Throws:
IOException
-
startNow
public void startNow() throws IOException
Description copied from class:JenkinsController
Synchronously start Jenkins instance until it starts responding to the specified URL.- Specified by:
startNow
in classJenkinsController
- Throws:
IOException
-
onReady
protected void onReady() throws IOException
Called when the Jenkins instance is ready to be used.- Throws:
IOException
-
stopNow
public void stopNow() throws IOException
Description copied from class:JenkinsController
Synchronously shutdown Jenkins instance.This method must leave JENKINS_HOME intact so that it can be started later. To really delete the data and clean up, see
JenkinsController.tearDown()
.- Specified by:
stopNow
in classJenkinsController
- Throws:
IOException
-
diagnose
public void diagnose(Throwable cause)
Description copied from class:JenkinsController
Perform controller specific diagnostics for test failure. Defaults to no-op.- Overrides:
diagnose
in classJenkinsController
- Parameters:
cause
- Failure cause
-
tearDown
public void tearDown()
Description copied from class:JenkinsController
Assuming the instance had already stopped, destroy JENKINS_HOME and release resources used by Jenkins.- Specified by:
tearDown
in classJenkinsController
-
commonLaunchEnv
@NonNull protected Map<String,String> commonLaunchEnv()
Common environment variables to put toCommandBuilder
when launching Jenkins.
-
getSutHostName
protected String getSutHostName()
Hostname to use when accessing Jenkins.Useful to override with public hostname/IP when external clients needs to talk back to Jenkins.
- Returns:
- "127.0.0.1" unless overridden via JENKINS_LOCAL_HOSTNAME env var.
-
isRunInstallWizard
public boolean isRunInstallWizard()
- Returns:
- true if the install wizard is going to be run
-
setRunInstallWizard
public void setRunInstallWizard(boolean runInstallWizard)
Set the flag to run the install wizard.- Parameters:
runInstallWizard
- -true
to run the install wizard
-
-