Skip to content

Commit

Permalink
Get the Grid e2e tests working.
Browse files Browse the repository at this point in the history
In the process, remove any statics from the classes.
  • Loading branch information
shs96c committed Oct 5, 2016
1 parent 5fdeca3 commit 7919164
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 206 deletions.
19 changes: 11 additions & 8 deletions java/server/test/org/openqa/grid/e2e/GridE2ETests.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
import org.junit.runners.Suite;
import org.openqa.grid.e2e.misc.ConfigInheritanceTest;
import org.openqa.grid.e2e.misc.Grid1HeartbeatTest;
import org.openqa.grid.e2e.misc.GridDistributionTest;
import org.openqa.grid.e2e.misc.GridSerializeExceptionTest;
import org.openqa.grid.e2e.misc.GridViaCommandLineTest;
import org.openqa.grid.e2e.misc.HubRestart;
import org.openqa.grid.e2e.misc.HubRestartNeg;
import org.openqa.grid.e2e.misc.Issue1586;
import org.openqa.grid.e2e.misc.WebDriverPriorityDemo;
import org.openqa.grid.e2e.node.BrowserTimeOutTest;
import org.openqa.grid.e2e.node.CrashWhenStartingBrowserTest;
Expand All @@ -43,23 +45,24 @@

@RunWith(Suite.class)
@Suite.SuiteClasses({
BrowserTimeOutTest.class,
ConfigInheritanceTest.class,
CrashWhenStartingBrowserTest.class,
DefaultProxyFindsFirefoxLocationsTest.class,
DefaultProxyIsUnregisteredIfDownForTooLongTest.class,
ExtraServletUtilTest.class,
Grid1HeartbeatTest.class,
GridDistributionTest.class,
GridSerializeExceptionTest.class,
GridViaCommandLineTest.class,
HubRestart.class,
HubRestartNeg.class,
//Issue1586.class, // extremely slow test, for issue1586. Excluding from regression.
WebDriverPriorityDemo.class,
//BrowserTimeOutTest.class, // broken on CI, needs investigation
CrashWhenStartingBrowserTest.class,
DefaultProxyFindsFirefoxLocationsTest.class,
DefaultProxyIsUnregisteredIfDownForTooLongTest.class,
Issue1586.class,
NodeGoingDownAndUpTest.class, // slow
NodeRecoveryTest.class,
NodeTimeOutTest.class,
SmokeTest.class, // slow
ExtraServletUtilTest.class,
GridViaCommandLineTest.class,
WebDriverPriorityDemo.class,
})
public class GridE2ETests {
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@

import static org.junit.Assert.assertEquals;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.e2e.utils.GridTestHelper;
import org.openqa.grid.e2e.utils.RegistryTestHelper;
import org.openqa.grid.internal.RemoteProxy;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.net.PortProber;
import org.openqa.selenium.remote.server.SeleniumServer;


public class ConfigInheritanceTest {
private static Hub hub;
private Hub hub;

@BeforeClass
public static void prepare() throws Exception {
@Before
public void prepare() throws Exception {
GridHubConfiguration config = new GridHubConfiguration();
config.port = PortProber.findFreePort();
config.custom.put("A", "valueA");
Expand Down Expand Up @@ -74,8 +74,8 @@ public void test() {

}

@AfterClass
public static void stop() throws Exception {
@After
public void stop() throws Exception {
hub.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.e2e.utils.GridTestHelper;
import org.openqa.grid.e2e.utils.RegistryTestHelper;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
Expand All @@ -42,10 +41,10 @@

public class Grid1HeartbeatTest {

private static Hub hub;
private Hub hub;

@BeforeClass
public static void setup() throws Exception {
@Before
public void setup() throws Exception {
hub = GridTestHelper.getHub();
}

Expand Down Expand Up @@ -113,8 +112,8 @@ public void testIsRegistered() throws Exception {
}
}

@AfterClass
public static void teardown() throws Exception {
@After
public void teardown() throws Exception {
hub.stop();
}
}
30 changes: 15 additions & 15 deletions java/server/test/org/openqa/grid/e2e/misc/GridDistributionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

package org.openqa.grid.e2e.misc;

import junit.framework.Assert;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.e2e.utils.GridTestHelper;
Expand All @@ -34,18 +34,19 @@
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.server.SeleniumServer;

import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class GridDistributionTest {

private static Hub hub;
private static List<WebDriver> drivers = new ArrayList<>();
private Hub hub;
private List<WebDriver> drivers = new ArrayList<>();

@BeforeClass
public static void prepare() throws Exception {
@Before
public void prepare() throws Exception {

hub = GridTestHelper.getHub();

Expand All @@ -61,10 +62,9 @@ public static void prepare() throws Exception {
}
}

@Test
public void testLoadIsDistributedEvenly() throws Throwable {


@Test(timeout = 45000)
@Ignore("Times out")
public void testLoadIsDistributedEvenly() throws MalformedURLException {
for (int i=0; i < 8; i++) {
drivers.add(GridTestHelper.getRemoteWebDriver(DesiredCapabilities.chrome(), hub));
}
Expand Down Expand Up @@ -179,7 +179,7 @@ public void testLeastRecentlyUsedNodesPickedFirst() throws Throwable {
}
}

private static void stopDrivers(List<WebDriver> drivers) {
private void stopDrivers(List<WebDriver> drivers) {
for (WebDriver driver : drivers) {
try {
driver.quit();
Expand All @@ -190,8 +190,8 @@ private static void stopDrivers(List<WebDriver> drivers) {
drivers.clear();
}

@AfterClass
public static void stop() throws Exception {
@After
public void stop() throws Exception {
stopDrivers(drivers);
hub.stop();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

package org.openqa.grid.e2e.misc;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.e2e.utils.GridTestHelper;
Expand All @@ -30,11 +30,10 @@

public class GridSerializeExceptionTest {

private static Hub hub;

@BeforeClass
public static void prepare() throws Exception {
private Hub hub;

@Before
public void prepare() throws Exception {
hub = GridTestHelper.getHub();

SelfRegisteringRemote remote =
Expand All @@ -51,8 +50,8 @@ public void testwebdriver() throws Throwable {
GridTestHelper.getRemoteWebDriver(GridTestHelper.getDefaultBrowserCapability(), hub);
}

@AfterClass
public static void stop() throws Exception {
@After
public void stop() throws Exception {
hub.stop();
}
}
21 changes: 10 additions & 11 deletions java/server/test/org/openqa/grid/e2e/misc/HubRestart.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import static org.junit.Assert.assertEquals;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.e2e.utils.GridTestHelper;
Expand All @@ -41,13 +41,13 @@
*/
public class HubRestart {

private static Hub hub;
private static Registry registry;
private static SelfRegisteringRemote remote;
private static GridHubConfiguration config = new GridHubConfiguration();
private Hub hub;
private Registry registry;
private SelfRegisteringRemote remote;
private GridHubConfiguration config = new GridHubConfiguration();

@BeforeClass
public static void prepare() throws Exception {
@Before
public void prepare() throws Exception {
config.host = "localhost";
config.port = PortProber.findFreePort();
hub = GridTestHelper.getHub(config);
Expand Down Expand Up @@ -90,10 +90,9 @@ public void nodeRegisterAgain() throws Exception {

}

@AfterClass
public static void stop() throws Exception {
@After
public void stop() throws Exception {
hub.stop();
remote.stopRemoteServer();

}
}
25 changes: 11 additions & 14 deletions java/server/test/org/openqa/grid/e2e/misc/HubRestartNeg.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@

import static org.junit.Assert.assertEquals;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.common.RegistrationRequest;
import org.openqa.grid.e2e.utils.GridTestHelper;
import org.openqa.grid.e2e.utils.RegistryTestHelper;
import org.openqa.grid.internal.Registry;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.internal.utils.SelfRegisteringRemote;
import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;
import org.openqa.grid.web.Hub;
import org.openqa.selenium.net.PortProber;
import org.openqa.selenium.remote.server.SeleniumServer;
Expand All @@ -42,13 +41,13 @@
*
*/
public class HubRestartNeg {
private static Hub hub;
private static Registry registry;
private static SelfRegisteringRemote remote;
private static GridHubConfiguration config = new GridHubConfiguration();
private Hub hub;
private Registry registry;
private SelfRegisteringRemote remote;
private GridHubConfiguration config = new GridHubConfiguration();

@BeforeClass
public static void prepare() throws Exception {
@Before
public void prepare() throws Exception {
config.host = "localhost";
config.port = PortProber.findFreePort();
hub = new Hub(config);
Expand All @@ -61,7 +60,6 @@ public static void prepare() throws Exception {

remote.setRemoteServer(new SeleniumServer(remote.getConfiguration()));
remote.startRemoteServer();

}

@Test(timeout = 5000)
Expand Down Expand Up @@ -92,10 +90,9 @@ public void nodeRegisterAgain() throws Exception {

}

@AfterClass
public static void stop() throws Exception {
@After
public void stop() throws Exception {
hub.stop();
remote.stopRemoteServer();

}
}
18 changes: 9 additions & 9 deletions java/server/test/org/openqa/grid/e2e/misc/Issue1586.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

package org.openqa.grid.e2e.misc;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.openqa.grid.common.GridRole;
import org.openqa.grid.e2e.utils.GridTestHelper;
Expand All @@ -32,15 +33,14 @@
import org.openqa.selenium.remote.server.SeleniumServer;

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

// see http://code.google.com/p/selenium/issues/detail?id=1586
public class Issue1586 {

private static Hub hub;
private Hub hub;

@BeforeClass
public static void prepare() throws Exception {
@Before
public void prepare() throws Exception {
hub = GridTestHelper.getHub();

// register a webdriver
Expand All @@ -55,8 +55,8 @@ public static void prepare() throws Exception {
RegistryTestHelper.waitForNode(hub.getRegistry(), 1);
}

// extremely slow test, for issue1586. Excluding from regression.
@Test
@Ignore("Extremely slow test, for issue1586. Excluding from regression.")
public void test() throws MalformedURLException {
WebDriver driver = null;
try {
Expand All @@ -77,8 +77,8 @@ public void test() throws MalformedURLException {
}
}

@AfterClass
public static void stop() throws Exception {
@After
public void stop() throws Exception {
hub.stop();
}
}
Loading

0 comments on commit 7919164

Please sign in to comment.