Skip to content

Commit

Permalink
Always use random hub port to support multiple local grids in a commo…
Browse files Browse the repository at this point in the history
…n environment.
  • Loading branch information
squash-merge committed Apr 25, 2016
1 parent bb26610 commit 93e2410
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.paypal.selion.internal.platform.grid;

import org.openqa.selenium.net.NetworkUtils;
import org.openqa.selenium.net.PortProber;

import com.paypal.selion.configuration.Config;
import com.paypal.selion.configuration.Config.ConfigProperty;
Expand Down Expand Up @@ -44,7 +45,12 @@ synchronized LocalHub getLocalServerComponent() {
instance = new LocalHub();

instance.setHost(new NetworkUtils().getIpOfLoopBackIp4());
instance.setPort(Integer.parseInt(Config.getConfigProperty(ConfigProperty.SELENIUM_PORT)));

// Choose a random port for local hub.
int hubPort = PortProber.findFreePort();
// Set ConfigProperty.SELENIUM_PORT so that the local nodes can register to it.
instance.setPort(hubPort);
Config.setConfigProperty(ConfigProperty.SELENIUM_PORT, Integer.toString(hubPort));

LauncherOptions launcherOptions = new LauncherOptionsImpl()
.setFileDownloadCheckTimeStampOnInvocation(false).setFileDownloadCleanupOnInvocation(false);
Expand Down Expand Up @@ -75,4 +81,5 @@ public void shutdown() {
super.shutdown();
LOGGER.exiting();
}

}

0 comments on commit 93e2410

Please sign in to comment.