Skip to content

Commit 0c02532

Browse files
committed
[grid] Displaying the real stereotype config at startup
1 parent 79c7847 commit 0c02532

File tree

8 files changed

+37
-1
lines changed

8 files changed

+37
-1
lines changed

java/src/org/openqa/selenium/grid/node/SessionFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ public interface SessionFactory extends
2929
Function<CreateSessionRequest, Either<WebDriverException, ActiveSession>>,
3030
Predicate<Capabilities> {
3131

32+
Capabilities getStereotype();
3233
}

java/src/org/openqa/selenium/grid/node/config/DriverServiceSessionFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public DriverServiceSessionFactory(
9595
this.sessionCapabilitiesMutator = new SessionCapabilitiesMutator(this.stereotype);
9696
}
9797

98+
@Override
99+
public Capabilities getStereotype() {
100+
return stereotype;
101+
}
102+
98103
@Override
99104
public boolean test(Capabilities capabilities) {
100105
return predicate.test(capabilities);

java/src/org/openqa/selenium/grid/node/config/NodeOptions.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,12 @@ private void report(Map.Entry<WebDriverInfo, Collection<SessionFactory>> entry)
651651
StringBuilder caps = new StringBuilder();
652652
try (JsonOutput out = JSON.newOutput(caps)) {
653653
out.setPrettyPrint(false);
654-
out.write(entry.getKey().getCanonicalCapabilities());
654+
Optional<SessionFactory> optionalSessionFactory = entry.getValue().stream().findFirst();
655+
if (optionalSessionFactory.isPresent()) {
656+
out.write(optionalSessionFactory.get().getStereotype());
657+
} else {
658+
out.write(entry.getKey().getCanonicalCapabilities());
659+
}
655660
}
656661

657662
LOG.info(String.format(

java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ public DockerSessionFactory(
134134
this.slotMatcher = new DefaultSlotMatcher();
135135
}
136136

137+
@Override
138+
public Capabilities getStereotype() {
139+
return stereotype;
140+
}
141+
137142
@Override
138143
public boolean test(Capabilities capabilities) {
139144
return slotMatcher.matches(stereotype, capabilities);

java/src/org/openqa/selenium/grid/node/relay/RelaySessionFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ public RelaySessionFactory(
9797
.copyOf(Require.nonNull("Stereotype", stereotype));
9898
}
9999

100+
@Override
101+
public Capabilities getStereotype() {
102+
return stereotype;
103+
}
104+
100105
@Override
101106
public boolean test(Capabilities capabilities) {
102107
// If a request reaches this point is because the basic match of W3C caps has already been done.

java/test/org/openqa/selenium/grid/graphql/GraphqlHandlerTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ void shouldBeAbleToGetUrlsOfAllNodes() throws URISyntaxException {
254254
String nodeUri = "http://localhost:5556";
255255
Node node = LocalNode.builder(tracer, bus, new URI(nodeUri), publicUri, registrationSecret)
256256
.add(stereotype, new SessionFactory() {
257+
@Override
258+
public Capabilities getStereotype() {
259+
return null;
260+
}
261+
257262
@Override
258263
public Either<WebDriverException, ActiveSession> apply(
259264
CreateSessionRequest createSessionRequest) {

java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ public static class HelperFactory {
613613

614614
public static SessionFactory create(Config config, Capabilities caps) {
615615
return new SessionFactory() {
616+
@Override
617+
public Capabilities getStereotype() {
618+
return null;
619+
}
620+
616621
@Override
617622
public Either<WebDriverException, ActiveSession> apply(
618623
CreateSessionRequest createSessionRequest) {

java/test/org/openqa/selenium/grid/testing/TestSessionFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public TestSessionFactory(Capabilities stereotype, BiFunction<SessionId, Capabil
5757
this.sessionGenerator = sessionGenerator;
5858
}
5959

60+
@Override
61+
public Capabilities getStereotype() {
62+
return stereotype;
63+
}
64+
6065
@Override
6166
public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sessionRequest) {
6267
SessionId id = new SessionId(UUID.randomUUID());

0 commit comments

Comments
 (0)