From 15c48c4893fe340c6a4ab6b09b0d903635973f28 Mon Sep 17 00:00:00 2001 From: Simon Mavi Stewart Date: Tue, 28 Sep 2021 11:13:17 +0100 Subject: [PATCH] Remove tests we were keeping for reference only --- .../org/openqa/grid/e2e/GridE2ETests.java | 49 ---- .../grid/e2e/misc/GridDistributionTest.java | 129 ----------- .../e2e/misc/GridListActiveSessionsTest.java | 116 ---------- .../org/openqa/grid/e2e/misc/HubRestart.java | 91 -------- .../openqa/grid/e2e/misc/HubRestartNeg.java | 87 -------- .../grid/e2e/misc/WebDriverPriorityDemo.java | 209 ------------------ .../grid/e2e/node/BrowserTimeOutTest.java | 75 ------- .../node/CrashWhenStartingBrowserTest.java | 102 --------- ...oxyIsUnregisteredIfDownForTooLongTest.java | 119 ---------- .../grid/e2e/node/NodeGoingDownAndUpTest.java | 89 -------- .../grid/e2e/node/NodeRecoveryTest.java | 90 -------- .../org/openqa/grid/e2e/node/SmokeTest.java | 49 ---- .../openqa/grid/e2e/utils/GridTestHelper.java | 119 ---------- .../grid/e2e/utils/RegistryTestHelper.java | 63 ------ .../grid/e2e/utils/TestHttpServlet.java | 27 --- .../grid/internal/ConcurrencyLockTest.java | 117 ---------- .../grid/internal/GridInternalTests.java | 30 --- .../openqa/grid/internal/PriorityTest.java | 128 ----------- .../grid/internal/PriorityTestLoad.java | 120 ---------- .../openqa/grid/internal/mock/GridHelper.java | 69 ------ .../proxy/DefaultRemoteProxyTest.java | 96 -------- .../grid/web/servlet/BaseServletTest.java | 75 ------- 22 files changed, 2049 deletions(-) delete mode 100644 java/test/org/openqa/grid/e2e/GridE2ETests.java delete mode 100644 java/test/org/openqa/grid/e2e/misc/GridDistributionTest.java delete mode 100644 java/test/org/openqa/grid/e2e/misc/GridListActiveSessionsTest.java delete mode 100644 java/test/org/openqa/grid/e2e/misc/HubRestart.java delete mode 100644 java/test/org/openqa/grid/e2e/misc/HubRestartNeg.java delete mode 100644 java/test/org/openqa/grid/e2e/misc/WebDriverPriorityDemo.java delete mode 100644 java/test/org/openqa/grid/e2e/node/BrowserTimeOutTest.java delete mode 100644 java/test/org/openqa/grid/e2e/node/CrashWhenStartingBrowserTest.java delete mode 100644 java/test/org/openqa/grid/e2e/node/DefaultProxyIsUnregisteredIfDownForTooLongTest.java delete mode 100644 java/test/org/openqa/grid/e2e/node/NodeGoingDownAndUpTest.java delete mode 100644 java/test/org/openqa/grid/e2e/node/NodeRecoveryTest.java delete mode 100644 java/test/org/openqa/grid/e2e/node/SmokeTest.java delete mode 100644 java/test/org/openqa/grid/e2e/utils/GridTestHelper.java delete mode 100644 java/test/org/openqa/grid/e2e/utils/RegistryTestHelper.java delete mode 100644 java/test/org/openqa/grid/e2e/utils/TestHttpServlet.java delete mode 100644 java/test/org/openqa/grid/internal/ConcurrencyLockTest.java delete mode 100644 java/test/org/openqa/grid/internal/GridInternalTests.java delete mode 100644 java/test/org/openqa/grid/internal/PriorityTest.java delete mode 100644 java/test/org/openqa/grid/internal/PriorityTestLoad.java delete mode 100644 java/test/org/openqa/grid/internal/mock/GridHelper.java delete mode 100644 java/test/org/openqa/grid/selenium/proxy/DefaultRemoteProxyTest.java delete mode 100644 java/test/org/openqa/grid/web/servlet/BaseServletTest.java diff --git a/java/test/org/openqa/grid/e2e/GridE2ETests.java b/java/test/org/openqa/grid/e2e/GridE2ETests.java deleted file mode 100644 index c33533d7ea1fd..0000000000000 --- a/java/test/org/openqa/grid/e2e/GridE2ETests.java +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.openqa.grid.e2e.misc.GridDistributionTest; -import org.openqa.grid.e2e.misc.GridListActiveSessionsTest; -import org.openqa.grid.e2e.misc.HubRestart; -import org.openqa.grid.e2e.misc.HubRestartNeg; -import org.openqa.grid.e2e.misc.WebDriverPriorityDemo; -import org.openqa.grid.e2e.node.BrowserTimeOutTest; -import org.openqa.grid.e2e.node.CrashWhenStartingBrowserTest; -import org.openqa.grid.e2e.node.DefaultProxyIsUnregisteredIfDownForTooLongTest; -import org.openqa.grid.e2e.node.NodeGoingDownAndUpTest; -import org.openqa.grid.e2e.node.NodeRecoveryTest; -import org.openqa.grid.e2e.node.SmokeTest; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ - BrowserTimeOutTest.class, - CrashWhenStartingBrowserTest.class, - DefaultProxyIsUnregisteredIfDownForTooLongTest.class, - GridDistributionTest.class, - HubRestart.class, - HubRestartNeg.class, - NodeGoingDownAndUpTest.class, // slow - NodeRecoveryTest.class, - SmokeTest.class, // slow - WebDriverPriorityDemo.class, - GridListActiveSessionsTest.class -}) -public class GridE2ETests { -} diff --git a/java/test/org/openqa/grid/e2e/misc/GridDistributionTest.java b/java/test/org/openqa/grid/e2e/misc/GridDistributionTest.java deleted file mode 100644 index 17abcb977df2b..0000000000000 --- a/java/test/org/openqa/grid/e2e/misc/GridDistributionTest.java +++ /dev/null @@ -1,129 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.misc; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.openqa.selenium.WebDriver; - -import java.util.ArrayList; -import java.util.List; - -public class GridDistributionTest { - -// private Hub hub; - private List drivers = new ArrayList<>(); - - @Before - public void prepare() { - -// hub = GridTestHelper.getHub(); -// -// for (int i =0; i < 8; i++) { -// SelfRegisteringRemote remote = -// GridTestHelper.getRemoteWithoutCapabilities(hub, GridRole.NODE); -// -// remote.addBrowser(GridTestHelper.getDefaultBrowserCapability(), 3); -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); -// remote.sendRegistrationRequest(); -// RegistryTestHelper.waitForNode(hub.getRegistry(), i+1); -// } - } - - @Test - public void testLeastRecentlyUsedNodesPickedFirst() { -// ProxySet ps = hub.getRegistry().getAllProxies(); -// -// for (int i=0; i < 4; i++) { -// drivers.add(GridTestHelper.getRemoteWebDriver(hub)); -// } -// -// Set chosenNodes = new HashSet<>(); -// -// for (RemoteProxy p : ps) { -// for (TestSlot ts : p.getTestSlots()) { -// if (ts.getSession() != null) { -// chosenNodes.add(p.getRemoteHost().toString()); -// break; -// } -// } -// } -// -// stopDrivers(drivers); -// -// for (int i=0; i < 4; i++) { -// drivers.add(GridTestHelper.getRemoteWebDriver(hub)); -// } -// -// for (RemoteProxy p : ps) { -// for (TestSlot ts : p.getTestSlots()) { -// if (ts.getSession() != null) { -// Assert.assertFalse("Should not be immediately reused: " + p.getRemoteHost().toString() + " previously used nodes: " + chosenNodes, -// chosenNodes.contains(p.getRemoteHost().toString())); -// break; -// } -// } -// } -// -// chosenNodes.clear(); -// -// for (RemoteProxy p : ps) { -// for (TestSlot ts : p.getTestSlots()) { -// if (ts.getSession() != null) { -// chosenNodes.add(p.getRemoteHost().toString()); -// break; -// } -// } -// } -// -// stopDrivers(drivers); -// -// for (int i=0; i < 4; i++) { -// drivers.add(GridTestHelper.getRemoteWebDriver(hub)); -// } -// -// for (RemoteProxy p : ps) { -// for (TestSlot ts : p.getTestSlots()) { -// if (ts.getSession() != null) { -// Assert.assertFalse("Should not be immediately reused: " + p.getRemoteHost().toString() + " previously used nodes: " + chosenNodes, -// chosenNodes.contains(p.getRemoteHost().toString())); -// break; -// } -// } -// } - } - - private void stopDrivers(List drivers) { - for (WebDriver driver : drivers) { - try { - driver.quit(); - } catch (Exception e) { - System.out.println(e.toString()); - } - } - drivers.clear(); - } - - @After - public void stop() { - stopDrivers(drivers); -// hub.stop(); - } -} diff --git a/java/test/org/openqa/grid/e2e/misc/GridListActiveSessionsTest.java b/java/test/org/openqa/grid/e2e/misc/GridListActiveSessionsTest.java deleted file mode 100644 index 785430d420644..0000000000000 --- a/java/test/org/openqa/grid/e2e/misc/GridListActiveSessionsTest.java +++ /dev/null @@ -1,116 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.misc; - -@SuppressWarnings("unchecked") -public class GridListActiveSessionsTest { - -// @Test -// public void testNoSessions() throws Exception { -// runTest(1, 0, map -> { -// List> proxies = extractProxies(map); -// assertTrue("No sessions data should be found", proxies.isEmpty()); -// }); -// } -// -// @Test -// public void testOneSessionWithSingleProxy() throws Exception { -// runTestForMultipleSessions(1, 1, 1); -// } -// -// @Test -// public void testMultipleSessionsWithSingleProxy() throws Exception { -// runTestForMultipleSessions(1, 2, 2); -// } -// -// @Test -// public void testMultipleSessionsWithMultipleProxies() throws Exception { -// runTestForMultipleSessions(2, 2, 1); -// } -// -// private void runTestForMultipleSessions(int howManyNodes, int howManySessions, -// int expectedSessionsPerProxy) throws Exception { -// runTest(howManyNodes, -// howManySessions, -// map -> { -// List> proxies = extractProxies(map); -// assertEquals("Number of proxies", howManyNodes, proxies.size()); -// for (Map proxy : proxies) { -// Map sessions = (Map) proxy.get("sessions"); -// List values = (List) sessions.get("value"); -// assertEquals("Sessions per proxy", expectedSessionsPerProxy, -// values.size()); -// } -// }); -// } -// -// private void runTest(int nodesCount, int howMany, -// Consumer> assertions) throws Exception { -// Hub hub = null; -// List drivers = new ArrayList<>(); -// try { -// hub = GridTestHelper.prepareTestGrid(nodesCount); -// drivers = createSession(howMany, hub); -// Map sessions = getSessions(hub); -// assertions.accept(sessions); -// } finally { -// drivers.forEach(RemoteWebDriver::quit); -// if (hub != null) { -// hub.stop(); -// } -// } -// } -// -// private List createSession(int howMany, Hub hub) { -// List drivers = new ArrayList<>(); -// if (howMany == 0) { -// return drivers; -// } -// URL url; -// try { -// url = new URL("http://" + hub.getUrl().getHost() + ":" + -// hub.getUrl().getPort() + "/wd/hub"); -// } catch (MalformedURLException e) { -// return new ArrayList<>(); -// } -// for (int i = 0; i < howMany; i++) { -// drivers.add(new RemoteWebDriver(url, GridTestHelper.getDefaultBrowserCapability())); -// } -// return drivers; -// -// } -// -// private Map getSessions(Hub hub) throws IOException { -// String url = String.format("http://%s:%d/grid/api/sessions", hub.getUrl().getHost(), -// hub.getUrl().getPort()); -// URL grid = new URL(url); -// URLConnection connection = grid.openConnection(); -// try (InputStream in = connection.getInputStream(); -// JsonInput input = new Json().newInput(new BufferedReader(new InputStreamReader(in)))) { -// return input.read(Json.MAP_TYPE); -// -// } -// } -// -// private List> extractProxies(Map map) { -// boolean success = Boolean.parseBoolean(map.get("success").toString()); -// assertTrue("Status should be true", success); -// return (List>) map.get("proxies"); -// } -// -} diff --git a/java/test/org/openqa/grid/e2e/misc/HubRestart.java b/java/test/org/openqa/grid/e2e/misc/HubRestart.java deleted file mode 100644 index 35b21e1dd5dda..0000000000000 --- a/java/test/org/openqa/grid/e2e/misc/HubRestart.java +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.misc; - -/** - * A node will try to contact the hub it's registered to every RegistrationRequest.REGISTER_CYCLE - * millisec. If the hub crash, and is restarted, the node will register themselves again. - * - * @author freynaud - * - */ -public class HubRestart { -// -// private Hub hub; -// private GridRegistry registry; -// private SelfRegisteringRemote remote; -// private GridHubConfiguration config = new GridHubConfiguration(); -// -// @Before -// public void prepare() { -// config.host = "localhost"; -// config.port = PortProber.findFreePort(); -// config.timeout = 10; -// config.browserTimeout = 10; -// hub = GridTestHelper.getHub(config); -// registry = hub.getRegistry(); -// -// remote = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE); -// -// remote.getConfiguration().registerCycle = 250; -// -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); -// } -// -// @Test(timeout = 5000) -// public void nodeRegisterAgain() throws Exception { -// -// // every 5 sec, the node register themselves again. -// assertEquals(remote.getConfiguration().registerCycle.longValue(), 250); -// remote.startRegistrationProcess(); -// -// // should be up -// RegistryTestHelper.waitForNode(hub.getRegistry(), 1); -// -// assertEquals(remote.getConfiguration().timeout.intValue(), 10); -// assertEquals(remote.getConfiguration().browserTimeout.intValue(), 10); -// -// // crashing the hub. -// hub.stop(); -// -// // check that the remote do not crash if there is no hub to reply. -// Thread.sleep(1000); -// -// // and starting a new hub -// config.timeout = 20; -// config.browserTimeout = 20; -// hub = new Hub(config); -// registry = hub.getRegistry(); -// // should be empty -// assertEquals(registry.getAllProxies().size(), 0); -// hub.start(); -// -// // the node will appear again after 250 ms. -// RegistryTestHelper.waitForNode(hub.getRegistry(), 1); -// -// assertEquals(remote.getConfiguration().timeout.intValue(), 20); -// assertEquals(remote.getConfiguration().browserTimeout.intValue(), 20); -// } -// -// @After -// public void stop() { -// hub.stop(); -// remote.stopRemoteServer(); -// } -} diff --git a/java/test/org/openqa/grid/e2e/misc/HubRestartNeg.java b/java/test/org/openqa/grid/e2e/misc/HubRestartNeg.java deleted file mode 100644 index 96ebd46f39a25..0000000000000 --- a/java/test/org/openqa/grid/e2e/misc/HubRestartNeg.java +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.misc; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * by specifing a RegistrationRequest.REGISTER_CYCLE= -1 , the node to not try to register against - * the hub all the time. For such a node, if the hub crash, the node won't reconnect after the hub - * is restarted. - * - * @author freynaud - * - */ -public class HubRestartNeg { -// private Hub hub; -// private GridRegistry registry; -// private SelfRegisteringRemote remote; -// private GridHubConfiguration config = new GridHubConfiguration(); - - @Before - public void prepare() { -// config.host = "localhost"; -// config.port = PortProber.findFreePort(); -// hub = new Hub(config); -// registry = hub.getRegistry(); -// hub.start(); -// -// remote = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE); -// -// remote.getConfiguration().registerCycle = -1; -// -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); - } - - @Test(timeout = 5000) - public void nodeRegisterAgain() throws Exception { - -// // every 5 sec, the node register themselves again. -// assertEquals(remote.getConfiguration().registerCycle.longValue(), -1); -// remote.startRegistrationProcess(); -// -// // should be up -// RegistryTestHelper.waitForNode(hub.getRegistry(), 1); -// -// // crashing the hub. -// hub.stop(); -// -// // check that the remote do not crash if there is no hub to reply. -// Thread.sleep(1000); -// -// // and starting a new hub -// hub = new Hub(config); -// registry = hub.getRegistry(); -// // should be empty -// assertEquals(registry.getAllProxies().size(), 0); -// hub.start(); -// -// // the node will appear again after 250 ms. -// RegistryTestHelper.waitForNode(hub.getRegistry(), 0); - - } - - @After - public void stop() { -// hub.stop(); -// remote.stopRemoteServer(); - } -} diff --git a/java/test/org/openqa/grid/e2e/misc/WebDriverPriorityDemo.java b/java/test/org/openqa/grid/e2e/misc/WebDriverPriorityDemo.java deleted file mode 100644 index e02680c67eec1..0000000000000 --- a/java/test/org/openqa/grid/e2e/misc/WebDriverPriorityDemo.java +++ /dev/null @@ -1,209 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.misc; - -/** - * how to setup a grid that does not use FIFO for the requests. - */ -public class WebDriverPriorityDemo { -// -// private Hub hub = null; -// private GridRegistry registry = null; -// -// private SelfRegisteringRemote remote = null; -// -// private URL hubURL = null; -// private URL driverURL = null; -// private URL consoleURL = null; -// -// private WebDriver runningOne = null; -// private volatile WebDriver importantOne = null; -// private volatile boolean importantOneStarted = false; -// -// private DesiredCapabilities browser = null; -// private DesiredCapabilities important_browser = null; -// -// @Before -// public void prepare() { -// -// // start a small grid that only has 1 testing slot : htmlunit -// -// -// // assigning a priority rule where requests with the flag "important" go first. -// GridHubConfiguration hubConfiguration = new GridHubConfiguration(); -// hubConfiguration.prioritizer = new Prioritizer() { -// @Override -// public int compareTo(Map a, Map b) { -// boolean aImportant = -// a.get("grid:important") == null ? false : Boolean.parseBoolean(a.get("grid:important") -// .toString()); -// boolean bImportant = -// b.get("grid:important") == null ? false : Boolean.parseBoolean(b.get("grid:important") -// .toString()); -// if (aImportant == bImportant) { -// return 0; -// } -// if (aImportant && !bImportant) { -// return -1; -// } -// return 1; -// } -// }; -// -// hub = GridTestHelper.getHub(hubConfiguration, true); -// registry = hub.getRegistry(); -// -// hubURL = hub.getUrl(); -// driverURL = hub.getWebDriverHubRequestURL(); -// consoleURL = hub.getConsoleURL(); -// -// -// // initialize node -// -// browser = GridTestHelper.getDefaultBrowserCapability(); -// important_browser = GridTestHelper.getDefaultBrowserCapability(); -// important_browser.setCapability("grid:important", true); -// -// remote = GridTestHelper.getRemoteWithoutCapabilities(hubURL, GridRole.NODE); -// remote.addBrowser(browser, 1); -// -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); -// remote.setMaxConcurrent(1); -// remote.setTimeout(-1, -1); -// remote.sendRegistrationRequest(); -// -// RegistryTestHelper.waitForNode(registry, 1); -// assertEquals(1, registry.getAllProxies().size()); -// assertEquals(0, registry.getNewSessionRequestCount()); -// assertEquals(0, registry.getActiveSessions().size()); -// -// -// // mark the grid 100% busy = having 1 browser test running. -// runningOne = new RemoteWebDriver(driverURL, browser); -// visitHubConsole(runningOne); -// -// RegistryTestHelper.waitForActiveTestSessionCount(registry, 1); -// assertEquals(1, registry.getAllProxies().size()); -// assertEquals(0, registry.getNewSessionRequestCount()); -// assertEquals(1, registry.getActiveSessions().size()); -// -// -// // queuing 5 requests on the grid. -// for (int i = 0; i < 5; i++) { -// new Thread(new Runnable() { // Thread safety reviewed -// @Override -// public void run() { -// try { -// new RemoteWebDriver(driverURL, browser); -// } catch (Exception e) { -// throw new RuntimeException("Exception is occurred during driver instanciating", e); -// } -// } -// }).start(); -// } -// -// RegistryTestHelper.waitForNewSessionRequestCount(registry, 5); -// assertEquals(1, registry.getAllProxies().size()); -// assertEquals(5, registry.getNewSessionRequestCount()); -// assertEquals(1, registry.getActiveSessions().size()); -// -// -// // adding a request with high priority at the end of the queue -// new Thread(new Runnable() { // Thread safety reviewed -// @Override -// public void run() { -// try { -// importantOne = new RemoteWebDriver(driverURL, important_browser); -// importantOneStarted = true; -// } catch (Exception e) { -// throw new RuntimeException("Exception is occurred during driver instanciating", e); -// } -// } -// }).start(); -// -// RegistryTestHelper.waitForNewSessionRequestCount(registry, 6); -// assertEquals(1, registry.getAllProxies().size()); -// assertEquals(6, registry.getNewSessionRequestCount()); -// assertEquals(1, registry.getActiveSessions().size()); -// -// -// // then 5 more non-important requests -// for (int i = 0; i < 5; i++) { -// new Thread(new Runnable() { // Thread safety reviewed -// @Override -// public void run() { -// try { -// new RemoteWebDriver(driverURL, browser); -// } catch (Exception e) { -// throw new RuntimeException("Exception is occurred during driver instanciating", e); -// } -// } -// }).start(); -// } -// -// RegistryTestHelper.waitForNewSessionRequestCount(registry, 11); -// assertEquals(1, registry.getAllProxies().size()); -// assertEquals(11, registry.getNewSessionRequestCount()); -// assertEquals(1, registry.getActiveSessions().size()); -// } -// -// @Test(timeout = 20000) -// public void test5ValidateStateAndPickTheImportantOne() throws InterruptedException { -// try { -// // closing the running test. -// runningOne.quit(); -// -// RegistryTestHelper.waitForNewSessionRequestCount(registry, 10); -// assertEquals(1, registry.getAllProxies().size()); -// assertEquals(10, registry.getNewSessionRequestCount()); -// assertEquals(1, registry.getActiveSessions().size()); -// -// // TODO freynaud : sometines does not start. FF pops up, but address bar remains empty. -// while (!importantOneStarted) { -// Thread.sleep(250); -// System.out.println("waiting for browser to start"); -// } -// -// visitHubConsole(importantOne); -// -// } finally { -// // cleaning the queue to avoid having some browsers left over after -// // the test -// registry.clearNewSessionRequests(); -// importantOne.quit(); -// } -// -// } -// -// // simple helper -// private void visitHubConsole(WebDriver driver) { -// driver.get(consoleURL.toString()); -// assertEquals(driver.getTitle(), "Grid Console"); -// } -// -// @After -// public void stop() { -// if (remote != null) { -// remote.stopRemoteServer(); -// } -// if (hub != null) { -// hub.stop(); -// } -// } -} diff --git a/java/test/org/openqa/grid/e2e/node/BrowserTimeOutTest.java b/java/test/org/openqa/grid/e2e/node/BrowserTimeOutTest.java deleted file mode 100644 index 0bb228e5a3f37..0000000000000 --- a/java/test/org/openqa/grid/e2e/node/BrowserTimeOutTest.java +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.node; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * checks that the session is stopped and browser released when browser timeout happens. - */ -public class BrowserTimeOutTest { - -// private Hub hub; -// private SelfRegisteringRemote node; - - @Before - public void setup() { -// GridHubConfiguration gridHubConfiguration = new GridHubConfiguration(); -// gridHubConfiguration.port = PortProber.findFreePort(); -// gridHubConfiguration.host = "localhost"; -// -// gridHubConfiguration.browserTimeout = 5; -// gridHubConfiguration.servlets = -// Collections.singletonList("org.openqa.grid.e2e.node.SlowServlet"); -// hub = GridTestHelper.getHub(gridHubConfiguration); -// -// // register a selenium 1 -// node = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE); -// node.addBrowser(GridTestHelper.getSelenium1FirefoxCapability(), 1); -// node.addBrowser(GridTestHelper.getDefaultBrowserCapability(), 1); -// -// node.setRemoteServer(new SeleniumServer(node.getConfiguration())); -// node.startRemoteServer(); -// node.sendRegistrationRequest(); -// -// RegistryTestHelper.waitForNode(hub.getRegistry(), 1); - } - - - @Test - public void testWebDriverTimesOut() { -// String url = hub.getUrl("/grid/admin/SlowServlet").toExternalForm(); -// DesiredCapabilities caps = GridTestHelper.getDefaultBrowserCapability(); -// WebDriver driver = new RemoteWebDriver(hub.getWebDriverHubRequestURL(), caps); -// -// try { -// driver.get(url); -// } catch(WebDriverException ignore) { -// } finally { -// RegistryTestHelper.waitForActiveTestSessionCount(hub.getRegistry(), 0); -// } - } - - @After - public void teardown() { -// node.stopRemoteServer(); -// hub.stop(); - } -} diff --git a/java/test/org/openqa/grid/e2e/node/CrashWhenStartingBrowserTest.java b/java/test/org/openqa/grid/e2e/node/CrashWhenStartingBrowserTest.java deleted file mode 100644 index ef56a0a49a8fb..0000000000000 --- a/java/test/org/openqa/grid/e2e/node/CrashWhenStartingBrowserTest.java +++ /dev/null @@ -1,102 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.node; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -public class CrashWhenStartingBrowserTest { - -// private Hub hub; -// private SelfRegisteringRemote remote; -// private GridRegistry registry; -// private Wait wait = new FluentWait("").withTimeout(Duration.ofSeconds(30)); - - private String proxyId; - - private static final String WRONG_PATH = "stupidPathUnlikelyToExist"; - - @Before - public void prepareANodePointingToANonExistingFirefox() throws Exception { -// hub = GridTestHelper.getHub(); -// registry = hub.getRegistry(); -// -// remote = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE); -// -// remote.addBrowser(new DesiredCapabilities(new FirefoxOptions()), 1); -// -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); -// remote.sendRegistrationRequest(); -// RegistryTestHelper.waitForNode(registry, 1); -// -// proxyId = getProxyId(); - } - - @Test - public void serverCrashesStartingFirefox() { -// // should be up -// DefaultRemoteProxy p; -// assertEquals(1, registry.getAllProxies().size()); -// p = (DefaultRemoteProxy) registry.getAllProxies().getProxyById(proxyId); -// wait.until(isUp(p)); -// -// // no active sessions -// assertEquals("active session is found on empty grid", 0, registry.getActiveSessions().size()); -// -// try { -// Capabilities ff = new FirefoxOptions() -// .setBinary(WRONG_PATH); -// new RemoteWebDriver(hub.getWebDriverHubRequestURL(), ff); -// fail("Expected WebDriverException to be thrown"); -// } catch (SessionNotCreatedException expected) { -// assertTrue( -// "We'd like to assert the path is in the message, but the spec does not demand this", -// true); -// } -// -// RegistryTestHelper.waitForActiveTestSessionCount(registry, 0); - } - -// private Function isUp(final DefaultRemoteProxy proxy) { -// return input -> !proxy.isDown(); -// } - -// private String getProxyId() throws Exception { -// RemoteProxy p = null; -// for (RemoteProxy remoteProxy : registry.getAllProxies()) { -// p = remoteProxy; -// } -// if (p == null) { -// throw new Exception("Unable to find registered proxy at hub"); -// } -// String proxyId = p.getId(); -// if (proxyId == null) { -// throw new Exception("Unable to get id of proxy"); -// } -// return proxyId; -// } - - @After - public void stop() { -// remote.stopRemoteServer(); -// hub.stop(); - } -} diff --git a/java/test/org/openqa/grid/e2e/node/DefaultProxyIsUnregisteredIfDownForTooLongTest.java b/java/test/org/openqa/grid/e2e/node/DefaultProxyIsUnregisteredIfDownForTooLongTest.java deleted file mode 100644 index 80544e479bd37..0000000000000 --- a/java/test/org/openqa/grid/e2e/node/DefaultProxyIsUnregisteredIfDownForTooLongTest.java +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.node; - -public class DefaultProxyIsUnregisteredIfDownForTooLongTest { -// -// private Hub hub; -// private GridRegistry registry; -// private SelfRegisteringRemote remote; -// -// private String proxyId; -// -// @Before -// public void prepare() throws Exception { -// hub = GridTestHelper.getHub(); -// registry = hub.getRegistry(); -// -// remote = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE); -// -// // check if the node is up every 900 ms -// remote.getConfiguration().nodePolling = 900; -// // unregister the proxy is it's down for more than 10 sec in a row. -// remote.getConfiguration().unregisterIfStillDownAfter = 10000; -// // mark as down after 3 tries -// remote.getConfiguration().downPollingLimit = 3; -// // limit connection and socket timeout for node alive check up to -// remote.getConfiguration().nodeStatusCheckTimeout = 100; -// // add browser -// remote.addBrowser(GridTestHelper.getDefaultBrowserCapability(), 1); -// -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); -// remote.sendRegistrationRequest(); -// RegistryTestHelper.waitForNode(registry, 1); -// -// proxyId = getProxyId(); -// } -// -// @Test -// public void proxyIsUnregistered() throws InterruptedException { -// DefaultRemoteProxy p; -// -// // should be up -// assertEquals(1, registry.getAllProxies().size()); -// p = (DefaultRemoteProxy) registry.getAllProxies().getProxyById(proxyId); -// waitFor(isUp(p)); -// -// remote.stopRemoteServer(); -// -// // first mark down - proxy is not down, proxy is not unregistered. -// Thread.sleep(1500); -// assertEquals(1, registry.getAllProxies().size()); -// p = (DefaultRemoteProxy) registry.getAllProxies().getProxyById(proxyId); -// assertFalse(p.isDown()); -// -// // node is considered down - proxy is down, proxy is not unregistered. -// // sleep interval should be bigger than (STATUS_CHECK_TIMEOUT + NODE_POLLING) * DOWN_POLLING_LIMIT -// // but less than UNREGISTER_IF_STILL_DOWN_AFTER (with previous sleeps accounting). -// Thread.sleep(3500); -// assertEquals(1, registry.getAllProxies().size()); -// p = (DefaultRemoteProxy) registry.getAllProxies().getProxyById(proxyId); -// assertTrue(p.isDown()); -// -// Thread.sleep(10000); -// -// // and finally removed after time > UNREGISTER_IF_STILL_DOWN_AFTER -// RegistryTestHelper.waitForNode(registry, 0); -// } -// -// private Callable isUp(final DefaultRemoteProxy proxy) { -// return () -> ! proxy.isDown(); -// } -// -// private String getProxyId() throws Exception { -// RemoteProxy p = null; -// for (RemoteProxy remoteProxy : registry.getAllProxies()) { -// p = remoteProxy; -// } -// if (p == null) { -// throw new Exception("Unable to find registered proxy at hub"); -// } -// String proxyId = p.getId(); -// if (proxyId == null) { -// throw new Exception("Unable to get id of proxy"); -// } -// return proxyId; -// } -// -// @After -// public void tearDown() { -// hub.stop(); -// } -// -// private void waitFor(final Callable thing) { -// new FluentWait("").withTimeout(Duration.ofSeconds(30)).until( -// (Function) input -> { -// try { -// return thing.call(); -// } catch (Exception e) { -// throw new RuntimeException(e); -// } -// }); -// } -} diff --git a/java/test/org/openqa/grid/e2e/node/NodeGoingDownAndUpTest.java b/java/test/org/openqa/grid/e2e/node/NodeGoingDownAndUpTest.java deleted file mode 100644 index c88750ff1af4e..0000000000000 --- a/java/test/org/openqa/grid/e2e/node/NodeGoingDownAndUpTest.java +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.node; - -public class NodeGoingDownAndUpTest { - -// private Hub hub; -// private GridRegistry registry; -// private SelfRegisteringRemote remote; -// private Wait wait = new FluentWait("").withTimeout(Duration.ofSeconds(30)); -// -// @Before -// public void prepare() { -// hub = GridTestHelper.getHub(); -// registry = hub.getRegistry(); -// -// remote = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE); -// -// // check if the node is up every 900 ms -// remote.getConfiguration().nodePolling = 900; -// // unregister the proxy is it's down for more than 10 sec in a row. -// remote.getConfiguration().unregisterIfStillDownAfter = 10000; -// // mark as down after 3 tries -// remote.getConfiguration().downPollingLimit = 3; -// // limit connection and socket timeout for node alive check up to -// remote.getConfiguration().nodeStatusCheckTimeout = 100; -// // add browser -// remote.addBrowser(GridTestHelper.getDefaultBrowserCapability(), 1); -// -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); -// remote.sendRegistrationRequest(); -// RegistryTestHelper.waitForNode(registry, 1); -// } -// -// @Test -// public void markdown() { -// // should be up -// for (RemoteProxy proxy : registry.getAllProxies()) { -// wait.until(isUp((DefaultRemoteProxy) proxy)); -// } -// -// // killing the nodes -// remote.stopRemoteServer(); -// -// // should be down -// for (RemoteProxy proxy : registry.getAllProxies()) { -// wait.until(isDown((DefaultRemoteProxy) proxy)); -// } -// -// // and back up -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// remote.startRemoteServer(); -// -// // should be up -// for (RemoteProxy proxy : registry.getAllProxies()) { -// wait.until(isUp((DefaultRemoteProxy) proxy)); -// } -// } -// -// private Function isUp(final DefaultRemoteProxy proxy) { -// return input -> !proxy.isDown(); -// } -// -// private Function isDown(final DefaultRemoteProxy proxy) { -// return input -> proxy.isDown(); -// } -// -// @After -// public void stop() { -// hub.stop(); -// remote.stopRemoteServer(); -// } -} diff --git a/java/test/org/openqa/grid/e2e/node/NodeRecoveryTest.java b/java/test/org/openqa/grid/e2e/node/NodeRecoveryTest.java deleted file mode 100644 index 045352dc6fa20..0000000000000 --- a/java/test/org/openqa/grid/e2e/node/NodeRecoveryTest.java +++ /dev/null @@ -1,90 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.node; - -/** - * a node should be allowed to stop / crash and restart. When the node restarts, it replaces the old - * one, updating its configuration is necessary. - * - * @author freynaud - * - */ -public class NodeRecoveryTest { - -// private Hub hub; -// private SelfRegisteringRemote node; -// -// private final static int ORIGINAL_TIMEOUT = 3; -// private final static int NEW_TIMEOUT = 20; -// -// @Before -// public void setup() { -// GridHubConfiguration config = new GridHubConfiguration(); -// config.host = "localhost"; -// config.port = PortProber.findFreePort(); -// hub = new Hub(config); -// -// hub.start(); -// -// node = GridTestHelper.getRemoteWithoutCapabilities(hub.getUrl(), GridRole.NODE); -// node.getConfiguration().timeout = ORIGINAL_TIMEOUT; -// // register a selenium 1 with a timeout of 3 sec -// node.addBrowser(GridTestHelper.getDefaultBrowserCapability(), 1); -// node.setRemoteServer(new SeleniumServer(node.getConfiguration())); -// node.startRemoteServer(); -// node.sendRegistrationRequest(); -// RegistryTestHelper.waitForNode(hub.getRegistry(), 1); -// } -// -// @Test -// public void nodeServerCanStopAndRestart() throws Exception { -// -// assertEquals(hub.getRegistry().getAllProxies().size(), 1); -// for (RemoteProxy p : hub.getRegistry().getAllProxies()) { -// // Nodes fetch timeout and browserTimeout from the hub and update their configs -// assertEquals(ORIGINAL_TIMEOUT * 1000, p.getTimeOut()); -// } -// -// DesiredCapabilities caps = GridTestHelper.getDefaultBrowserCapability(); -// new RemoteWebDriver(hub.getWebDriverHubRequestURL(), caps); -// -// // kill the node -// node.stopRemoteServer(); -// -// // changing the node timeout, it should be kept after restarting and registering again -// node.getConfiguration().timeout = NEW_TIMEOUT; -// -// // restart it -// node.setRemoteServer(new SeleniumServer(node.getConfiguration())); -// node.startRemoteServer(); -// node.sendRegistrationRequest(); -// -// // the timeout of the original node should be reached, and the session freed -// Thread.sleep(ORIGINAL_TIMEOUT * 1000 + 100); -// -// assertEquals(hub.getRegistry().getActiveSessions().size(), 0); -// -// assertEquals(hub.getRegistry().getAllProxies().size(), 1); -// -// -// for (RemoteProxy p : hub.getRegistry().getAllProxies()) { -// assertEquals(p.getTimeOut(), NEW_TIMEOUT * 1000); -// } -// -// } -} diff --git a/java/test/org/openqa/grid/e2e/node/SmokeTest.java b/java/test/org/openqa/grid/e2e/node/SmokeTest.java deleted file mode 100644 index 8a61acc4fe3db..0000000000000 --- a/java/test/org/openqa/grid/e2e/node/SmokeTest.java +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.node; - -public class SmokeTest { - -// private Hub hub; -// -// @Before -// public void prepare() { -// hub = GridTestHelper.prepareTestGrid(1); -// } -// -// @Test -// public void browserOnWebDriver() { -// WebDriver driver = null; -// try { -// DesiredCapabilities caps = GridTestHelper.getDefaultBrowserCapability(); -// driver = new RemoteWebDriver(hub.getWebDriverHubRequestURL(), caps); -// driver.get(hub.getConsoleURL().toString()); -// assertEquals(driver.getTitle(), "Grid Console"); -// } finally { -// if (driver != null) { -// driver.quit(); -// } -// } -// } -// -// @After -// public void stop() { -// hub.stop(); -// } -// -} diff --git a/java/test/org/openqa/grid/e2e/utils/GridTestHelper.java b/java/test/org/openqa/grid/e2e/utils/GridTestHelper.java deleted file mode 100644 index 82162cd9d4613..0000000000000 --- a/java/test/org/openqa/grid/e2e/utils/GridTestHelper.java +++ /dev/null @@ -1,119 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.utils; - -public class GridTestHelper { - -// public static SelfRegisteringRemote getRemoteWithoutCapabilities(Hub hub, GridRole role) { -// return getRemoteWithoutCapabilities(hub.getUrl(), role); -// } - -// public static SelfRegisteringRemote getRemoteWithoutCapabilities(URL hub, GridRole role) { -// String[] args = {"-role", role.toString(), -// "-host","localhost", -// "-hub",hub.toString(), -// "-port",String.valueOf(PortProber.findFreePort())}; -// GridNodeCliOptions options = new GridNodeCliOptions(); -// JCommander.newBuilder().addObject(options).build().parse(args); -// GridNodeConfiguration config = new GridNodeConfiguration(options); -// RegistrationRequest req = RegistrationRequest.build(config); -// SelfRegisteringRemote remote = new SelfRegisteringRemote(req); -// remote.deleteAllBrowsers(); -// return remote; -// } - -// public static DesiredCapabilities getSelenium1FirefoxCapability() { -// DesiredCapabilities firefoxOnSeleniumCapability = new DesiredCapabilities(); -// firefoxOnSeleniumCapability.setBrowserName("*firefox"); -// firefoxOnSeleniumCapability.setCapability(RegistrationRequest.SELENIUM_PROTOCOL, -// SeleniumProtocol.Selenium); -// return firefoxOnSeleniumCapability; -// } - -// public static DesiredCapabilities getDefaultBrowserCapability() { -// String browser = System.getProperty("webdriver.gridtest.browser"); -// if (browser != null) { -// DesiredCapabilities caps = new DesiredCapabilities(); -// caps.setBrowserName(browser); -// return caps; -// } -// return new DesiredCapabilities(BrowserType.HTMLUNIT, "", Platform.ANY); -// } - -// public static Hub getHub() { -// return getHub(new GridHubConfiguration(), true); -// } - -// public static Hub getHub( -// GridHubConfiguration config, -// boolean dynamicallyAllocatePortOnLocalHost) { -// if (dynamicallyAllocatePortOnLocalHost) { -// config.host = "localhost"; -// config.port = PortProber.findFreePort(); -// } -// return getHub(config); -// } - -// public static Hub getHub(GridHubConfiguration config) { -// Hub hub = new Hub(config); -// try { -// hub.start(); -// } catch (Exception e) { -// fail("Expected hub to start: " + Throwables.getStackTraceAsString(e)); -// } -// return hub; -// } - -// public static Hub prepareTestGrid(int nodeCount) { -// return prepareTestGrid(getDefaultBrowserCapability(), nodeCount); -// } - -// public static Hub prepareTestGrid(Capabilities caps, int nodeCount) { -// Hub hub = GridTestHelper.getHub(); -// -// for (int i = 0; i < nodeCount; i++) { -// SelfRegisteringRemote remote = GridTestHelper.getRemoteWithoutCapabilities( -// hub.getUrl(), -// GridRole.NODE); -// remote.addBrowser(new DesiredCapabilities(caps), 1); -// -// DesiredCapabilities capabilities = new DesiredCapabilities(caps); -// capabilities.setCapability(RegistrationRequest.SELENIUM_PROTOCOL, SeleniumProtocol.WebDriver); -// -// remote.addBrowser(capabilities, 1); -// -// remote.setRemoteServer(new SeleniumServer(remote.getConfiguration())); -// -// try { -// remote.startRemoteServer(); -// } catch (Exception e) { -// fail("Unable to start node: " + Throwables.getStackTraceAsString(e)); -// } -// -// remote.getConfiguration().timeout = -1; -// remote.sendRegistrationRequest(); -// } -// -// RegistryTestHelper.waitForNode(hub.getRegistry(), nodeCount); -// return hub; -// } - -// public static RemoteWebDriver getRemoteWebDriver(Hub hub) { -// return new RemoteWebDriver(hub.getWebDriverHubRequestURL(), getDefaultBrowserCapability()); -// } -} diff --git a/java/test/org/openqa/grid/e2e/utils/RegistryTestHelper.java b/java/test/org/openqa/grid/e2e/utils/RegistryTestHelper.java deleted file mode 100644 index ed97261ca55e8..0000000000000 --- a/java/test/org/openqa/grid/e2e/utils/RegistryTestHelper.java +++ /dev/null @@ -1,63 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.utils; - -public class RegistryTestHelper { - -// private RegistryTestHelper() { -// // Utility class -// } -// -// /** -// * Wait for the registry to have exactly nodeNumber nodes registered. -// */ -// public static void waitForNode(final GridRegistry r, final int nodeNumber) { -// newWait().until(input -> { -// Integer i = r.getAllProxies().size(); -// if (i != nodeNumber) { -// return null; -// } -// return i; -// }); -// } -// -// -// public static void waitForActiveTestSessionCount(final GridRegistry r, final int activeTestSessions) { -// newWait().until(input -> { -// Integer i = r.getActiveSessions().size(); -// if (i != activeTestSessions) { -// return null; -// } -// return i; -// }); -// } -// -// public static void waitForNewSessionRequestCount(final GridRegistry r, final int newSessionRequestCount) { -// newWait().until(input -> { -// Integer i = r.getNewSessionRequestCount(); -// if (i != newSessionRequestCount) { -// return null; -// } -// return i; -// }); -// } -// -// private static Wait newWait() { -// return new FluentWait("").withTimeout(Duration.ofSeconds(30)); -// } -} diff --git a/java/test/org/openqa/grid/e2e/utils/TestHttpServlet.java b/java/test/org/openqa/grid/e2e/utils/TestHttpServlet.java deleted file mode 100644 index 23fef903cc469..0000000000000 --- a/java/test/org/openqa/grid/e2e/utils/TestHttpServlet.java +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.e2e.utils; - -import javax.servlet.http.HttpServlet; - -/** - * sample servlet for ExtraServletUtilTest - */ -public class TestHttpServlet extends HttpServlet { - -} diff --git a/java/test/org/openqa/grid/internal/ConcurrencyLockTest.java b/java/test/org/openqa/grid/internal/ConcurrencyLockTest.java deleted file mode 100644 index f31ca28cbf150..0000000000000 --- a/java/test/org/openqa/grid/internal/ConcurrencyLockTest.java +++ /dev/null @@ -1,117 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.internal; - -/** - * Check that 1 type of request doesn't block other requests. - *

- * For a hub capable of handling 1 FF and 1 IE for instance, if the hub already built a queue of FF - * requests and a IE request is received it should be processed right away and not blocked by the FF - * queue. - */ - -public class ConcurrencyLockTest { - -// private GridRegistry registry; -// -// private Map ie = new HashMap<>(); -// private Map ff = new HashMap<>(); -// -// /** -// * create a hub with 1 IE and 1 FF -// */ -// @Before -// public void setup() throws Exception { -// registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration())); -// ie.put(CapabilityType.APPLICATION_NAME, "IE"); -// ff.put(CapabilityType.APPLICATION_NAME, "FF"); -// -// RemoteProxy p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ie, "http://machine1:4444", registry); -// RemoteProxy p2 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine2:4444", registry); -// registry.add(p1); -// registry.add(p2); -// -// } -// -// private List results = Collections.synchronizedList(new ArrayList<>()); -// -// @Test(timeout = 10000) -// public void runTest() throws InterruptedException { -// List> caps = new ArrayList<>(); -// caps.add(ff); -// caps.add(ff); -// caps.add(ff); -// caps.add(ie); -// -// List threads = new ArrayList<>(); -// for (final Map cap : caps) { -// Thread t = new Thread(new Runnable() { // Thread safety reviewed -// @Override -// public void run() { -// try { -// runTests2(cap); -// } catch (InterruptedException e) { -// e.printStackTrace(); -// } -// } -// }); -// t.start(); -// threads.add(t); -// } -// -// for (Thread t : threads) { -// t.join(); -// } -// assertEquals(4, results.size()); -// assertEquals("IE", results.get(0)); -// assertEquals("FF", results.get(1)); -// assertEquals("FF", results.get(2)); -// assertEquals("FF", results.get(3)); -// } -// -// private void runTests2(Map cap) throws InterruptedException { -// -// MockedRequestHandler newSessionHandler = GridHelper.createNewSessionHandler(registry, cap); -// -// if (cap.get(CapabilityType.APPLICATION_NAME).equals("FF")) { -// // start the FF right away -// newSessionHandler.process(); -// TestSession s = newSessionHandler.getSession(); -// Thread.sleep(2000); -// results.add("FF"); -// ((DefaultGridRegistry) registry).terminateSynchronousFOR_TEST_ONLY(s); -// } else { -// // wait for 1 sec before starting IE to make sure the FF proxy is -// // busy with the 3 FF requests. -// Thread.sleep(1000); -// newSessionHandler.process(); -// results.add("IE"); -// } -// // at that point, the hub has recieved first 3 FF requests that are -// // queued and 1 IE request 1sec later, after the FF are already blocked -// // in the queue.The blocked FF request shouldn't block IE from starting, -// // so IE should be done first. -// } -// -// -// @After -// public void teardown() { -// registry.stop(); -// } -// -} diff --git a/java/test/org/openqa/grid/internal/GridInternalTests.java b/java/test/org/openqa/grid/internal/GridInternalTests.java deleted file mode 100644 index 16987e853f455..0000000000000 --- a/java/test/org/openqa/grid/internal/GridInternalTests.java +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.internal; - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; - -@RunWith(Suite.class) -@Suite.SuiteClasses({ - ConcurrencyLockTest.class, - PriorityTest.class, - PriorityTestLoad.class, -}) -public class GridInternalTests { -} diff --git a/java/test/org/openqa/grid/internal/PriorityTest.java b/java/test/org/openqa/grid/internal/PriorityTest.java deleted file mode 100644 index c5eb63c694664..0000000000000 --- a/java/test/org/openqa/grid/internal/PriorityTest.java +++ /dev/null @@ -1,128 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.internal; - -public class PriorityTest { - -// private GridRegistry registry; -// -// // priority rule : the request with the highest priority goes first. -// private static Prioritizer highestNumberHasPriority = new Prioritizer() { -// @Override -// public int compareTo(Map a, Map b) { -// int priorityA = Integer.parseInt(a.get("_priority").toString()); -// int priorityB = Integer.parseInt(b.get("_priority").toString()); -// return priorityB - priorityA; -// } -// }; -// -// private Map ff = new HashMap<>(); -// private RemoteProxy p1; -// -// private RequestHandler newSessionRequest1; -// private RequestHandler newSessionRequest2; -// private RequestHandler newSessionRequest3; -// private RequestHandler newSessionRequest4; -// private RequestHandler newSessionRequest5; -// -// private List requests = new ArrayList<>(); -// -// /** -// * create a hub with 1 FF -// */ -// @Before -// public void setup() throws Exception { -// registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration())); -// registry.getHub().getConfiguration().prioritizer = highestNumberHasPriority; -// ff.put(CapabilityType.APPLICATION_NAME, "FF"); -// p1 = RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry); -// registry.add(p1); -// -// // create 5 sessionRequest, with priority =1 .. 5 -// Map ff1 = new HashMap<>(); -// ff1.put(CapabilityType.APPLICATION_NAME, "FF"); -// ff1.put("_priority", 1); -// -// Map ff2 = new HashMap<>(); -// ff2.put(CapabilityType.APPLICATION_NAME, "FF"); -// ff2.put("_priority", 2); -// -// Map ff3 = new HashMap<>(); -// ff3.put(CapabilityType.APPLICATION_NAME, "FF"); -// ff3.put("_priority", 3); -// -// Map ff4 = new HashMap<>(); -// ff4.put(CapabilityType.APPLICATION_NAME, "FF"); -// ff4.put("_priority", 4); -// -// Map ff5 = new HashMap<>(); -// ff5.put(CapabilityType.APPLICATION_NAME, "FF"); -// ff5.put("_priority", 5); -// -// newSessionRequest1 = GridHelper.createNewSessionHandler(registry, ff1); -// newSessionRequest2 = GridHelper.createNewSessionHandler(registry, ff2); -// newSessionRequest3 = GridHelper.createNewSessionHandler(registry, ff3); -// newSessionRequest4 = GridHelper.createNewSessionHandler(registry, ff4); -// newSessionRequest5 = GridHelper.createNewSessionHandler(registry, ff5); -// -// requests.add(newSessionRequest1); -// requests.add(newSessionRequest2); -// requests.add(newSessionRequest5); -// requests.add(newSessionRequest3); -// requests.add(newSessionRequest4); -// -// RequestHandler newSessionRequest = GridHelper.createNewSessionHandler(registry, ff); -// newSessionRequest.process(); -// TestSession session = newSessionRequest.getSession(); -// -// // fill the queue with 5 requests. -// for (RequestHandler h : requests) { -// final RequestHandler req = h; -// new Thread(new Runnable() { // Thread safety reviewed -// @Override -// public void run() { -// req.process(); -// } -// }).start(); -// } -// -// while (registry.getNewSessionRequestCount() != 5) { -// Thread.sleep(100); -// } -// -// // free the grid : the queue is consumed, and the test with the highest -// // priority should be processed. -// ((DefaultGridRegistry) registry).terminateSynchronousFOR_TEST_ONLY(session); -// -// } -// -// -// // validate that the one with priority 5 has been assigned a proxy -// @Test -// public void validate() throws InterruptedException { -// Thread.sleep(250); -// assertNotNull(newSessionRequest5.getSession()); -// } -// -// -// @After -// public void teardown() { -// registry.stop(); -// } -// -} diff --git a/java/test/org/openqa/grid/internal/PriorityTestLoad.java b/java/test/org/openqa/grid/internal/PriorityTestLoad.java deleted file mode 100644 index bcfa2534e54d2..0000000000000 --- a/java/test/org/openqa/grid/internal/PriorityTestLoad.java +++ /dev/null @@ -1,120 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.internal; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - - -/** - * Grid with only 1 node. Sending MAX thread in it to load the queue and keep it ordered. - */ -public class PriorityTestLoad { - - private final static int MAX = 100; - -// private GridRegistry registry; - - // priority rule : the request with the highest priority goes first. -// private Prioritizer highestNumberHasPriority = new Prioritizer() { -// @Override -// public int compareTo(Map a, Map b) { -// int priorityA = Integer.parseInt(a.get("_priority").toString()); -// int priorityB = Integer.parseInt(b.get("_priority").toString()); -// return priorityB - priorityA; -// } -// }; - - private Map ff = new HashMap<>(); -// private List requests = new ArrayList<>(); - - private volatile boolean reqDone = false; - - /** - * create a hub with 1 FF - */ - @Before - public void setup() throws Exception { -// registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration())); -// registry.getHub().getConfiguration().prioritizer = highestNumberHasPriority; -// ff.put(CapabilityType.APPLICATION_NAME, "FF"); -// RemoteProxy -// p1 = -// RemoteProxyFactory.getNewBasicRemoteProxy(ff, "http://machine1:4444", registry); -// registry.add(p1); -// -// for (int i = 1; i <= MAX; i++) { -// Map cap = new HashMap<>(); -// cap.put(CapabilityType.APPLICATION_NAME, "FF"); -// cap.put("_priority", i); -// RequestHandler req = GridHelper.createNewSessionHandler(registry, cap); -// requests.add(req); -// } -// -// // use all the proxies -// RequestHandler newSessionRequest = GridHelper.createNewSessionHandler(registry, ff); -// newSessionRequest.process(); -// TestSession session = newSessionRequest.getSession(); -// -// // and keep adding request in the queue. -// for (RequestHandler h : requests) { -// final RequestHandler req = h; -// new Thread(new Runnable() { // Thread safety reviewed -// @Override -// public void run() { -// req.process(); -// reqDone = true; -// } -// }).start(); -// } -// -// // wait for all the request to reach the queue. -// while (registry.getNewSessionRequestCount() != MAX) { -// Thread.sleep(250); -// } -// -// // release the initial request. -// ((DefaultGridRegistry) registry).terminateSynchronousFOR_TEST_ONLY(session); - } - - // validate that the one with priority MAX has been assigned a proxy - @Test(timeout = 5000) - public void validate() throws InterruptedException { -// // using a flag here. The queue contains all the requests. -// // when release is executed, 1 slot is -// // freed.The iteration over the queue to sort + find the match isn't -// // instant. -// while (!reqDone) { -// Thread.sleep(20); -// } -// assertNotNull(requests.get(requests.size() - 1).getSession()); -// assertEquals( -// requests.get(requests.size() - 1).getRequest().getDesiredCapabilities().get("_priority"), -// MAX); - } - - @After - public void teardown() { -// registry.stop(); - } - -} diff --git a/java/test/org/openqa/grid/internal/mock/GridHelper.java b/java/test/org/openqa/grid/internal/mock/GridHelper.java deleted file mode 100644 index 3a8f4feb849ab..0000000000000 --- a/java/test/org/openqa/grid/internal/mock/GridHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.internal.mock; - -/** - * create mocked object for testing grid internal. - * Objects will have all the normal object characteristics, - * and will reserve/release the resources on the hub, but will - * not forward the requests to the nodes. - */ -public class GridHelper { - -// public static MockedRequestHandler createNewSessionHandler(GridRegistry registry, -// Map desiredCapability) { -// SeleniumBasedRequest request = -// createNewSessionRequest(registry, desiredCapability); -// return new MockedRequestHandler(request, null, registry); -// } -// -// -// public static MockedRequestHandler createStopSessionHandler(GridRegistry registry, TestSession session) { -// SeleniumBasedRequest request = createMockedRequest(registry, RequestType.STOP_SESSION, null); -// MockedRequestHandler handler = new MockedRequestHandler(request, null, registry); -// handler.setSession(session); -// return handler; -// } -// -// public static SeleniumBasedRequest createMockedRequest(GridRegistry registry, -// RequestType type, Map desiredCapability) { -// HttpServletRequest request = mock(HttpServletRequest.class); -// return new SeleniumBasedRequest(request, registry, type, desiredCapability) { -// -// @Override -// public ExternalSessionKey extractSession() { -// return null; -// } -// -// @Override -// public RequestType extractRequestType() { -// return null; -// } -// -// @Override -// public Map extractDesiredCapability() { -// return getDesiredCapabilities(); -// } -// }; -// } -// -// public static SeleniumBasedRequest createNewSessionRequest(GridRegistry registry, -// Map desiredCapability) { -// return createMockedRequest(registry, RequestType.START_SESSION, desiredCapability); -// } -} diff --git a/java/test/org/openqa/grid/selenium/proxy/DefaultRemoteProxyTest.java b/java/test/org/openqa/grid/selenium/proxy/DefaultRemoteProxyTest.java deleted file mode 100644 index 6d695987cd2b5..0000000000000 --- a/java/test/org/openqa/grid/selenium/proxy/DefaultRemoteProxyTest.java +++ /dev/null @@ -1,96 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.selenium.proxy; - -import org.junit.After; -import org.junit.Test; -import org.openqa.selenium.grid.jmx.JMXHelper; - -import java.util.concurrent.TimeoutException; - -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; - - -public class DefaultRemoteProxyTest { - - @Test - public void ensureCleanupHappensWhenProxyTimesoutAndCleanupIsEnabled() - throws TimeoutException, InterruptedException { -// BaseRemoteProxy p = createProxyAndSimulateTimeout(1000); -// assertTrue("Ensure there are NO active sessions", -// p.getRegistry().getActiveSessions().isEmpty()); -// assertEquals("Ensure that there are NO used slots", 0, p.getTotalUsed()); - } - - @Test - public void ensureNoCleanupHappensWhenProxyTimesoutAndCleanupIsDisabled() - throws TimeoutException, InterruptedException { -// BaseRemoteProxy p = createProxyAndSimulateTimeout(0); -// assertFalse("Ensure there are active sessions", p.getRegistry().getActiveSessions().isEmpty()); -// assertEquals("Ensure that 1 slot is still marked as in use", 1, p.getTotalUsed()); - } - - @After - public void unregisterHubFromJMX() throws MalformedObjectNameException { - ObjectName obj = new ObjectName("org.seleniumhq.grid:type=Hub"); - new JMXHelper().unregister(obj); - } - - private static Object createProxyAndSimulateTimeout(int cleanupCycle) - throws TimeoutException, InterruptedException { -// GridRegistry registry = DefaultGridRegistry.newInstance(new Hub(new GridHubConfiguration())); -// registry.getHub().getConfiguration().timeout = 1; -// registry.getHub().getConfiguration().cleanUpCycle = cleanupCycle; -// String[] args = new String[]{"-role", "webdriver"}; -// GridNodeCliOptions options = new GridNodeCliOptions(); -// JCommander.newBuilder().addObject(options).build().parse(args); -// GridNodeConfiguration nodeConfiguration = new GridNodeConfiguration(options); -// nodeConfiguration.port = new Random().nextInt(100); -// nodeConfiguration.timeout = 1; -// RegistrationRequest req = RegistrationRequest.build(nodeConfiguration); -// req.getConfiguration().proxy = DefaultRemoteProxy.class.getName(); -// BaseRemoteProxy p = createMockProxyWithPollingDisabled(req, registry); -// MockedRequestHandler reqHandler = GridHelper.createNewSessionHandler(registry, new HashMap<>()); -// registry.addNewSessionRequest(reqHandler); -// reqHandler.waitForSessionBound(); -// assertFalse("Ensure a new session was created", registry.getActiveSessions().isEmpty()); -// simulateTimeout(cleanupCycle); -// return p; - - return null; - } - - private static void simulateTimeout(int cleanupCycle) { - int sleepMoreThanCleanupCycle = cleanupCycle + 1000; - try { - Thread.sleep(sleepMoreThanCleanupCycle); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - -// private static BaseRemoteProxy createMockProxyWithPollingDisabled(RegistrationRequest req, -// GridRegistry registry) { -// BaseRemoteProxy p = BaseRemoteProxy.getNewInstance(req, registry); -// registry.add(p); -// ((SelfHealingProxy) p).stopPolling(); -// return p; -// } - -} diff --git a/java/test/org/openqa/grid/web/servlet/BaseServletTest.java b/java/test/org/openqa/grid/web/servlet/BaseServletTest.java deleted file mode 100644 index faa7bd6a83900..0000000000000 --- a/java/test/org/openqa/grid/web/servlet/BaseServletTest.java +++ /dev/null @@ -1,75 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -package org.openqa.grid.web.servlet; - -import org.openqa.selenium.json.Json; -import org.openqa.testing.FakeHttpServletRequest; -import org.openqa.testing.FakeHttpServletResponse; -import org.openqa.testing.UrlInfo; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; - - -public class BaseServletTest { - private static final String BASE_URL = "http://localhost:4444"; - private static final String CONTEXT_PATH = "/"; - - protected HttpServlet servlet; - - protected static UrlInfo createUrl(String path) { - return new UrlInfo(BASE_URL, CONTEXT_PATH, path); - } - - protected FakeHttpServletResponse sendCommand(String method, String commandPath) - throws IOException, ServletException { - return sendCommand(method, commandPath, null); - } - - protected FakeHttpServletResponse sendCommand( - String method, - String commandPath, - Map parameters) throws IOException, ServletException { - return sendCommand(this.servlet,method, commandPath, parameters); - } - - protected static FakeHttpServletResponse sendCommand( - HttpServlet servlet, - String method, - String commandPath, - Map parameters) throws IOException, ServletException { - FakeHttpServletRequest request = new FakeHttpServletRequest(method, createUrl(commandPath)); - if ("get".equalsIgnoreCase(method) && parameters != null) { - Map params = new HashMap<>(); - for (Map.Entry parameter : parameters.entrySet()) { - params.put(parameter.getKey(), parameter.getValue().toString()); - } - request.setParameters(params); - } - if ("post".equalsIgnoreCase(method) && parameters != null) { - request.setBody(new Json().toJson(parameters)); - } - FakeHttpServletResponse response = new FakeHttpServletResponse(); - servlet.service(request, response); - return response; - } -}