-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing grid launching with node role and including -browser
JCommander Converters need to be in their own class file, since when running tests inside the IDE java will think they have a declared constructor even though they don't, simply because they are an inner class. created a new e2e test that mimics the real world example that everyone does Fixes #2355
- Loading branch information
Showing
16 changed files
with
224 additions
and
46 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...penqa/grid/internal/utils/configuration/converters/BrowserDesiredCapabilityConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.openqa.grid.internal.utils.configuration.converters; | ||
|
||
import com.beust.jcommander.IStringConverter; | ||
|
||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
|
||
public class BrowserDesiredCapabilityConverter implements IStringConverter<DesiredCapabilities> { | ||
@Override | ||
public DesiredCapabilities convert(String value) { | ||
DesiredCapabilities capabilities = new DesiredCapabilities(); | ||
for (String cap : value.split(",")) { | ||
String[] pieces = cap.split("="); | ||
if (pieces[0].equals("maxInstances")) { | ||
capabilities.setCapability(pieces[0], Integer.parseInt(pieces[1], 10)); | ||
} else { | ||
capabilities.setCapability(pieces[0], pieces[1]); | ||
} | ||
} | ||
return capabilities; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
java/server/src/org/openqa/grid/internal/utils/configuration/converters/CustomConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.openqa.grid.internal.utils.configuration.converters; | ||
|
||
import com.beust.jcommander.IStringConverter; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class CustomConverter implements IStringConverter<Map<String,String>> { | ||
@Override | ||
public Map<String,String> convert(String value) { | ||
Map<String,String> custom = new HashMap<>(); | ||
for (String pair : value.split(",")) { | ||
String[] pieces = pair.split("="); | ||
custom.put(pieces[0], pieces[1]); | ||
} | ||
return custom; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...er/src/org/openqa/grid/internal/utils/configuration/converters/NoOpParameterSplitter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.openqa.grid.internal.utils.configuration.converters; | ||
|
||
import com.beust.jcommander.converters.IParameterSplitter; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class NoOpParameterSplitter implements IParameterSplitter { | ||
@Override | ||
public List<String> split(String value) { | ||
return Arrays.asList(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
java/server/test/org/openqa/grid/e2e/misc/GridViaCommandLineTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// 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 junit.framework.Assert; | ||
|
||
import org.junit.Test; | ||
import org.openqa.grid.selenium.GridLauncherV3; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.net.UrlChecker; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
|
||
import java.net.URL; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
/** | ||
* Ensure that launching the hub / node in most common ways simulating command line args works | ||
*/ | ||
public class GridViaCommandLineTest { | ||
|
||
@Test | ||
public void testRegisterNodeToHub() throws Exception { | ||
String[] hubArgs = {"-role", "hub"}; | ||
GridLauncherV3.main(hubArgs); | ||
UrlChecker urlChecker = new UrlChecker(); | ||
urlChecker.waitUntilAvailable(10, TimeUnit.SECONDS, new URL("http://localhost:4444/grid/console")); | ||
|
||
String[] nodeArgs = {"-role", "node", "-hub", "http://localhost:4444", "-browser", "browserName=chrome,maxInstances=1"}; | ||
GridLauncherV3.main(nodeArgs); | ||
urlChecker.waitUntilAvailable(100, TimeUnit.SECONDS, new URL("http://localhost:5555/wd/hub/status")); | ||
|
||
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), | ||
DesiredCapabilities.chrome()); | ||
|
||
try { | ||
driver.get("http://localhost:4444/grid/console"); | ||
Assert.assertEquals("Should only have one chrome registered to the hub", 1, driver.findElements(By.cssSelector("img[src$='chrome.png']")).size()); | ||
} finally { | ||
try { | ||
driver.quit(); | ||
} catch (Exception e) {} | ||
} | ||
|
||
|
||
} | ||
} |
Oops, something went wrong.