Skip to content

Commit

Permalink
[Grid] Passing throwOnCapabilityNotPresent properly to the ProxySet,
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol authored and Grigory Mischenko committed Sep 20, 2018
1 parent ce05494 commit 27752d7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
5 changes: 5 additions & 0 deletions java/server/src/org/openqa/grid/internal/ProxySet.java
Expand Up @@ -160,4 +160,9 @@ public void verifyAbilityToHandleDesiredCapabilities(Map<String, Object> desired
public void setThrowOnCapabilityNotPresent(boolean throwOnCapabilityNotPresent) {
this.throwOnCapabilityNotPresent = throwOnCapabilityNotPresent;
}

public boolean isThrowOnCapabilityNotPresent() {
return throwOnCapabilityNotPresent;
}

}
1 change: 1 addition & 0 deletions java/server/src/org/openqa/grid/web/Hub.java
Expand Up @@ -93,6 +93,7 @@ public Hub(GridHubConfiguration gridHubConfiguration) {
try {
registry = (GridRegistry) Class.forName(config.registry).newInstance();
registry.setHub(this);
registry.setThrowOnCapabilityNotPresent(config.throwOnCapabilityNotPresent);
} catch (Throwable e) {
throw new GridConfigurationException("Error creating class with " + config.registry +
" : " + e.getMessage(), e);
Expand Down
Expand Up @@ -19,6 +19,8 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import com.google.common.base.Function;
Expand Down Expand Up @@ -230,6 +232,40 @@ public void testRegisterNodeToHub() throws Exception {
checkPresenceOfElementOnHubConsole(hubPort, By.cssSelector("img[src$='htmlunit.png']"));
}

/*
throwOnCapabilityNotPresent is a flag used in the ProxySet. It is configured in the hub,
and then passed to the registry, finally to the ProxySet.
This test checks that the flag value makes it all the way to the ProxySet. Default is "true".
*/
@Test
public void testThrowOnCapabilityNotPresentFlagIsUsed() throws Exception {
Integer hubPort = PortProber.findFreePort();
String[] hubArgs = {"-role", "hub", "-host", "localhost", "-port", hubPort.toString(),
"-throwOnCapabilityNotPresent", "true"};

server = new GridLauncherV3(hubArgs).launch();
Hub hub = (Hub) server.orElse(null);
assertNotNull("Hub didn't start with given parameters." ,hub);

assertTrue("throwOnCapabilityNotPresent was false in the Hub and it was passed as true",
hub.getConfiguration().throwOnCapabilityNotPresent);
assertTrue("throwOnCapabilityNotPresent was false in the ProxySet and it was passed as true",
hub.getRegistry().getAllProxies().isThrowOnCapabilityNotPresent());

// Stopping the hub and starting it with a new throwOnCapabilityNotPresent value
hub.stop();
hubArgs = new String[]{"-role", "hub", "-host", "localhost", "-port", hubPort.toString(),
"-throwOnCapabilityNotPresent", "false"};
server = new GridLauncherV3(hubArgs).launch();
hub = (Hub) server.orElse(null);
assertNotNull("Hub didn't start with given parameters." ,hub);

assertFalse("throwOnCapabilityNotPresent was true in the Hub and it was passed as false",
hub.getConfiguration().throwOnCapabilityNotPresent);
assertFalse("throwOnCapabilityNotPresent was true in the ProxySet and it was passed as false",
hub.getRegistry().getAllProxies().isThrowOnCapabilityNotPresent());
}

@Test
public void canStartHubUsingConfigFile() throws Exception {
Integer hubPort = PortProber.findFreePort();
Expand Down

0 comments on commit 27752d7

Please sign in to comment.