Skip to content

Commit

Permalink
[grid] Fix tests for Grid status endpoint and UI (SeleniumHQ#14605)
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 authored and jman-sketch committed Oct 17, 2024
1 parent 7443886 commit 25556c8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 2 additions & 1 deletion java/src/org/openqa/selenium/grid/data/NodeStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ 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
&& this.sessionTimeout.compareTo(that.sessionTimeout) == 0
&& this.heartbeatPeriod.compareTo(that.heartbeatPeriod) == 0
&& Objects.equals(this.slots, that.slots)
&& Objects.equals(this.availability, that.availability)
&& Objects.equals(this.version, that.version);
Expand Down
14 changes: 13 additions & 1 deletion java/src/org/openqa/selenium/grid/router/GridStatusHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,19 @@ public HttpResponse execute(HttpRequest req) {

List<Map<String, Object>> nodeResults =
status.getNodes().stream()
.map(node -> new ImmutableMap.Builder<String, Object>().putAll(node.toJson()).build())
.map(
node ->
new ImmutableMap.Builder<String, Object>()
.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())
.put("version", node.getVersion())
.put("slots", node.getSlots())
.build())
.collect(toList());

ImmutableMap.Builder<String, Object> value = ImmutableMap.builder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void setUp() throws URISyntaxException {
.add(caps, new TestSessionFactory((id, c) -> new Handler(c)))
.maximumConcurrentSessions(2)
.sessionTimeout(Duration.ofSeconds(30))
.heartbeatPeriod(Duration.ofSeconds(5))
.build();

wait =
Expand Down Expand Up @@ -145,6 +146,7 @@ void testAddNodeToDistributor() {
assertThat(distributorNode.getNodeId()).isEqualByComparingTo(localNode.getId());
assertThat(distributorNode.getExternalUri()).isEqualTo(uri);
assertThat(distributorNode.getSessionTimeout()).isEqualTo(Duration.ofSeconds(30));
assertThat(distributorNode.getHeartbeatPeriod()).isEqualTo(Duration.ofSeconds(5));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void tearDown() {

@Test
void shouldReportConcurrencyZeroPercentWhenGridIsStartedWithoutLoad() {
driver.get(whereIs(server, "/ui#/sessions"));
driver.get(whereIs(server, "/ui/#/sessions"));

WebElement concurrency =
wait.until(
Expand All @@ -79,7 +79,7 @@ void shouldReportConcurrencyZeroPercentWhenGridIsStartedWithoutLoad() {

@Test
void shouldShowOneNodeRegistered() {
driver.get(whereIs(server, "/ui"));
driver.get(whereIs(server, "/ui/"));

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

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

0 comments on commit 25556c8

Please sign in to comment.