Skip to content

Commit

Permalink
Breaking unwanted grid dependency on parts of RC server
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Oct 11, 2015
1 parent f4a8391 commit 2f12ebb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
14 changes: 0 additions & 14 deletions java/server/src/org/openqa/grid/common/RegistrationRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.JsonToBeanConverter;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory;
import org.openqa.selenium.server.cli.RemoteControlLauncher;

import com.google.common.collect.Maps;
import com.google.gson.Gson;
Expand Down Expand Up @@ -584,18 +582,6 @@ public void setRole(GridRole role) {
this.role = role;
}

public RemoteControlConfiguration getRemoteControlConfiguration() {
List<String> params = new ArrayList<>();
for (String key : configuration.keySet()) {
params.add("-" + key);

if (!configuration.get(key).toString().trim().isEmpty()) {
params.add("" + configuration.get(key));
}
}
return RemoteControlLauncher.parseLauncherOptions(params.toArray(new String[params.size()]));
}

public String[] getArgs() {
return args;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.internal.HttpClientFactory;
import org.openqa.selenium.remote.server.log.LoggingManager;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;

import java.io.BufferedReader;
Expand Down Expand Up @@ -88,27 +87,25 @@ public void startRemoteServer() throws Exception {

System.setProperty("org.openqa.jetty.http.HttpRequest.maxFormContentSize", "0");


nodeConfig.validate();
RemoteControlConfiguration remoteControlConfiguration = nodeConfig.getRemoteControlConfiguration();

try {
JsonObject hubParameters = getHubConfiguration();
if (hubParameters.has(RegistrationRequest.TIME_OUT)){
int timeout = hubParameters.get(RegistrationRequest.TIME_OUT).getAsInt() / 1000;
remoteControlConfiguration.setTimeoutInSeconds(timeout);
nodeConfig.getConfiguration().put(RegistrationRequest.TIME_OUT, timeout);
}
if (hubParameters.has(RegistrationRequest.BROWSER_TIME_OUT)) {
int browserTimeout = hubParameters.get(RegistrationRequest.BROWSER_TIME_OUT).getAsInt();
remoteControlConfiguration.setBrowserTimeoutInMs(browserTimeout);
nodeConfig.getConfiguration().put(RegistrationRequest.BROWSER_TIME_OUT, browserTimeout);
}
} catch (Exception e) {
LOG.warning(
"error getting the parameters from the hub. The node may end up with wrong timeouts." + e
.getMessage());
}

server = new SeleniumServer(remoteControlConfiguration);
server = new SeleniumServer(nodeConfig.getConfiguration());

Server jetty = server.getServer();

Expand Down
19 changes: 19 additions & 0 deletions java/server/src/org/openqa/selenium/server/SeleniumServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
import java.net.BindException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
Expand Down Expand Up @@ -241,6 +244,22 @@ public SeleniumServer() throws Exception {
this(slowResourceProperty(), new RemoteControlConfiguration());
}

public SeleniumServer(Map<String, Object> configurationAsMap) throws Exception {
this(slowResourceProperty(), mapToRemoteControlConfiguration(configurationAsMap));
}

private static RemoteControlConfiguration mapToRemoteControlConfiguration(Map<String, Object> configurationAsMap) {
List<String> params = new ArrayList<>();
for (String key : configurationAsMap.keySet()) {
params.add("-" + key);

if (!configurationAsMap.get(key).toString().trim().isEmpty()) {
params.add("" + configurationAsMap.get(key));
}
}
return RemoteControlLauncher.parseLauncherOptions(params.toArray(new String[params.size()]));
}

public SeleniumServer(RemoteControlConfiguration configuration) throws Exception {
this(slowResourceProperty(), configuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void CapabilityNotPresentRegistryParam() {
}
}

@Test(timeout = 1000)
@Test(timeout = 2000)
public void registerAtTheSameTime() throws InterruptedException {
final Registry registry = Registry.newInstance();
final CountDownLatch latch = new CountDownLatch(TOTAL_THREADS);
Expand Down

0 comments on commit 2f12ebb

Please sign in to comment.