Skip to content

Commit

Permalink
[grid]: Node sessionTimeout include in Grid 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 11, 2024
1 parent 438b77c commit 836e903
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions java/src/org/openqa/selenium/grid/data/NodeStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ public boolean equals(Object o) {
return Objects.equals(this.nodeId, that.nodeId)
&& Objects.equals(this.externalUri, that.externalUri)
&& this.maxSessionCount == that.maxSessionCount
&& this.sessionTimeout == that.sessionTimeout
&& Objects.equals(this.slots, that.slots)
&& Objects.equals(this.availability, that.availability)
&& Objects.equals(this.version, that.version);
Expand Down
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 @@ -38,6 +39,7 @@ public class Node {
private final URI uri;
private final Availability status;
private final int maxSession;
private final Duration sessionTimeout;
private final Map<Capabilities, Integer> stereotypes;
private final Map<Session, Slot> activeSessions;
private final String version;
Expand All @@ -49,6 +51,7 @@ public Node(
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Node {
uri: Uri!
status: Status!
maxSession: Int!
sessionTimeout: String!
slotCount: Int!
sessions: [Session]!
sessionCount: Int!
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 836e903

Please sign in to comment.