Skip to content

Commit c79a864

Browse files
VietND96sandeepsuryaprasad
authored andcommitted
[grid] Add default sessionTimeout to NodeStatus to increase backward compatibility (SeleniumHQ#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]>
1 parent 1558d6d commit c79a864

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

java/src/org/openqa/selenium/grid/data/NodeStatus.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static NodeStatus fromJson(JsonInput input) {
7676
Set<Slot> slots = null;
7777
Availability availability = null;
7878
Duration heartbeatPeriod = null;
79-
Duration sessionTimeout = null;
79+
Duration sessionTimeout = Duration.ofSeconds(300);
8080
String version = null;
8181
Map<String, String> osInfo = null;
8282

java/test/org/openqa/selenium/grid/data/NodeStatusTest.java

+75
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,79 @@ void ensureRoundTripWorks() throws URISyntaxException {
7272

7373
assertThat(seen).isEqualTo(status);
7474
}
75+
76+
@Test
77+
void withoutSessionTimeoutInJsonStatus() throws URISyntaxException {
78+
String source =
79+
"{\n"
80+
+ " \"availability\": \"UP\",\n"
81+
+ " \"externalUri\": \"http:\\u002f\\u002f192.168.1.101:5555\",\n"
82+
+ " \"heartbeatPeriod\": 60000,\n"
83+
+ " \"maxSessions\": 1,\n"
84+
+ " \"nodeId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
85+
+ " \"osInfo\": {\n"
86+
+ " \"arch\": \"aarch64\",\n"
87+
+ " \"name\": \"Mac OS X\",\n"
88+
+ " \"version\": \"15.3\"\n"
89+
+ " },\n"
90+
+ " \"slots\": [\n"
91+
+ " {\n"
92+
+ " \"id\": {\n"
93+
+ " \"hostId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
94+
+ " \"id\": \"965e8cb4-7b48-4638-8bc8-6889c6319682\"\n"
95+
+ " },\n"
96+
+ " \"lastStarted\": \"1970-01-01T00:00:00Z\",\n"
97+
+ " \"session\": null,\n"
98+
+ " \"stereotype\": {\n"
99+
+ " \"browserName\": \"chrome\",\n"
100+
+ " \"platformName\": \"mac\"\n"
101+
+ " }\n"
102+
+ " }\n"
103+
+ " ],\n"
104+
+ " \"version\": \"4.17.0 (revision unknown*)\"\n"
105+
+ " }";
106+
107+
Json json = new Json();
108+
NodeStatus nodeStatus = json.toType(source, NodeStatus.class);
109+
110+
assertThat(nodeStatus.getSessionTimeout()).isEqualTo(Duration.ofSeconds(300));
111+
}
112+
113+
@Test
114+
void withSessionTimeoutInJsonStatus() throws URISyntaxException {
115+
String source =
116+
"{\n"
117+
+ " \"availability\": \"UP\",\n"
118+
+ " \"externalUri\": \"http:\\u002f\\u002f192.168.1.101:5555\",\n"
119+
+ " \"heartbeatPeriod\": 60000,\n"
120+
+ " \"maxSessions\": 1,\n"
121+
+ " \"sessionTimeout\": 600000,\n"
122+
+ " \"nodeId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
123+
+ " \"osInfo\": {\n"
124+
+ " \"arch\": \"aarch64\",\n"
125+
+ " \"name\": \"Mac OS X\",\n"
126+
+ " \"version\": \"15.3\"\n"
127+
+ " },\n"
128+
+ " \"slots\": [\n"
129+
+ " {\n"
130+
+ " \"id\": {\n"
131+
+ " \"hostId\": \"d136dd9b-6497-4049-9371-42f89b14ea2b\",\n"
132+
+ " \"id\": \"965e8cb4-7b48-4638-8bc8-6889c6319682\"\n"
133+
+ " },\n"
134+
+ " \"lastStarted\": \"1970-01-01T00:00:00Z\",\n"
135+
+ " \"session\": null,\n"
136+
+ " \"stereotype\": {\n"
137+
+ " \"browserName\": \"chrome\",\n"
138+
+ " \"platformName\": \"mac\"\n"
139+
+ " }\n"
140+
+ " }\n"
141+
+ " ],\n"
142+
+ " \"version\": \"4.17.0 (revision unknown*)\"\n"
143+
+ " }";
144+
145+
Json json = new Json();
146+
NodeStatus nodeStatus = json.toType(source, NodeStatus.class);
147+
148+
assertThat(nodeStatus.getSessionTimeout()).isEqualTo(Duration.ofSeconds(600));
149+
}
75150
}

0 commit comments

Comments
 (0)