Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[grid] Fix tests for Grid status endpoint and UI #14605

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading