Skip to content
Permalink
Browse files
…configuration under jenkins 'manager jenkins' is not saved.

2. Remove deprecated and unused parameters from Configure System page: -rcDebug, -rcLog
3. Add parameter -browserTimeout
4. Set correct description for parameter -timeout (it was changed since selenium v2.21)
5. Remove code which terminates starting selenium node in #startSeleniumNode() in case getHostName() returns null. Reason: node hostname can be manually configured on node in case it is non-discoverable from master. In such case node will successfully starts.
  • Loading branch information
kool79 committed Nov 17, 2014
1 parent 9679c4e commit 76f88f59284d97d5edacca36ddaa8282404b76db
@@ -44,6 +44,7 @@
import hudson.plugins.selenium.configuration.global.hostname.HostnameResolver;
import hudson.plugins.selenium.configuration.global.hostname.HostnameResolverDescriptor;
import hudson.plugins.selenium.configuration.global.hostname.JenkinsRootHostnameResolver;
import hudson.plugins.selenium.configuration.global.hostname.StaticHostnameResolver;
import hudson.plugins.selenium.configuration.global.matcher.SeleniumConfigurationMatcher;
import hudson.plugins.selenium.configuration.global.matcher.SeleniumConfigurationMatcher.MatcherDescriptor;
import hudson.plugins.selenium.configuration.global.matcher.MatchAllMatcher;
@@ -80,6 +81,8 @@

import jenkins.model.Jenkins;

import net.sf.json.JSONObject;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;
import org.kohsuke.stapler.StaplerRequest;
@@ -90,13 +93,15 @@
import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.RemoteProxy;
import org.openqa.grid.internal.TestSlot;
import org.openqa.selenium.WebDriver;
import org.springframework.util.StringUtils;

/**
* Starts Selenium Grid server in another JVM.
*
*
* @author Kohsuke Kawaguchi
* @author Richard Lavoie
* @author Ryan Thomas Correia Ortega
*/
@ExportedBean
public class PluginImpl extends Plugin implements Action, Serializable, Describable<PluginImpl> {
@@ -119,11 +124,11 @@
* Exclusion pattern for nodes. Nodes matching this pattern will not have a selenium node running on them.
*/
private String exclusionPatterns;
private Integer newSessionWaitTimeout = -1;
private Integer newSessionWaitTimeout = -1; //ms or -1
private Integer timeout = 300; //sec // default value as defined in WebDriver
private Integer browserTimeout = 0; //sec // default value as defined in WebDriver
private boolean throwOnCapabilityNotPresent = false;
private String hubLogLevel = "INFO";
private boolean rcDebug;
private String rcLog;

private HostnameResolver hostnameResolver = new JenkinsRootHostnameResolver();

@@ -132,6 +137,8 @@
private transient Boolean rcBrowserSessionReuse;
private transient Boolean rcTrustAllSSLCerts;
private transient Boolean rcBrowserSideLog;
private transient boolean rcDebug;
private transient String rcLog;

private List<SeleniumGlobalConfiguration> configurations = new ArrayList<SeleniumGlobalConfiguration>();

@@ -146,17 +153,42 @@

@Override
public void postInitialize() throws Exception {
load();

startHub();

Hudson.getInstance().getActions().add(this);
}

@Override
public void start() throws Exception {
load();
}

@Override
public void configure(StaplerRequest req, JSONObject formData)
throws IOException, ServletException, Descriptor.FormException {
super.configure(req, formData);

LOGGER.warning(formData.toString());
port = formData.optInt("port", 4444);
exclusionPatterns = formData.getString("exclusionPatterns");
hubLogLevel = formData.getString("hubLogLevel");
newSessionWaitTimeout = formData.optInt("newSessionWaitTimeout", -1);
timeout = formData.optInt("timeout", 300000);
browserTimeout = formData.optInt("browserTimeout", 0);
throwOnCapabilityNotPresent = formData.getBoolean("throwOnCapabilityNotPresent");

LOGGER.warning(formData.getJSONObject("hostnameResolver").toString());

hostnameResolver = req.bindJSON(HostnameResolver.class, formData.getJSONObject("hostnameResolver"));

save();
}

/**
* @throws IOException
* @throws InterruptedException
*
*
*/
private void startHub() throws IOException, InterruptedException {

@@ -172,6 +204,14 @@ private void startHub() throws IOException, InterruptedException {
args.add("-newSessionWaitTimeout");
args.add(getNewSessionWaitTimeout().toString());
}
if (getTimeout() != null) {
args.add("-timeout");
args.add(getTimeout().toString());
}
if (getBrowserTimeout() != null) {
args.add("-browserTimeout");
args.add(getBrowserTimeout().toString());
}
if (getThrowOnCapabilityNotPresent()) {
args.add("-throwOnCapabilityNotPresent");
args.add(Boolean.toString(getThrowOnCapabilityNotPresent()));
@@ -228,6 +268,16 @@ public Integer getNewSessionWaitTimeout() {
return newSessionWaitTimeout;
}

@Exported
public Integer getTimeout() {
return timeout;
}

@Exported
public Integer getBrowserTimeout() {
return browserTimeout;
}

@Exported
public String getHubLogLevel() {
return hubLogLevel != null ? hubLogLevel : "INFO";
@@ -269,7 +319,7 @@ public void stop() throws Exception {
Collection<SeleniumTestSlotGroup> rcs = channel.call(new Callable<Collection<SeleniumTestSlotGroup>, RuntimeException>() {

/**
*
*
*/
private static final long serialVersionUID = 1791985298575049757L;

@@ -374,7 +424,7 @@ public Object readResolve() {

/**
* Returns either the object, or the default value is null.
*
*
* @param object
* Object to return
* @param defaultObject
@@ -430,12 +480,6 @@ public static void startSeleniumNode(Computer c, TaskListener listener, String c
return;
}

String nodehost = c.getHostName();
if (nodehost == null) {
LOGGER.warning("Unable to determine node's hostname. Skipping");
return;
}

listener.getLogger().println("Starting Selenium nodes on " + ("".equals(c.getName()) ? "(master)" : c.getName()));

for (SeleniumGlobalConfiguration config : confs) {
@@ -488,7 +532,7 @@ public SeleniumGlobalConfiguration getConfiguration(String name) {
}

/**
*
*
* @param req
* StaplerRequest
* @param rsp
@@ -510,15 +554,15 @@ public void validateAdmin() {

/**
* Return true if the user has selenium admin access.
*
*
* @return True if the user is a selenium admin, false otherwise
*/
public boolean isAdmin() {
return Hudson.getInstance().hasPermission(getRequiredPermission());
}

/**
*
*
* @param req
* StaplerRequest
* @param rsp
@@ -1,26 +1,32 @@
/**
*
*
*/
package hudson.plugins.selenium.configuration.global.hostname;

import hudson.Extension;
import hudson.model.Hudson;
import org.kohsuke.stapler.DataBoundConstructor;

import java.net.MalformedURLException;
import java.net.URL;

/**
* @author Richard Lavoie
*
*
*/
public class JenkinsRootHostnameResolver extends HostnameResolver {

/**
*
*
*/
private static final long serialVersionUID = 7865004453289102894L;

public String retrieveHost() {
@DataBoundConstructor
public JenkinsRootHostnameResolver() {
}


public String retrieveHost() {
String rootUrl = Hudson.getInstance().getRootUrl();
if (rootUrl == null)
return "localhost";
@@ -1,30 +1,36 @@
/**
*
*
*/
package hudson.plugins.selenium.configuration.global.hostname;

import hudson.Extension;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* @author Richard Lavoie
*
*
*/
public class StaticHostnameResolver extends HostnameResolver {

/**
*
*
*/
private static final long serialVersionUID = -6854399632708036684L;

private String hostname;

@DataBoundConstructor
public StaticHostnameResolver(String hostname) {
this.hostname = hostname;
}

public String retrieveHost() {
return hostname;
}
public String retrieveHost() {
return hostname;
}

public String getHostname() {
return hostname;
}

@Extension
public static final class StaticHostnameRetrieverDescriptor extends HostnameResolverDescriptor {
@@ -4,7 +4,7 @@
<j:set var="descriptor" value="${it.descriptor}"/>
<j:set var="configurationType" value="${ct}"/>
<f:section title="Selenium">
<f:entry title="${%Selenium Grid Port}" field="port">
<f:entry title="${%Selenium Hub Port}" field="port">
<f:textbox />
</f:entry>
<f:advanced>
@@ -24,16 +24,12 @@
<f:entry title="${%Set -timeout}" field="timeout">
<f:textbox />
</f:entry>
<f:entry title="${%Enable -throwOnCapabilityNotPresent}" field="throwOnCapabilityNotPresent">
<f:checkbox />
<f:entry title="${%Set -browserTimeout}" field="browserTimeout">
<f:textbox />
</f:entry>

<f:entry title="${%Enable -debug}" field="rcDebug">
<f:entry title="${%Enable -throwOnCapabilityNotPresent}" field="throwOnCapabilityNotPresent">
<f:checkbox />
</f:entry>
<f:entry title="${%Set -log}" field="rcLog">
<f:textbox />
</f:entry>
<f:entry title="${%Hostname}">
<table style="width:100%">
<f:descriptorRadioList title="${%Hostname resolver}" varName="hostnameResolver" instance="${it.hostnameResolver}" descriptors="${it.resolverTypes}"/>
@@ -42,4 +38,4 @@
</f:advanced>
</f:section>
</j:scope>
</j:jelly>
</j:jelly>
@@ -0,0 +1,10 @@
<div>
Starting from selenium v2.21.0
<br/>Controls how long the browser is allowed to hang (value in <b>seconds</b>)
<br/>
The grid does not act on this value by itself, but passes the value on to the nodes, which do.
Should be higher than the socket lock timeout (45 seconds) and generally higher than values used in webDriver.manage().timeouts()
<br/><br/>
See also
<br/><a href="https://code.google.com/p/selenium/wiki/Grid2">https://code.google.com/p/selenium/wiki/Grid2</a>
</div>
@@ -1,5 +1,5 @@
<div>
Time in ms after which a new test waiting for a node to become available will
time out.When that happens, the test will throw an exception before starting
a browser.
</div>
Time in <b>ms</b> after which a new test waiting for a node to become available will
time out.When that happens, the test will throw an exception before starting
a browser.
</div>

This file was deleted.

This file was deleted.

@@ -1,3 +1,17 @@
<div>
Specify the number of seconds that the server will wait for the browser to respond to the previous command, or for the client driver to issue a new request.
</div>
Controls how long (value in <b>seconds</b>) the client is allowed to be gone before the session is reclaimed.
Typically takes care of the client crashes. Working together with cleanup cycle (default is 5sec).
Worst case scenario, a session can be idle for timeout + cleanup cycle before the timeout is detected.
<br/>
When elapsed the browser will be released for another test to use.
To remove the timeout completely, specify -timeout 0 and the hub will never release the node.
(Can be used when doing step-by-step debugging of client code)
<br/>
Default value is 30sec.
<br/>
Replaces the -nodeTimeout parameter starting from selenium v2.21.0
<br/><br/>
See also:
<br/> <a href="https://code.google.com/p/selenium/wiki/Grid2">https://code.google.com/p/selenium/wiki/Grid2</a>
<br/> <a href="https://code.google.com/p/selenium/wiki/RemoteWebDriverServer">https://code.google.com/p/selenium/wiki/RemoteWebDriverServer</a>
</div>

0 comments on commit 76f88f5

Please sign in to comment.