Skip to content

Commit

Permalink
[grid] Add default sessionTimeout to NodeStatus to increase backward …
Browse files Browse the repository at this point in the history
…compatibility (#15229)

* [grid] Add default sessionTimeout to NodeStatus to increase backward compatibility
* Add test sessionTimeout from NodeStatus JSON scheme

---------

Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored Feb 4, 2025
1 parent 787cf6f commit 1b7742e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/grid/data/NodeStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static NodeStatus fromJson(JsonInput input) {
Set<Slot> slots = null;
Availability availability = null;
Duration heartbeatPeriod = null;
Duration sessionTimeout = null;
Duration sessionTimeout = Duration.ofSeconds(300);
String version = null;
Map<String, String> osInfo = null;

Expand Down
75 changes: 75 additions & 0 deletions java/test/org/openqa/selenium/grid/data/NodeStatusTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,79 @@ void ensureRoundTripWorks() throws URISyntaxException {

assertThat(seen).isEqualTo(status);
}

@Test
void withoutSessionTimeoutInJsonStatus() throws URISyntaxException {
String source =
"{\n"
+ " \"availability\": \"UP\",\n"
+ " \"externalUri\": \"http:\\u002f\\u002f192.168.1.101:5555\",\n"
+ " \"heartbeatPeriod\": 60000,\n"
+ " \"maxSessions\": 1,\n"
+ " \"nodeId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
+ " \"osInfo\": {\n"
+ " \"arch\": \"aarch64\",\n"
+ " \"name\": \"Mac OS X\",\n"
+ " \"version\": \"15.3\"\n"
+ " },\n"
+ " \"slots\": [\n"
+ " {\n"
+ " \"id\": {\n"
+ " \"hostId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
+ " \"id\": \"965e8cb4-7b48-4638-8bc8-6889c6319682\"\n"
+ " },\n"
+ " \"lastStarted\": \"1970-01-01T00:00:00Z\",\n"
+ " \"session\": null,\n"
+ " \"stereotype\": {\n"
+ " \"browserName\": \"chrome\",\n"
+ " \"platformName\": \"mac\"\n"
+ " }\n"
+ " }\n"
+ " ],\n"
+ " \"version\": \"4.17.0 (revision unknown*)\"\n"
+ " }";

Json json = new Json();
NodeStatus nodeStatus = json.toType(source, NodeStatus.class);

assertThat(nodeStatus.getSessionTimeout()).isEqualTo(Duration.ofSeconds(300));
}

@Test
void withSessionTimeoutInJsonStatus() throws URISyntaxException {
String source =
"{\n"
+ " \"availability\": \"UP\",\n"
+ " \"externalUri\": \"http:\\u002f\\u002f192.168.1.101:5555\",\n"
+ " \"heartbeatPeriod\": 60000,\n"
+ " \"maxSessions\": 1,\n"
+ " \"sessionTimeout\": 600000,\n"
+ " \"nodeId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
+ " \"osInfo\": {\n"
+ " \"arch\": \"aarch64\",\n"
+ " \"name\": \"Mac OS X\",\n"
+ " \"version\": \"15.3\"\n"
+ " },\n"
+ " \"slots\": [\n"
+ " {\n"
+ " \"id\": {\n"
+ " \"hostId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
+ " \"id\": \"965e8cb4-7b48-4638-8bc8-6889c6319682\"\n"
+ " },\n"
+ " \"lastStarted\": \"1970-01-01T00:00:00Z\",\n"
+ " \"session\": null,\n"
+ " \"stereotype\": {\n"
+ " \"browserName\": \"chrome\",\n"
+ " \"platformName\": \"mac\"\n"
+ " }\n"
+ " }\n"
+ " ],\n"
+ " \"version\": \"4.17.0 (revision unknown*)\"\n"
+ " }";

Json json = new Json();
NodeStatus nodeStatus = json.toType(source, NodeStatus.class);

assertThat(nodeStatus.getSessionTimeout()).isEqualTo(Duration.ofSeconds(600));
}
}

0 comments on commit 1b7742e

Please sign in to comment.