Skip to content

Commit

Permalink
[grid]: Distributor could not get session timeout from RemoteNode status
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Oct 9, 2024
1 parent 2cc7a5b commit 10e3510
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions java/src/org/openqa/selenium/grid/graphql/Grid.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public List<Node> getNodes() {
status.getExternalUri(),
status.getAvailability(),
status.getMaxSessionCount(),
status.getSessionTimeout(),
status.getSlots().size(),
stereotypes,
sessions,
Expand Down
8 changes: 8 additions & 0 deletions java/src/org/openqa/selenium/grid/graphql/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import com.google.common.collect.ImmutableList;
import java.net.URI;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -43,12 +44,14 @@ public class Node {
private final String version;
private final OsInfo osInfo;
private final int slotCount;
private final Duration sessionTimeout;

public Node(
NodeId id,
URI uri,
Availability status,
int maxSession,
Duration sessionTimeout,
int slotCount,
Map<Capabilities, Integer> stereotypes,
Map<Session, Slot> activeSessions,
Expand All @@ -63,6 +66,7 @@ public Node(
this.activeSessions = Require.nonNull("Active sessions", activeSessions);
this.version = Require.nonNull("Grid Node version", version);
this.osInfo = Require.nonNull("Grid Node OS info", osInfo);
this.sessionTimeout = Require.positive("Node session timeout", sessionTimeout);
}

public List<org.openqa.selenium.grid.graphql.Session> getSessions() {
Expand Down Expand Up @@ -122,6 +126,10 @@ public OsInfo getOsInfo() {
return osInfo;
}

public Duration getSessionTimeout() {
return sessionTimeout;
}

private org.openqa.selenium.grid.graphql.Session createGraphqlSession(
Map.Entry<Session, Slot> entry) {
Session session = entry.getKey();
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/grid/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ protected Node(
this.tracer = Require.nonNull("Tracer", tracer);
this.id = Require.nonNull("Node id", id);
this.uri = Require.nonNull("URI", uri);
this.sessionTimeout = Require.positive("Session timeout", sessionTimeout);
this.sessionTimeout = Require.positive("Node session timeout", sessionTimeout);
Require.nonNull("Registration secret", registrationSecret);

RequiresSecretFilter requiresSecret = new RequiresSecretFilter(registrationSecret);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public HttpResponse execute(HttpRequest req) {
.put("id", node.getNodeId())
.put("uri", node.getExternalUri())
.put("maxSessions", node.getMaxSessionCount())
.put("sessionTimeout", node.getSessionTimeout().toMillis())
.put("osInfo", node.getOsInfo())
.put("heartbeatPeriod", node.getHeartbeatPeriod().toMillis())
.put("availability", node.getAvailability())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void setUp() throws URISyntaxException {
LocalNode.builder(tracer, bus, uri, uri, registrationSecret)
.add(caps, new TestSessionFactory((id, c) -> new Handler(c)))
.maximumConcurrentSessions(2)
.sessionTimeout(Duration.ofSeconds(30))
.build();

wait =
Expand Down Expand Up @@ -143,6 +144,7 @@ void testAddNodeToDistributor() {
NodeStatus distributorNode = nodes.iterator().next();
assertThat(distributorNode.getNodeId()).isEqualByComparingTo(localNode.getId());
assertThat(distributorNode.getExternalUri()).isEqualTo(uri);
assertThat(distributorNode.getSessionTimeout()).isEqualTo(Duration.ofSeconds(30));
}

@Test
Expand Down

0 comments on commit 10e3510

Please sign in to comment.