Skip to content

Commit

Permalink
adjust to removal of idle executors (#1605)
Browse files Browse the repository at this point in the history
  • Loading branch information
mawinter69 committed Jun 24, 2024
1 parent c2e0469 commit dea99c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 38 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<properties>
<changelist>999999-SNAPSHOT</changelist>
<spotbugs.skip>true</spotbugs.skip>
<jenkins.version>2.462</jenkins.version>
<jenkins.version>2.463</jenkins.version>
<selenium.version>4.22.0</selenium.version>
<guava.version>33.2.1-jre</guava.version> <!-- aligned with selenium -->
<maven.version>3.8.1</maven.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jenkinsci.test.acceptance.plugins.dashboard_view.read;

import java.util.List;
import java.util.stream.Collectors;
import org.jenkinsci.test.acceptance.po.PageAreaImpl;
import org.jenkinsci.test.acceptance.po.PageObject;
import org.openqa.selenium.By;
Expand All @@ -18,30 +17,22 @@ public class BuildExecutorStatus extends PageAreaImpl {
* Container for all further elements.
*/
private final By executors = By.xpath("//div[@id=\"side-panel\"]/div[@id=\"executors\"]");
/**
* Main table of nodes and executors.
*/
private final By table = By.xpath("//table/tbody");
/**
* Header in the table for the name of the node. If only one node, the header is not shown.
*/
private final By header = By.xpath("//th");
/**
* All Executors. (not split by header)
*/
private final By executor = By.xpath("//tr/td[2]");
private final By header = By.xpath("//div[@class=\"computer-caption\"] | //table//th");

public BuildExecutorStatus(PageObject context, String path) {
super(context, path);
}

/**
* Get the main table containing the nodes and executors.
* Get the div containing the nodes and executors.
*
* @return the WebElement for the table.
* @return the WebElement for the div.
*/
public WebElement getTable() {
return find(executors).findElement(table);
public WebElement getExecutorsDiv() {
return find(executors);
}

/**
Expand All @@ -51,22 +42,7 @@ public WebElement getTable() {
*
* @return the names of all displayed nodes/agents.
*/
public List<String> getHeaders() {
return getTable().findElements(header).stream()
.map(WebElement::getText)
.map(String::trim)
.collect(Collectors.toList());
public List<WebElement> getHeaders() {
return getExecutorsDiv().findElements(header);
}

/**
* Get all the executors displayed in the table.
* @return the list of executor names.
*/
public List<String> getExecutors() {
return getTable().findElements(executor).stream()
.map(WebElement::getText)
.map(String::trim)
.collect(Collectors.toList());
}

}
9 changes: 3 additions & 6 deletions src/test/java/plugins/DashboardViewPluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.jenkinsci.test.acceptance.po.Node;
import org.jenkinsci.test.acceptance.slave.SlaveController;
import org.junit.Test;
import org.openqa.selenium.WebElement;

@WithPlugins("dashboard-view")
public class DashboardViewPluginTest extends AbstractJobRelatedTest {
Expand Down Expand Up @@ -258,21 +259,17 @@ public void configureDashboardFilterBuildExecutors() throws Exception {
});
v.open();

final List<String> headers = v.buildExecutorStatus.getHeaders();
final List<String> executors = v.buildExecutorStatus.getExecutors();
final List<WebElement> headers = v.buildExecutorStatus.getHeaders();
assertThat(headers.size(), is(2));
assertThat(executors.size(), greaterThan(1));

job.configure(() -> {
job.setLabelExpression("test");
});
v.open();

final List<String> headers2 = v.buildExecutorStatus.getHeaders();
final List<String> executors2 = v.buildExecutorStatus.getExecutors();
final List<WebElement> headers2 = v.buildExecutorStatus.getHeaders();
// If only one node, the title header is not shown.
assertThat(headers2.size(), is(0));
assertThat(executors2.size(), is(1));
}

@Test
Expand Down

0 comments on commit dea99c1

Please sign in to comment.