Skip to content

Commit

Permalink
Fix for 3.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
smccarthy-godaddy committed Nov 24, 2017
1 parent 290f56b commit 844cf2d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 20 deletions.
26 changes: 13 additions & 13 deletions SeleniumGridExtras/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.groupon.selenium-grid-extras</groupId>
<artifactId>SeleniumGridExtras</artifactId>
<version>1.12.17-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>

<repositories>
<repository>
Expand All @@ -19,11 +19,11 @@
</repositories>

<properties>
<version.selenium>3.5.3</version.selenium>
<version.selenium>3.7.1</version.selenium>
</properties>

<dependencies>
<dependency> <!-- Selenium 2.53.1 comes with jna-platform 4.1.0 -->
<dependency> <!-- Selenium 3.7.1 comes with jna-platform 4.1.0 -->
<groupId>net.java.dev.jna</groupId> <!-- Needed for BrowerVersionDetector (for IE) -->
<artifactId>jna-platform</artifactId>
<version>4.1.0</version>
Expand All @@ -50,31 +50,31 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency> <!-- Selenium 2.53.1 comes with commons-io 2.4 -->
<dependency> <!-- Selenium 3.7.1 comes with commons-io 2.5 -->
<groupId>commons-io</groupId> <!-- GridHub.writeToFile requires this -->
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>2.5</version>
</dependency>
<dependency> <!-- Selenium 2.53.1 comes with commons-codec 1.10 -->
<groupId>commons-codec</groupId> <!-- ScreenshotUtility.encodeStreamToBase64 requires this -->
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<!-- Needed for `Should we store all of these configs in central location on the HUB node and update from there? (1-yes/0-no)` -->
<dependency> <!-- Selenium 2.53.1 comes with httpclient 4.5.1 -->
<dependency> <!-- Selenium 3.7.1 comes with httpclient 4.5.3 -->
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.1</version>
<version>4.5.3</version>
</dependency>
<dependency> <!-- Selenium 2.53.1 comes with commons-lang3 3.4 -->
<dependency> <!-- Selenium 3.7.1 comes with commons-lang3 3.5 -->
<groupId>org.apache.commons</groupId> <!-- Needed all over -->
<artifactId>commons-lang3</artifactId>
<version>3.3.2</version>
<version>3.5</version>
</dependency>
<dependency>
<dependency> <!-- Selenium 3.7.1 comes with gson 2.8.2 -->
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.1</version>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
Expand Down Expand Up @@ -106,7 +106,7 @@
<artifactId>xuggler</artifactId>
<version>0.16</version>
</dependency>
<dependency> <!-- selenium-api-2.53.1 comes with guava 19.0 -->
<dependency> <!-- selenium-api-3.7.1 comes with guava 23.0 -->
<artifactId>guava</artifactId> <!-- Needed for UpgradeGridExtrasTask.getSanitizedReleaseList -->
<groupId>com.google.guava</groupId>
<type>jar</type>
Expand All @@ -120,7 +120,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.0.31-beta</version>
<version>2.12.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.common.exception.RemoteUnregisterException;
import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.GridRegistry;
import org.openqa.grid.internal.TestSession;
import org.openqa.grid.internal.listeners.SelfHealingProxy;
import org.openqa.grid.internal.utils.HtmlRenderer;
Expand All @@ -24,7 +24,7 @@ public class AutoProxy extends DefaultRemoteProxy implements SelfHealingProxy {
private Date startTime;
private HtmlRenderer renderer = new ExtrasHtmlRenderer(this);

public AutoProxy(RegistrationRequest request, Registry registry) {
public AutoProxy(RegistrationRequest request, GridRegistry registry) {
super(request, registry);
NodeManager nodeManager = new NodeManager(this);
new Thread(nodeManager).start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import com.groupon.seleniumgridextras.utilities.threads.video.VideoDownloaderCallable;
import org.apache.log4j.Logger;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.GridRegistry;
import org.openqa.grid.internal.TestSession;
import org.openqa.grid.internal.listeners.TestSessionListener;
import org.openqa.grid.selenium.proxy.DefaultRemoteProxy;
Expand All @@ -78,7 +78,7 @@ public class SetupTeardownProxy extends DefaultRemoteProxy implements TestSessio
private static Logger logger = Logger.getLogger(SetupTeardownProxy.class);


public SetupTeardownProxy(RegistrationRequest request, Registry registry) {
public SetupTeardownProxy(RegistrationRequest request, GridRegistry registry) {
super(request, registry);
logger.info(String.format("Attaching node %s", this.getId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import org.openqa.grid.internal.ProxySet;
import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.GridRegistry;
import org.openqa.grid.internal.RemoteProxy;
import org.openqa.grid.internal.TestSlot;
import org.openqa.grid.web.servlet.RegistryBasedServlet;
Expand All @@ -27,7 +27,7 @@ public ProxyStatusJsonServlet() {
this(null);
}

public ProxyStatusJsonServlet(Registry registry) {
public ProxyStatusJsonServlet(GridRegistry registry) {
super(registry);
}

Expand Down Expand Up @@ -102,4 +102,3 @@ private Map getResponse() {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import com.groupon.seleniumgridextras.config.RuntimeConfig;
import com.groupon.seleniumgridextras.tasks.config.TaskDescriptions;
import com.groupon.seleniumgridextras.utilities.json.JsonCodec;
import com.groupon.seleniumgridextras.Version;
import com.groupon.seleniumgridextras.utilities.VersionCompare;

import org.apache.log4j.Logger;

Expand Down Expand Up @@ -85,9 +87,18 @@ public JsonObject execute() {
}

if (updateWebDriver) {
String gridExtrasVersion = Version.getSanitizedVersion();
String
newWebDriverVersion =
RuntimeConfig.getReleaseManager().getWedriverLatestVersion().getPrettyPrintVersion(".");
if(gridExtrasVersion.startsWith("2.")) {
if(VersionCompare.versionCompare(newWebDriverVersion, "3.7.1") < 0) {
String message = String.format("SeleniumGridExtras 2.X is not compatible with Selenium version 3.7.0 or less.");
logger.info(message);
getJsonResponse().addKeyValues(JsonCodec.OUT, message);
return getJsonResponse().getJson();
}
}
logger.info("WebDriver JAR " + genericUpdate + " " + newWebDriverVersion);
RuntimeConfig.getConfig().getWebdriver().setVersion(newWebDriverVersion);
updateVersionFor(configHash, "webdriver", newWebDriverVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.groupon.seleniumgridextras.tasks.config.TaskDescriptions;
import com.groupon.seleniumgridextras.utilities.FileIOUtility;
import com.groupon.seleniumgridextras.utilities.json.JsonCodec;
import com.groupon.seleniumgridextras.utilities.VersionCompare;
import org.apache.log4j.Logger;

import java.io.File;
Expand Down Expand Up @@ -203,6 +204,15 @@ public JsonObject execute(String version) {

getJsonResponse().addKeyValues(JsonCodec.GridExtras.NEW_VERSION, version);

if (version.startsWith("2.")) {
String webdriverVersion = RuntimeConfig.getConfig().getWebdriver().getVersion();
if (VersionCompare.versionCompare(webdriverVersion, "3.7.1") < 0) {
String message = String.format("SeleniumGridExtras 2.X is not compatible with Selenium version 3.7.0 or less.");
logger.info(message);
getJsonResponse().addKeyValues(JsonCodec.OUT, message);
return getJsonResponse().getJson();
}
}

File destinationJar = new File(RuntimeConfig.getSeleniungGridExtrasHomePath(),
String.format("SeleniumGridExtras-%s-SNAPSHOT-jar-with-dependencies.jar", version));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.groupon.seleniumgridextras.utilities;

public class VersionCompare {

/**
Return 1 if version1 is greater than version2
Return 0 if version 1 is equal to version2
Return -1 if version 1 is less than version2
*/
public static int versionCompare(String version1, String version2) {
int major1 = (version1.split(".").length > 0) ? Integer.parseInt(version1.split(".")[0]) : 0;
int minor1 = (version1.split(".").length > 1) ? Integer.parseInt(version1.split(".")[1]) : 0;
int patch1 = (version1.split(".").length > 2) ? Integer.parseInt(version1.split(".")[2]) : 0;

int major2 = (version2.split(".").length > 0) ? Integer.parseInt(version2.split(".")[0]) : 0;
int minor2 = (version2.split(".").length > 1) ? Integer.parseInt(version2.split(".")[1]) : 0;
int patch2 = (version2.split(".").length > 2) ? Integer.parseInt(version2.split(".")[2]) : 0;

if (major1 > major2) {
return 1;
} else if (major1 < major2) {
return -1;
} else { // Majors match
if (minor1 > minor2) {
return 1;
} else if (minor1 < minor2) {
return -1;
} else {
if (patch1 > patch2) {
return 1;
} else if (patch1 < patch2) {
return -1;
} else {
return 0;
}
}
}
}
}

0 comments on commit 844cf2d

Please sign in to comment.