]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9802 improve name of Database sections
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sun, 24 Sep 2017 20:27:08 +0000 (22:27 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 26 Sep 2017 21:49:38 +0000 (23:49 +0200)
15 files changed:
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseSection.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseSectionMBean.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbConnectionSection.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbConnectionSectionMBean.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbSection.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/WebSystemInfoModule.java
server/sonar-server/src/main/java/org/sonar/server/platform/ws/BaseInfoWsAction.java
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DatabaseSectionTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DbConnectionSectionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DbSectionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/SystemInfoTesting.java
tests/src/test/java/org/sonarqube/pageobjects/SystemInfoPageItem.java
tests/src/test/java/org/sonarqube/tests/cluster/ClusterTest.java
tests/src/test/java/org/sonarqube/tests/serverSystem/SystemInfoTest.java

index c5e45edfa256d53088c6a00361d378d247927fc3..3cf5f769c7f10b519a3d0bb18135d5b5039f31a1 100644 (file)
@@ -126,7 +126,7 @@ import org.sonar.server.platform.UrlSettings;
 import org.sonar.server.platform.WebServerImpl;
 import org.sonar.server.platform.db.migration.MigrationConfigurationModule;
 import org.sonar.server.platform.db.migration.version.DatabaseVersion;
-import org.sonar.server.platform.monitoring.DatabaseSection;
+import org.sonar.server.platform.monitoring.DbSection;
 import org.sonar.server.platform.monitoring.cluster.LoggingSection;
 import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
 import org.sonar.server.plugins.InstalledPluginReferentialFactory;
@@ -430,7 +430,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
         CeDistributedInformationImpl.class,
 
         // system info
-        DatabaseSection.class,
+        DbSection.class,
         ProcessInfoProvider.class,
         LoggingSection.class);
     } else {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseSection.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseSection.java
deleted file mode 100644 (file)
index a64e8d2..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.platform.monitoring;
-
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-import org.apache.commons.dbcp.BasicDataSource;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbSession;
-import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo.Section;
-import org.sonar.server.platform.db.migration.version.DatabaseVersion;
-
-import static org.sonar.process.systeminfo.SystemInfoUtils.setAttribute;
-
-/**
- * Information about database and connection pool
- */
-public class DatabaseSection extends BaseSectionMBean implements DatabaseSectionMBean {
-
-  private final DatabaseVersion dbVersion;
-  private final DbClient dbClient;
-
-  public DatabaseSection(DatabaseVersion dbVersion, DbClient dbClient) {
-    this.dbVersion = dbVersion;
-    this.dbClient = dbClient;
-  }
-
-  @Override
-  public String name() {
-    return "Database";
-  }
-
-  @Override
-  public String getMigrationStatus() {
-    return dbVersion.getStatus().name();
-  }
-
-  @Override
-  public int getPoolActiveConnections() {
-    return commonsDbcp().getNumActive();
-  }
-
-  @Override
-  public int getPoolMaxActiveConnections() {
-    return commonsDbcp().getMaxActive();
-  }
-
-  @Override
-  public int getPoolIdleConnections() {
-    return commonsDbcp().getNumIdle();
-  }
-
-  @Override
-  public int getPoolMaxIdleConnections() {
-    return commonsDbcp().getMaxIdle();
-  }
-
-  @Override
-  public int getPoolMinIdleConnections() {
-    return commonsDbcp().getMinIdle();
-  }
-
-  @Override
-  public int getPoolInitialSize() {
-    return commonsDbcp().getInitialSize();
-  }
-
-  @Override
-  public long getPoolMaxWaitMillis() {
-    return commonsDbcp().getMaxWait();
-  }
-
-  @Override
-  public boolean getPoolRemoveAbandoned() {
-    return commonsDbcp().getRemoveAbandoned();
-  }
-
-  @Override
-  public int getPoolRemoveAbandonedTimeoutSeconds() {
-    return commonsDbcp().getRemoveAbandonedTimeout();
-  }
-
-  @Override
-  public Section toProtobuf() {
-    Section.Builder protobuf = Section.newBuilder();
-    protobuf.setName(name());
-    completeDbAttributes(protobuf);
-    completePoolAttributes(protobuf);
-    return protobuf.build();
-  }
-
-  private void completePoolAttributes(Section.Builder protobuf) {
-    setAttribute(protobuf, "Pool Active Connections", getPoolActiveConnections());
-    setAttribute(protobuf, "Pool Max Connections", getPoolMaxActiveConnections());
-    setAttribute(protobuf, "Pool Initial Size", getPoolInitialSize());
-    setAttribute(protobuf, "Pool Idle Connections", getPoolIdleConnections());
-    setAttribute(protobuf, "Pool Min Idle Connections", getPoolMinIdleConnections());
-    setAttribute(protobuf, "Pool Max Idle Connections", getPoolMaxIdleConnections());
-    setAttribute(protobuf, "Pool Max Wait (ms)", getPoolMaxWaitMillis());
-    setAttribute(protobuf, "Pool Remove Abandoned", getPoolRemoveAbandoned());
-    setAttribute(protobuf, "Pool Remove Abandoned Timeout (seconds)", getPoolRemoveAbandonedTimeoutSeconds());
-  }
-
-  private BasicDataSource commonsDbcp() {
-    return (BasicDataSource) dbClient.getDatabase().getDataSource();
-  }
-
-  private void completeDbAttributes(Section.Builder protobuf) {
-    try (DbSession dbSession = dbClient.openSession(false)) {
-      DatabaseMetaData metadata = dbSession.getConnection().getMetaData();
-      setAttribute(protobuf, "Database", metadata.getDatabaseProductName());
-      setAttribute(protobuf, "Database Version", metadata.getDatabaseProductVersion());
-      setAttribute(protobuf, "Username", metadata.getUserName());
-      setAttribute(protobuf, "URL", metadata.getURL());
-      setAttribute(protobuf, "Driver", metadata.getDriverName());
-      setAttribute(protobuf, "Driver Version", metadata.getDriverVersion());
-      setAttribute(protobuf, "Version Status", getMigrationStatus());
-    } catch (SQLException e) {
-      throw new IllegalStateException("Fail to get DB metadata", e);
-    }
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseSectionMBean.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DatabaseSectionMBean.java
deleted file mode 100644 (file)
index 0ddd97f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.platform.monitoring;
-
-public interface DatabaseSectionMBean {
-
-  /**
-   * Is database schema up-to-date or should it be upgraded ?
-   */
-  String getMigrationStatus();
-
-  /**
-   *
-   */
-  int getPoolActiveConnections();
-
-  /**
-   * The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
-   */
-  int getPoolMaxActiveConnections();
-
-  int getPoolIdleConnections();
-
-  /**
-   * The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.
-   */
-  int getPoolMaxIdleConnections();
-
-  /**
-   * The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.
-   */
-  int getPoolMinIdleConnections();
-
-  /**
-   * The initial number of connections that are created when the pool is started.
-   */
-  int getPoolInitialSize();
-
-  /**
-   * The maximum number of milliseconds that the pool will wait
-   * (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.
-   */
-  long getPoolMaxWaitMillis();
-
-  /**
-   * Flag to remove abandoned connections if they exceed the {@link #getPoolRemoveAbandonedTimeoutSeconds()}.
-   */
-  boolean getPoolRemoveAbandoned();
-
-  /**
-   * Timeout in seconds before an abandoned connection can be removed.
-   */
-  int getPoolRemoveAbandonedTimeoutSeconds();
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbConnectionSection.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbConnectionSection.java
new file mode 100644 (file)
index 0000000..4cf0130
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.monitoring;
+
+import org.apache.commons.dbcp.BasicDataSource;
+import org.sonar.api.SonarQubeSide;
+import org.sonar.api.SonarRuntime;
+import org.sonar.db.DbClient;
+import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo.Section;
+import org.sonar.server.platform.db.migration.version.DatabaseVersion;
+
+import static org.sonar.process.systeminfo.SystemInfoUtils.setAttribute;
+
+/**
+ * Information about database connection pool
+ */
+public class DbConnectionSection extends BaseSectionMBean implements DbConnectionSectionMBean {
+
+  private final DatabaseVersion dbVersion;
+  private final DbClient dbClient;
+  private final SonarRuntime runtime;
+
+  public DbConnectionSection(DatabaseVersion dbVersion, DbClient dbClient, SonarRuntime runtime) {
+    this.dbVersion = dbVersion;
+    this.dbClient = dbClient;
+    this.runtime = runtime;
+  }
+
+  @Override
+  public String name() {
+    return "Database";
+  }
+
+  @Override
+  public String getMigrationStatus() {
+    return dbVersion.getStatus().name();
+  }
+
+  @Override
+  public int getPoolActiveConnections() {
+    return commonsDbcp().getNumActive();
+  }
+
+  @Override
+  public int getPoolMaxActiveConnections() {
+    return commonsDbcp().getMaxActive();
+  }
+
+  @Override
+  public int getPoolIdleConnections() {
+    return commonsDbcp().getNumIdle();
+  }
+
+  @Override
+  public int getPoolMaxIdleConnections() {
+    return commonsDbcp().getMaxIdle();
+  }
+
+  @Override
+  public int getPoolMinIdleConnections() {
+    return commonsDbcp().getMinIdle();
+  }
+
+  @Override
+  public int getPoolInitialSize() {
+    return commonsDbcp().getInitialSize();
+  }
+
+  @Override
+  public long getPoolMaxWaitMillis() {
+    return commonsDbcp().getMaxWait();
+  }
+
+  @Override
+  public boolean getPoolRemoveAbandoned() {
+    return commonsDbcp().getRemoveAbandoned();
+  }
+
+  @Override
+  public int getPoolRemoveAbandonedTimeoutSeconds() {
+    return commonsDbcp().getRemoveAbandonedTimeout();
+  }
+
+  @Override
+  public Section toProtobuf() {
+    Section.Builder protobuf = Section.newBuilder();
+    String side = runtime.getSonarQubeSide() == SonarQubeSide.COMPUTE_ENGINE ? "Compute Engine" : "Web";
+    protobuf.setName(side + " Database Connection");
+    completePoolAttributes(protobuf);
+    return protobuf.build();
+  }
+
+  private void completePoolAttributes(Section.Builder protobuf) {
+    setAttribute(protobuf, "Pool Active Connections", getPoolActiveConnections());
+    setAttribute(protobuf, "Pool Max Connections", getPoolMaxActiveConnections());
+    setAttribute(protobuf, "Pool Initial Size", getPoolInitialSize());
+    setAttribute(protobuf, "Pool Idle Connections", getPoolIdleConnections());
+    setAttribute(protobuf, "Pool Min Idle Connections", getPoolMinIdleConnections());
+    setAttribute(protobuf, "Pool Max Idle Connections", getPoolMaxIdleConnections());
+    setAttribute(protobuf, "Pool Max Wait (ms)", getPoolMaxWaitMillis());
+    setAttribute(protobuf, "Pool Remove Abandoned", getPoolRemoveAbandoned());
+    setAttribute(protobuf, "Pool Remove Abandoned Timeout (seconds)", getPoolRemoveAbandonedTimeoutSeconds());
+  }
+
+  private BasicDataSource commonsDbcp() {
+    return (BasicDataSource) dbClient.getDatabase().getDataSource();
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbConnectionSectionMBean.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbConnectionSectionMBean.java
new file mode 100644 (file)
index 0000000..5f225cc
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.monitoring;
+
+public interface DbConnectionSectionMBean {
+
+  /**
+   * Is database schema up-to-date or should it be upgraded ?
+   */
+  String getMigrationStatus();
+
+  /**
+   *
+   */
+  int getPoolActiveConnections();
+
+  /**
+   * The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
+   */
+  int getPoolMaxActiveConnections();
+
+  int getPoolIdleConnections();
+
+  /**
+   * The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.
+   */
+  int getPoolMaxIdleConnections();
+
+  /**
+   * The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.
+   */
+  int getPoolMinIdleConnections();
+
+  /**
+   * The initial number of connections that are created when the pool is started.
+   */
+  int getPoolInitialSize();
+
+  /**
+   * The maximum number of milliseconds that the pool will wait
+   * (when there are no available connections) for a connection to be returned before throwing an exception, or -1 to wait indefinitely.
+   */
+  long getPoolMaxWaitMillis();
+
+  /**
+   * Flag to remove abandoned connections if they exceed the {@link #getPoolRemoveAbandonedTimeoutSeconds()}.
+   */
+  boolean getPoolRemoveAbandoned();
+
+  /**
+   * Timeout in seconds before an abandoned connection can be removed.
+   */
+  int getPoolRemoveAbandonedTimeoutSeconds();
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbSection.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/DbSection.java
new file mode 100644 (file)
index 0000000..4162c07
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.monitoring;
+
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import org.sonar.db.DbClient;
+import org.sonar.db.DbSession;
+import org.sonar.process.systeminfo.Global;
+import org.sonar.process.systeminfo.SystemInfoSection;
+import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo.Section;
+
+import static org.sonar.process.systeminfo.SystemInfoUtils.setAttribute;
+
+/**
+ * Information about database
+ */
+public class DbSection implements SystemInfoSection, Global {
+
+  private final DbClient dbClient;
+
+  public DbSection(DbClient dbClient) {
+    this.dbClient = dbClient;
+  }
+
+  @Override
+  public Section toProtobuf() {
+    Section.Builder protobuf = Section.newBuilder();
+    protobuf.setName("Database");
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      DatabaseMetaData metadata = dbSession.getConnection().getMetaData();
+      setAttribute(protobuf, "Database", metadata.getDatabaseProductName());
+      setAttribute(protobuf, "Database Version", metadata.getDatabaseProductVersion());
+      setAttribute(protobuf, "Username", metadata.getUserName());
+      setAttribute(protobuf, "URL", metadata.getURL());
+      setAttribute(protobuf, "Driver", metadata.getDriverName());
+      setAttribute(protobuf, "Driver Version", metadata.getDriverVersion());
+    } catch (SQLException e) {
+      throw new IllegalStateException("Fail to get DB metadata", e);
+    }
+    return protobuf.build();
+  }
+}
index aae7dc5c087d2a2b1fe79cbf80eb71d5981e7660..9335402242a235694242a9dbe05614ceb174fd02 100644 (file)
@@ -22,11 +22,12 @@ package org.sonar.server.platform.monitoring;
 import org.sonar.process.systeminfo.JvmPropertiesSection;
 import org.sonar.process.systeminfo.JvmStateSection;
 import org.sonar.server.platform.monitoring.cluster.AppNodesInfoLoaderImpl;
+import org.sonar.server.platform.monitoring.cluster.CeQueueGlobalSection;
 import org.sonar.server.platform.monitoring.cluster.GlobalInfoLoader;
 import org.sonar.server.platform.monitoring.cluster.GlobalSystemSection;
-import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
 import org.sonar.server.platform.monitoring.cluster.LoggingSection;
 import org.sonar.server.platform.monitoring.cluster.NodeSystemSection;
+import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
 import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoaderImpl;
 import org.sonar.server.platform.ws.ClusterInfoAction;
 import org.sonar.server.platform.ws.InfoAction;
@@ -41,7 +42,8 @@ public class WebSystemInfoModule {
     return new Object[] {
       new JvmPropertiesSection("Web JVM Properties"),
       new JvmStateSection("Web JVM State"),
-      DatabaseSection.class,
+      DbSection.class,
+      DbConnectionSection.class,
       EsStateSection.class,
       EsIndexesSection.class,
       PluginsSection.class,
@@ -58,7 +60,9 @@ public class WebSystemInfoModule {
     return new Object[] {
       new JvmPropertiesSection("Web JVM Properties"),
       new JvmStateSection("Web JVM State"),
-      DatabaseSection.class,
+      CeQueueGlobalSection.class,
+      DbSection.class,
+      DbConnectionSection.class,
       EsIndexesSection.class,
       GlobalSystemSection.class,
       LoggingSection.class,
index f50aebe0c6569429b423f9a583e512b7fdf60a0e..f6c8ff5aa05f5a744c93f8f36203331926a41a66 100644 (file)
@@ -35,10 +35,13 @@ import static org.sonar.server.telemetry.TelemetryDataJsonWriter.writeTelemetryD
 public abstract class BaseInfoWsAction implements SystemWsAction {
 
   private static final String[] ORDERED_SECTION_NAMES = {
+    // standalone
     "System", "Database", "Plugins",
+
+    // cluster
     "Web JVM State", "Web Database Connection", "Web Logging", "Web JVM Properties",
-    "Search State", "Search Indexes",
-    "Compute Engine Tasks", "Compute Engine JVM State", "Compute Engine Database Connection", "Compute Engine Logging", "Compute Engine JVM Properties"};
+    "Compute Engine Tasks", "Compute Engine JVM State", "Compute Engine Database Connection", "Compute Engine Logging", "Compute Engine JVM Properties",
+    "Search State", "Search Indexes"};
 
   private final UserSession userSession;
   private final TelemetryDataLoader telemetry;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DatabaseSectionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DatabaseSectionTest.java
deleted file mode 100644 (file)
index f4139c8..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.platform.monitoring;
-
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.utils.System2;
-import org.sonar.db.DbTester;
-import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
-import org.sonar.server.platform.db.migration.version.DatabaseVersion;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.sonar.process.systeminfo.SystemInfoUtils.attribute;
-import static org.sonar.server.platform.monitoring.SystemInfoTesting.assertThatAttributeIs;
-
-public class DatabaseSectionTest {
-
-  @Rule
-  public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
-  private DatabaseVersion databaseVersion = mock(DatabaseVersion.class);
-  private DatabaseSection underTest = new DatabaseSection(databaseVersion, dbTester.getDbClient());
-
-  @Before
-  public void setUp() throws Exception {
-    when(databaseVersion.getStatus()).thenReturn(DatabaseVersion.Status.UP_TO_DATE);
-  }
-
-  @Test
-  public void name_is_not_empty() {
-    assertThat(underTest.name()).isNotEmpty();
-  }
-
-  @Test
-  public void db_info() {
-    ProtobufSystemInfo.Section section = underTest.toProtobuf();
-    assertThatAttributeIs(section, "Database", "H2");
-    assertThat(attribute(section, "Database Version").getStringValue()).startsWith("1.");
-    assertThatAttributeIs(section, "Username", "SONAR");
-    assertThat(attribute(section, "Driver Version").getStringValue()).startsWith("1.");
-  }
-
-  @Test
-  public void pool_info() {
-    ProtobufSystemInfo.Section section = underTest.toProtobuf();
-    assertThat(attribute(section, "Pool Max Connections").getLongValue()).isGreaterThan(0L);
-  }
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DbConnectionSectionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DbConnectionSectionTest.java
new file mode 100644 (file)
index 0000000..cb9e711
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.monitoring;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.SonarQubeSide;
+import org.sonar.api.SonarRuntime;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
+import org.sonar.server.platform.db.migration.version.DatabaseVersion;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.sonar.process.systeminfo.SystemInfoUtils.attribute;
+
+public class DbConnectionSectionTest {
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  private DatabaseVersion databaseVersion = mock(DatabaseVersion.class);
+  private SonarRuntime runtime = mock(SonarRuntime.class);
+  private DbConnectionSection underTest = new DbConnectionSection(databaseVersion, dbTester.getDbClient(), runtime);
+
+  @Test
+  public void jmx_name_is_not_empty() {
+    assertThat(underTest.name()).isEqualTo("Database");
+  }
+
+  @Test
+  public void pool_info() {
+    ProtobufSystemInfo.Section section = underTest.toProtobuf();
+    assertThat(attribute(section, "Pool Max Connections").getLongValue()).isGreaterThan(0L);
+    assertThat(attribute(section, "Pool Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L);
+    assertThat(attribute(section, "Pool Min Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L);
+    assertThat(attribute(section, "Pool Max Idle Connections").getLongValue()).isGreaterThanOrEqualTo(0L);
+    assertThat(attribute(section, "Pool Max Wait (ms)")).isNotNull();
+    assertThat(attribute(section, "Pool Remove Abandoned")).isNotNull();
+    assertThat(attribute(section, "Pool Remove Abandoned Timeout (seconds)").getLongValue()).isGreaterThanOrEqualTo(0L);
+  }
+
+  @Test
+  public void section_name_depends_on_runtime_side() {
+    when(runtime.getSonarQubeSide()).thenReturn(SonarQubeSide.COMPUTE_ENGINE);
+    assertThat(underTest.toProtobuf().getName()).isEqualTo("Compute Engine Database Connection");
+
+    when(runtime.getSonarQubeSide()).thenReturn(SonarQubeSide.SERVER );
+    assertThat(underTest.toProtobuf().getName()).isEqualTo("Web Database Connection");
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DbSectionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/DbSectionTest.java
new file mode 100644 (file)
index 0000000..429c7ff
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.platform.monitoring;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.db.DbTester;
+import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.process.systeminfo.SystemInfoUtils.attribute;
+import static org.sonar.server.platform.monitoring.SystemInfoTesting.assertThatAttributeIs;
+
+public class DbSectionTest {
+
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
+
+  private DbSection underTest = new DbSection(dbTester.getDbClient());
+
+  @Test
+  public void db_info() {
+    ProtobufSystemInfo.Section section = underTest.toProtobuf();
+    assertThatAttributeIs(section, "Database", "H2");
+    assertThat(attribute(section, "Database Version").getStringValue()).startsWith("1.");
+    assertThatAttributeIs(section, "Username", "SONAR");
+    assertThat(attribute(section, "Driver Version").getStringValue()).startsWith("1.");
+  }
+}
index 2a2c0d9fb9a6e80b7032a333f54ddfd6b618fbb6..528ba9785f07ef86038ca3f742ec6056d2e605c6 100644 (file)
@@ -19,7 +19,6 @@
  */
 package org.sonar.server.platform.monitoring;
 
-import java.util.Collection;
 import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -43,9 +42,9 @@ public class SystemInfoTesting {
     assertThat(value.getBooleanValue()).isEqualTo(expectedValue);
   }
 
-  public static void assertThatAttributeHasOnlyValues(ProtobufSystemInfo.Section section, String key, Collection<String> expectedValues) {
+  public static void assertThatAttributeIs(ProtobufSystemInfo.Section section, String key, long expectedValue) {
     ProtobufSystemInfo.Attribute value = attribute(section, key);
     assertThat(value).as(key).isNotNull();
-    assertThat((Collection<String>)value.getStringValuesList()).containsExactlyInAnyOrder(expectedValues.toArray(new String[expectedValues.size()]));
+    assertThat(value.getLongValue()).isEqualTo(expectedValue);
   }
 }
index 19a023e165fe791e4cd4f548bcdd9086b1b126b9..c477c874cb3e2b86f18773e9f827c3bfa83c1a65 100644 (file)
@@ -21,6 +21,7 @@ package org.sonarqube.pageobjects;
 
 import com.codeborne.selenide.SelenideElement;
 
+import static com.codeborne.selenide.Condition.exactText;
 import static com.codeborne.selenide.Condition.exist;
 import static com.codeborne.selenide.Condition.text;
 
@@ -62,7 +63,7 @@ public class SystemInfoPageItem {
 
   public SystemInfoPageItem shouldNotHaveField(String field) {
     ensureOpen();
-    elt.$$(".system-info-section-item-name").findBy(text(field)).shouldNot(exist);
+    elt.$$(".system-info-section-item-name").findBy(exactText(field)).shouldNot(exist);
     return this;
   }
 
index b7221c8bb03f2bf54fe67e9d91d25e021b4ac023..9ddde1ac32dca4421eaaf26c06ec1ef832a6ae19 100644 (file)
@@ -141,7 +141,8 @@ public class ClusterTest {
     page.getCardItem("System")
       .shouldHaveHealth()
       .shouldHaveMainSection()
-      .shouldNotHaveSection("Database")
+      .shouldHaveSection("Database")
+      .shouldHaveField("Database Version")
       .shouldNotHaveSection("Settings")
       .shouldNotHaveSection("Plugins")
       .shouldHaveField("High Availability")
index 605b058df2687534e6ab0eb8610f141c4fc36b47..c3d7a888f4758a86367dbe599435bd6f5371887b 100644 (file)
@@ -77,7 +77,7 @@ public class SystemInfoTest {
 
     page.getCardItem("Search")
       .shouldHaveSection("Search State")
-      .shouldHaveSection("Search Statistics");
+      .shouldHaveSection("Search Indexes");
   }
 
   @Test