From abde8d1515411e8d1f5a62aee07a3e3f96a701e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Thu, 21 Sep 2017 10:01:29 +0200 Subject: [PATCH] SONAR-9802 Add IT for cluster mode system info page --- .../system/components/ClusterSysInfos.tsx | 4 +- .../sonarqube/pageobjects/SystemInfoPage.java | 7 +- .../sonarqube/tests/cluster/ClusterTest.java | 67 ++++++++++++++++--- .../org/sonarqube/tests/cluster/Node.java | 5 ++ .../sonarqube/tests/cluster/NodeConfig.java | 8 +-- 5 files changed, 75 insertions(+), 16 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx index 54c70b1999c..281c0f5d7ae 100644 --- a/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx +++ b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx @@ -54,7 +54,7 @@ export default function ClusterSysInfos({ expandedCards, sysInfoData, toggleCard
  • {translate('system.application_nodes_title')}
  • - {sortBy(getAppNodes(sysInfoData), 'name').map(node => ( + {sortBy(getAppNodes(sysInfoData), getNodeName).map(node => ( ))}
  • {translate('system.search_nodes_title')}
  • - {sortBy(getSearchNodes(sysInfoData), 'name').map(node => ( + {sortBy(getSearchNodes(sysInfoData), getNodeName).map(node => ( { + 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 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); } /** -- 2.39.5