aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-09-21 10:01:29 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-26 23:49:38 +0200
commitabde8d1515411e8d1f5a62aee07a3e3f96a701e4 (patch)
tree482e813ae94014c7451a0ee46917eea1e495cfc2 /tests
parent0d049321178a98f46a1739f1c2817098064f1475 (diff)
downloadsonarqube-abde8d1515411e8d1f5a62aee07a3e3f96a701e4.tar.gz
sonarqube-abde8d1515411e8d1f5a62aee07a3e3f96a701e4.zip
SONAR-9802 Add IT for cluster mode system info page
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java7
-rw-r--r--tests/src/test/java/org/sonarqube/tests/cluster/ClusterTest.java67
-rw-r--r--tests/src/test/java/org/sonarqube/tests/cluster/Node.java5
-rw-r--r--tests/src/test/java/org/sonarqube/tests/cluster/NodeConfig.java8
4 files changed, 73 insertions, 14 deletions
diff --git a/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java b/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java
index 84ba01b2333..64d3576873f 100644
--- a/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java
+++ b/tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPage.java
@@ -32,8 +32,13 @@ public class SystemInfoPage {
$(".page-title").should(exist).shouldHave(text("System Info"));
}
+ public SystemInfoPage shouldHaveCard(String title) {
+ $$(".system-info-health-card-title").find(text(title)).should(exist);
+ return this;
+ }
+
public SystemInfoPage shouldHaveCards(String... titles) {
- $$(".system-info-health-card").shouldHave(CollectionCondition.texts(titles));
+ $$(".system-info-health-card-title").shouldHave(CollectionCondition.texts(titles));
return this;
}
diff --git a/tests/src/test/java/org/sonarqube/tests/cluster/ClusterTest.java b/tests/src/test/java/org/sonarqube/tests/cluster/ClusterTest.java
index a6afc2ca1fb..169e9a2caad 100644
--- a/tests/src/test/java/org/sonarqube/tests/cluster/ClusterTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/cluster/ClusterTest.java
@@ -39,6 +39,8 @@ import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
+import org.sonarqube.pageobjects.Navigation;
+import org.sonarqube.pageobjects.SystemInfoPage;
import org.sonarqube.ws.WsSystem;
import org.sonarqube.ws.client.HttpException;
import org.sonarqube.ws.client.issue.SearchWsRequest;
@@ -110,6 +112,9 @@ public class ClusterTest {
app.waitForCeLogsContain("Compute Engine is operational");
assertThat(app.anyLogsContain("Process[ce] is up")).isTrue();
});
+
+ testSystemInfoPage(cluster, cluster.getAppNode(0));
+ testSystemInfoPage(cluster, cluster.getAppNode(1));
}
}
@@ -128,6 +133,50 @@ public class ClusterTest {
});
}
+ private void testSystemInfoPage(Cluster cluster, Node node) {
+ Navigation nav = node.openBrowser().logIn().submitCredentials("admin");
+ node.wsClient().users().skipOnboardingTutorial();
+ SystemInfoPage page = nav.openSystemInfo();
+
+ page.getCardItem("System")
+ .shouldHaveHealth()
+ .shouldHaveMainSection()
+ .shouldNotHaveSection("Database")
+ .shouldNotHaveSection("Settings")
+ .shouldNotHaveSection("Plugins")
+ .shouldHaveField("High Availability")
+ .shouldNotHaveField("Official Distribution")
+ .shouldNotHaveField("Version")
+ .shouldNotHaveField("Logs Level")
+ .shouldNotHaveField("Health")
+ .shouldNotHaveField("Health Causes");
+
+ cluster.getNodes().forEach(clusterNodes -> {
+ page.shouldHaveCard(clusterNodes.getConfig().getName().get());
+ });
+
+ page.getCardItem(String.valueOf(node.getConfig().getName().get()))
+ .shouldHaveHealth()
+ .shouldHaveSection("System")
+ .shouldHaveSection("Database")
+ .shouldHaveSection("Web Logging")
+ .shouldHaveSection("Compute Engine Logging")
+ .shouldNotHaveSection("Settings")
+ .shouldHaveField("Version")
+ .shouldHaveField("Official Distribution")
+ .shouldHaveField("Processors")
+ .shouldNotHaveField("Health")
+ .shouldNotHaveField("Health Causes");
+
+ page.getCardItem(cluster.getSearchNode(0).getConfig().getName().get())
+ .shouldHaveHealth()
+ .shouldHaveSection("Search State")
+ .shouldHaveField("Disk Available")
+ .shouldHaveField("Max File Descriptors")
+ .shouldNotHaveField("Health")
+ .shouldNotHaveField("Health Causes");
+ }
+
@Test
public void minimal_cluster_is_2_search_and_1_application_nodes() throws Exception {
try (Cluster cluster = newCluster(2, 1)) {
@@ -156,9 +205,9 @@ public class ClusterTest {
@Test
public void configuration_of_connection_to_other_nodes_can_be_non_exhaustive() throws Exception {
try (Cluster cluster = new Cluster(null)) {
- NodeConfig searchConfig1 = newSearchConfig();
- NodeConfig searchConfig2 = newSearchConfig();
- NodeConfig appConfig = newApplicationConfig();
+ NodeConfig searchConfig1 = newSearchConfig("Search 1");
+ NodeConfig searchConfig2 = newSearchConfig("Search 2");
+ NodeConfig appConfig = newApplicationConfig("App 1");
// HZ bus : app -> search 2 -> search1, which is not recommended at all !!!
searchConfig2.addConnectionToBus(searchConfig1);
@@ -186,14 +235,14 @@ public class ClusterTest {
@Test
public void node_fails_to_join_cluster_if_different_cluster_name() throws Exception {
try (Cluster cluster = new Cluster("foo")) {
- NodeConfig searchConfig1 = newSearchConfig();
- NodeConfig searchConfig2 = newSearchConfig();
+ NodeConfig searchConfig1 = newSearchConfig("Search 1");
+ NodeConfig searchConfig2 = newSearchConfig("Search 2");
NodeConfig.interconnectBus(searchConfig1, searchConfig2);
NodeConfig.interconnectSearch(searchConfig1, searchConfig2);
cluster.startNode(searchConfig1, nothing());
cluster.startNode(searchConfig2, nothing());
- NodeConfig searchConfig3 = newSearchConfig()
+ NodeConfig searchConfig3 = newSearchConfig("Search 3")
.addConnectionToSearch(searchConfig1)
.addConnectionToBus(searchConfig1, searchConfig2);
Node search3 = cluster.addNode(searchConfig3, b -> b
@@ -322,7 +371,7 @@ public class ClusterTest {
try (Cluster cluster = newCluster(2, 0)) {
// add an application node that pauses during startup
- NodeConfig appConfig = NodeConfig.newApplicationConfig()
+ NodeConfig appConfig = NodeConfig.newApplicationConfig("App 1")
.addConnectionToBus(cluster.getSearchNode(0).getConfig())
.addConnectionToSearch(cluster.getSearchNode(0).getConfig());
Node appNode = cluster.addNode(appConfig, b -> b.setServerProperty("sonar.web.startupLock.path", startupLock.getAbsolutePath()));
@@ -358,8 +407,8 @@ public class ClusterTest {
Cluster cluster = new Cluster(null);
List<NodeConfig> configs = new ArrayList<>();
- IntStream.range(0, nbOfSearchNodes).forEach(i -> configs.add(newSearchConfig()));
- IntStream.range(0, nbOfAppNodes).forEach(i -> configs.add(newApplicationConfig()));
+ IntStream.range(0, nbOfSearchNodes).forEach(i -> configs.add(newSearchConfig("Search " + i)));
+ IntStream.range(0, nbOfAppNodes).forEach(i -> configs.add(newApplicationConfig("App " + i)));
NodeConfig[] configsArray = configs.toArray(new NodeConfig[configs.size()]);
// a node is connected to all nodes, including itself (see sonar.cluster.hosts)
diff --git a/tests/src/test/java/org/sonarqube/tests/cluster/Node.java b/tests/src/test/java/org/sonarqube/tests/cluster/Node.java
index 5b684ac4a24..8b200f496b8 100644
--- a/tests/src/test/java/org/sonarqube/tests/cluster/Node.java
+++ b/tests/src/test/java/org/sonarqube/tests/cluster/Node.java
@@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
+import org.sonarqube.pageobjects.Navigation;
import org.sonarqube.tests.LogsTailer;
import org.sonarqube.ws.WsSystem;
import org.sonarqube.ws.client.WsClient;
@@ -214,6 +215,10 @@ class Node {
return fileContains(orchestrator.getServer().getWebLogs(), message);
}
+ Navigation openBrowser() {
+ return Navigation.create(orchestrator);
+ }
+
private static boolean fileContains(@Nullable File logFile, String message) {
try {
return logFile != null && logFile.exists() && FileUtils.readFileToString(logFile).contains(message);
diff --git a/tests/src/test/java/org/sonarqube/tests/cluster/NodeConfig.java b/tests/src/test/java/org/sonarqube/tests/cluster/NodeConfig.java
index df3d2ed7dcf..cd7951a0bb7 100644
--- a/tests/src/test/java/org/sonarqube/tests/cluster/NodeConfig.java
+++ b/tests/src/test/java/org/sonarqube/tests/cluster/NodeConfig.java
@@ -136,12 +136,12 @@ class NodeConfig {
return searchNodes;
}
- static NodeConfig newApplicationConfig() {
- return new NodeConfig(NodeType.APPLICATION, null);
+ static NodeConfig newApplicationConfig(String name) {
+ return new NodeConfig(NodeType.APPLICATION, name);
}
- static NodeConfig newSearchConfig() {
- return new NodeConfig(NodeType.SEARCH, null);
+ static NodeConfig newSearchConfig(String name) {
+ return new NodeConfig(NodeType.SEARCH, name);
}
/**