Skip to content

Commit 625bb94

Browse files
committed
[grid] Fix tests for Grid status endpoint and UI
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent edff2f3 commit 625bb94

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ public boolean equals(Object o) {
214214
return Objects.equals(this.nodeId, that.nodeId)
215215
&& Objects.equals(this.externalUri, that.externalUri)
216216
&& this.maxSessionCount == that.maxSessionCount
217-
&& this.sessionTimeout == that.sessionTimeout
217+
&& this.sessionTimeout.compareTo(that.sessionTimeout) == 0
218+
&& this.heartbeatPeriod.compareTo(that.heartbeatPeriod) == 0
218219
&& Objects.equals(this.slots, that.slots)
219220
&& Objects.equals(this.availability, that.availability)
220221
&& Objects.equals(this.version, that.version);

java/src/org/openqa/selenium/grid/router/GridStatusHandler.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,19 @@ public HttpResponse execute(HttpRequest req) {
135135

136136
List<Map<String, Object>> nodeResults =
137137
status.getNodes().stream()
138-
.map(node -> new ImmutableMap.Builder<String, Object>().putAll(node.toJson()).build())
138+
.map(
139+
node ->
140+
new ImmutableMap.Builder<String, Object>()
141+
.put("id", node.getNodeId())
142+
.put("uri", node.getExternalUri())
143+
.put("maxSessions", node.getMaxSessionCount())
144+
.put("sessionTimeout", node.getSessionTimeout().toMillis())
145+
.put("osInfo", node.getOsInfo())
146+
.put("heartbeatPeriod", node.getHeartbeatPeriod().toMillis())
147+
.put("availability", node.getAvailability())
148+
.put("version", node.getVersion())
149+
.put("slots", node.getSlots())
150+
.build())
139151
.collect(toList());
140152

141153
ImmutableMap.Builder<String, Object> value = ImmutableMap.builder();

java/test/org/openqa/selenium/grid/distributor/local/LocalDistributorTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void setUp() throws URISyntaxException {
103103
.add(caps, new TestSessionFactory((id, c) -> new Handler(c)))
104104
.maximumConcurrentSessions(2)
105105
.sessionTimeout(Duration.ofSeconds(30))
106+
.heartbeatPeriod(Duration.ofSeconds(5))
106107
.build();
107108

108109
wait =
@@ -145,6 +146,7 @@ void testAddNodeToDistributor() {
145146
assertThat(distributorNode.getNodeId()).isEqualByComparingTo(localNode.getId());
146147
assertThat(distributorNode.getExternalUri()).isEqualTo(uri);
147148
assertThat(distributorNode.getSessionTimeout()).isEqualTo(Duration.ofSeconds(30));
149+
assertThat(distributorNode.getHeartbeatPeriod()).isEqualTo(Duration.ofSeconds(5));
148150
}
149151

150152
@Test

java/test/org/openqa/selenium/grid/gridui/OverallGridTest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void tearDown() {
6868

6969
@Test
7070
void shouldReportConcurrencyZeroPercentWhenGridIsStartedWithoutLoad() {
71-
driver.get(whereIs(server, "/ui#/sessions"));
71+
driver.get(whereIs(server, "/ui/#/sessions"));
7272

7373
WebElement concurrency =
7474
wait.until(
@@ -79,7 +79,7 @@ void shouldReportConcurrencyZeroPercentWhenGridIsStartedWithoutLoad() {
7979

8080
@Test
8181
void shouldShowOneNodeRegistered() {
82-
driver.get(whereIs(server, "/ui"));
82+
driver.get(whereIs(server, "/ui/"));
8383

8484
List<WebElement> nodeInfoIcons =
8585
wait.until(
@@ -93,7 +93,7 @@ void shouldIncrementSessionCountWhenSessionStarts() {
9393
WebDriver remoteWebDriver =
9494
new RemoteWebDriver(server.getUrl(), Browser.detect().getCapabilities());
9595
try {
96-
driver.get(whereIs(server, "/ui#/sessions"));
96+
driver.get(whereIs(server, "/ui/#/sessions"));
9797

9898
wait.until(textToBe(By.cssSelector("div[data-testid='session-count']"), "1"));
9999
} finally {

0 commit comments

Comments
 (0)