-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for customisation of TestSlot (#3431)
The current implementation does not let downstream consumers of the Grid provide a customised way of injecting a TestSlot. This is very useful when one needs to build an On-Demand Grid, wherein there are no real proxies, but a ghost proxy stands for the real proxy and based on new session requests, nodes are spun off. * Fixed this by defining a method for instantiating a TestSlot so that downstream RemoteProxy implementations can choose to provide their own customised TestSlots. * enhanced the SeleniumProtocol enum to house all logic related to forming the protocol and the path from a desired capability into it. * exposed the matches() method from TestSlot. Downstream consumers of TestSlot would need access to alter the logic of matches() method because sometimes TestSlots would blindly need to return true for all calls to matches() invocation [ This is true when one is building a ghost proxy which doesn’t represent any real node, but stands as a proxy for something such as a docker daemon from where the actual sessions would be honoured ] Without this, end-users would be forced to have their customized TestSlots reside in the same package as that of TestSlot (org.openqa.grid.internal)
- Loading branch information
1 parent
2e64afb
commit 5806700
Showing
9 changed files
with
159 additions
and
48 deletions.
There are no files selected for viewing
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
30 changes: 30 additions & 0 deletions
30
java/server/test/org/openqa/grid/common/SeleniumProtocolTest.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,30 @@ | ||
package org.openqa.grid.common; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
import org.openqa.selenium.remote.DesiredCapabilities; | ||
|
||
import java.util.Map; | ||
|
||
public class SeleniumProtocolTest { | ||
|
||
@Test | ||
public void getPathTest() { | ||
|
||
//Ensuring that when path is specified via capabilities, that is what we get back in return. | ||
DesiredCapabilities caps = new DesiredCapabilities(); | ||
caps.setCapability(RegistrationRequest.SELENIUM_PROTOCOL, SeleniumProtocol.WebDriver.toString()); | ||
caps.setCapability(RegistrationRequest.PATH, "foo/bar"); | ||
SeleniumProtocol protocol = SeleniumProtocol.fromCapabilitiesMap(caps.asMap()); | ||
assertEquals(SeleniumProtocol.WebDriver, protocol); | ||
assertEquals("foo/bar", protocol.getPathConsideringCapabilitiesMap((Map<String, Object>) caps.asMap())); | ||
|
||
//Ensuring that by default we parse the protocol as WebDriver and we get back its default path. | ||
caps = new DesiredCapabilities(); | ||
protocol = SeleniumProtocol.fromCapabilitiesMap(caps.asMap()); | ||
assertEquals(SeleniumProtocol.WebDriver, protocol); | ||
assertEquals("/wd/hub", protocol.getPathConsideringCapabilitiesMap((Map<String, Object>) caps.asMap())); | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.openqa.grid.internal; | ||
|
||
import org.openqa.grid.common.SeleniumProtocol; | ||
|
||
import java.util.Map; | ||
|
||
public class MyTestSlot extends TestSlot { | ||
private String slotName; | ||
|
||
public MyTestSlot(RemoteProxy proxy, SeleniumProtocol protocol, | ||
Map<String, Object> capabilities) { | ||
super(proxy, protocol, capabilities); | ||
} | ||
|
||
public void setSlotName(String slotName) { | ||
this.slotName = slotName; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return slotName + super.toString(); | ||
} | ||
} |