aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2019-08-13 13:54:45 +0200
committerSonarTech <sonartech@sonarsource.com>2019-08-14 20:21:14 +0200
commit1179e7ef7f549aecdc1f240418dba3a1caac3d51 (patch)
tree57e3fce7765d9b5c744caabb8675abed43faf7a6
parent3814e193bf5b1dab3b58b620a4b5614dfdcf056a (diff)
downloadsonarqube-1179e7ef7f549aecdc1f240418dba3a1caac3d51.tar.gz
sonarqube-1179e7ef7f549aecdc1f240418dba3a1caac3d51.zip
separate Action from indirect dependencies in system WS
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/AbstractSystemInfoWriter.java93
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java (renamed from server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java)5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ClusterSystemInfoWriter.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java (renamed from server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthActionModule.java)8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafeModeHealthCheckerModule.java (renamed from server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafeModeHealthActionModule.java)6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafemodeSystemWsModule.java37
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/StandaloneSystemInfoWriter.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriter.java73
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriterModule.java (renamed from server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java)8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemWsModule.java44
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java (renamed from server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java)12
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java (renamed from server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionModuleTest.java)10
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafeModeHealthCheckerModuleTest.java (renamed from server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafeModeHealthActionModuleTest.java)10
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafemodeSystemWsModuleTest.java36
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemInfoWriterModuleTest.java (renamed from server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java)8
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsModuleTest.java37
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java2
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java30
-rw-r--r--server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelSafeMode.java14
20 files changed, 295 insertions, 144 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/AbstractSystemInfoWriter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/AbstractSystemInfoWriter.java
new file mode 100644
index 00000000000..c6d2b88de20
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/AbstractSystemInfoWriter.java
@@ -0,0 +1,93 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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.ws;
+
+import java.util.Collection;
+import org.sonar.api.utils.text.JsonWriter;
+import org.sonar.process.systeminfo.SystemInfoUtils;
+import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
+import org.sonar.server.health.Health;
+import org.sonar.server.telemetry.TelemetryDataLoader;
+
+import static org.sonar.server.telemetry.TelemetryDataJsonWriter.writeTelemetryData;
+
+public abstract class AbstractSystemInfoWriter implements SystemInfoWriter {
+ private static final String[] ORDERED_SECTION_NAMES = {
+ // standalone
+ "System", "Database", "Plugins",
+
+ // cluster
+ "Web JVM State", "Web Database Connection", "Web Logging", "Web 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 TelemetryDataLoader telemetry;
+
+ AbstractSystemInfoWriter(TelemetryDataLoader telemetry) {
+ this.telemetry = telemetry;
+ }
+
+ protected void writeSections(Collection<ProtobufSystemInfo.Section> sections, JsonWriter json) {
+ SystemInfoUtils
+ .order(sections, ORDERED_SECTION_NAMES)
+ .forEach(section -> writeSection(section, json));
+ }
+
+ private void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) {
+ json.name(section.getName());
+ json.beginObject();
+ for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) {
+ writeAttribute(attribute, json);
+ }
+ json.endObject();
+ }
+
+ private void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) {
+ switch (attribute.getValueCase()) {
+ case BOOLEAN_VALUE:
+ json.prop(attribute.getKey(), attribute.getBooleanValue());
+ break;
+ case LONG_VALUE:
+ json.prop(attribute.getKey(), attribute.getLongValue());
+ break;
+ case DOUBLE_VALUE:
+ json.prop(attribute.getKey(), attribute.getDoubleValue());
+ break;
+ case STRING_VALUE:
+ json.prop(attribute.getKey(), attribute.getStringValue());
+ break;
+ case VALUE_NOT_SET:
+ json.name(attribute.getKey()).beginArray().values(attribute.getStringValuesList()).endArray();
+ break;
+ default:
+ throw new IllegalArgumentException("Unsupported type: " + attribute.getValueCase());
+ }
+ }
+
+ protected void writeHealth(Health health, JsonWriter json) {
+ json.prop("Health", health.getStatus().name());
+ json.name("Health Causes").beginArray().values(health.getCauses()).endArray();
+ }
+
+ protected void writeTelemetry(JsonWriter json) {
+ json.name("Statistics");
+ writeTelemetryData(json, telemetry.load());
+ }
+}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
index d8ef16a9604..ad0664b6331 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelActionModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModule.java
@@ -22,16 +22,15 @@ package org.sonar.server.platform.ws;
import org.sonar.core.platform.Module;
import org.sonar.server.platform.WebServer;
-public class ChangeLogLevelActionModule extends Module {
+public class ChangeLogLevelServiceModule extends Module {
private final WebServer webServer;
- public ChangeLogLevelActionModule(WebServer webServer) {
+ public ChangeLogLevelServiceModule(WebServer webServer) {
this.webServer = webServer;
}
@Override
protected void configureModule() {
- add(ChangeLogLevelAction.class);
if (webServer.isStandalone()) {
add(ChangeLogLevelStandaloneService.class);
} else {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ClusterSystemInfoWriter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ClusterSystemInfoWriter.java
index 97c92f8323f..06b3bb4972b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ClusterSystemInfoWriter.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/ClusterSystemInfoWriter.java
@@ -29,7 +29,7 @@ import org.sonar.server.platform.monitoring.cluster.NodeInfo;
import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoader;
import org.sonar.server.telemetry.TelemetryDataLoader;
-public class ClusterSystemInfoWriter extends SystemInfoWriter {
+public class ClusterSystemInfoWriter extends AbstractSystemInfoWriter {
private final GlobalInfoLoader globalInfoLoader;
private final AppNodesInfoLoader appNodesInfoLoader;
private final SearchNodesInfoLoader searchNodesInfoLoader;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthActionModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
index 453d287fc1c..8707f7da7f2 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthActionModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/HealthCheckerModule.java
@@ -29,10 +29,10 @@ import org.sonar.server.health.HealthCheckerImpl;
import org.sonar.server.health.WebServerStatusNodeCheck;
import org.sonar.server.platform.WebServer;
-public class HealthActionModule extends Module {
+public class HealthCheckerModule extends Module {
private final WebServer webServer;
- public HealthActionModule(WebServer webServer) {
+ public HealthCheckerModule(WebServer webServer) {
this.webServer = webServer;
}
@@ -50,8 +50,6 @@ public class HealthActionModule extends Module {
AppNodeClusterCheck.class);
}
- add(HealthCheckerImpl.class,
- HealthActionSupport.class,
- HealthAction.class);
+ add(HealthCheckerImpl.class);
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafeModeHealthActionModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafeModeHealthCheckerModule.java
index 96f8f7bb934..f1bd0698f99 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafeModeHealthActionModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafeModeHealthCheckerModule.java
@@ -25,7 +25,7 @@ import org.sonar.server.health.EsStatusNodeCheck;
import org.sonar.server.health.HealthCheckerImpl;
import org.sonar.server.health.WebServerSafemodeNodeCheck;
-public class SafeModeHealthActionModule extends Module {
+public class SafeModeHealthCheckerModule extends Module {
@Override
protected void configureModule() {
add(
@@ -34,8 +34,6 @@ public class SafeModeHealthActionModule extends Module {
DbConnectionNodeCheck.class,
EsStatusNodeCheck.class,
- HealthCheckerImpl.class,
- HealthActionSupport.class,
- SafeModeHealthAction.class);
+ HealthCheckerImpl.class);
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafemodeSystemWsModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafemodeSystemWsModule.java
new file mode 100644
index 00000000000..9a3919c2bf5
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SafemodeSystemWsModule.java
@@ -0,0 +1,37 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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.ws;
+
+import org.sonar.core.platform.Module;
+
+public class SafemodeSystemWsModule extends Module {
+ @Override
+ protected void configureModule() {
+ add(
+ StatusAction.class,
+ MigrateDbAction.class,
+ DbMigrationStatusAction.class,
+ HealthActionSupport.class,
+ SafeModeHealthAction.class,
+ SystemWs.class
+
+ );
+ }
+}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/StandaloneSystemInfoWriter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/StandaloneSystemInfoWriter.java
index 3557fa3caf4..a883a75c548 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/StandaloneSystemInfoWriter.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/StandaloneSystemInfoWriter.java
@@ -31,7 +31,7 @@ import org.sonar.server.telemetry.TelemetryDataLoader;
import static java.util.Arrays.stream;
-public class StandaloneSystemInfoWriter extends SystemInfoWriter {
+public class StandaloneSystemInfoWriter extends AbstractSystemInfoWriter {
private final CeHttpClient ceHttpClient;
private final HealthChecker healthChecker;
private final SystemInfoSection[] systemInfoSections;
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriter.java
index 5c0b046a028..fd6726573b8 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriter.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriter.java
@@ -19,77 +19,8 @@
*/
package org.sonar.server.platform.ws;
-import java.util.Collection;
import org.sonar.api.utils.text.JsonWriter;
-import org.sonar.process.systeminfo.SystemInfoUtils;
-import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
-import org.sonar.server.health.Health;
-import org.sonar.server.telemetry.TelemetryDataLoader;
-import static org.sonar.server.telemetry.TelemetryDataJsonWriter.writeTelemetryData;
-
-public abstract class SystemInfoWriter {
- private static final String[] ORDERED_SECTION_NAMES = {
- // standalone
- "System", "Database", "Plugins",
-
- // cluster
- "Web JVM State", "Web Database Connection", "Web Logging", "Web 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 TelemetryDataLoader telemetry;
-
- SystemInfoWriter(TelemetryDataLoader telemetry) {
- this.telemetry = telemetry;
- }
-
- public abstract void write(JsonWriter json) throws Exception;
-
- protected void writeSections(Collection<ProtobufSystemInfo.Section> sections, JsonWriter json) {
- SystemInfoUtils
- .order(sections, ORDERED_SECTION_NAMES)
- .forEach(section -> writeSection(section, json));
- }
-
- private void writeSection(ProtobufSystemInfo.Section section, JsonWriter json) {
- json.name(section.getName());
- json.beginObject();
- for (ProtobufSystemInfo.Attribute attribute : section.getAttributesList()) {
- writeAttribute(attribute, json);
- }
- json.endObject();
- }
-
- private void writeAttribute(ProtobufSystemInfo.Attribute attribute, JsonWriter json) {
- switch (attribute.getValueCase()) {
- case BOOLEAN_VALUE:
- json.prop(attribute.getKey(), attribute.getBooleanValue());
- break;
- case LONG_VALUE:
- json.prop(attribute.getKey(), attribute.getLongValue());
- break;
- case DOUBLE_VALUE:
- json.prop(attribute.getKey(), attribute.getDoubleValue());
- break;
- case STRING_VALUE:
- json.prop(attribute.getKey(), attribute.getStringValue());
- break;
- case VALUE_NOT_SET:
- json.name(attribute.getKey()).beginArray().values(attribute.getStringValuesList()).endArray();
- break;
- default:
- throw new IllegalArgumentException("Unsupported type: " + attribute.getValueCase());
- }
- }
-
- protected void writeHealth(Health health, JsonWriter json) {
- json.prop("Health", health.getStatus().name());
- json.name("Health Causes").beginArray().values(health.getCauses()).endArray();
- }
-
- protected void writeTelemetry(JsonWriter json) {
- json.name("Statistics");
- writeTelemetryData(json, telemetry.load());
- }
+public interface SystemInfoWriter {
+ void write(JsonWriter json) throws Exception;
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriterModule.java
index 276b14b8ac4..1da4de96524 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/WebSystemInfoModule.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemInfoWriterModule.java
@@ -19,7 +19,6 @@
*/
package org.sonar.server.platform.ws;
-import org.sonar.api.config.Configuration;
import org.sonar.core.platform.Module;
import org.sonar.process.systeminfo.JvmPropertiesSection;
import org.sonar.process.systeminfo.JvmStateSection;
@@ -41,10 +40,10 @@ import org.sonar.server.platform.monitoring.cluster.NodeSystemSection;
import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
import org.sonar.server.platform.monitoring.cluster.SearchNodesInfoLoaderImpl;
-public class WebSystemInfoModule extends Module {
+public class SystemInfoWriterModule extends Module {
private final WebServer webServer;
- public WebSystemInfoModule(WebServer webServer) {
+ public SystemInfoWriterModule(WebServer webServer) {
this.webServer = webServer;
}
@@ -60,8 +59,7 @@ public class WebSystemInfoModule extends Module {
EsIndexesSection.class,
LoggingSection.class,
PluginsSection.class,
- SettingsSection.class,
- InfoAction.class
+ SettingsSection.class
);
if (standalone) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemWsModule.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemWsModule.java
new file mode 100644
index 00000000000..38b377b80ec
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/platform/ws/SystemWsModule.java
@@ -0,0 +1,44 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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.ws;
+
+import org.sonar.core.platform.Module;
+
+public class SystemWsModule extends Module {
+
+ @Override
+ protected void configureModule() {
+ add(
+ ChangeLogLevelAction.class,
+ DbMigrationStatusAction.class,
+ HealthActionSupport.class,
+ HealthAction.class,
+ InfoAction.class,
+ LogsAction.class,
+ MigrateDbAction.class,
+ PingAction.class,
+ RestartAction.class,
+ StatusAction.class,
+ UpgradesAction.class,
+ SystemWs.class
+
+ );
+ }
+}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
index d69daf028f5..9a964e5f01d 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelActionModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/ChangeLogLevelServiceModuleTest.java
@@ -30,9 +30,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
-public class ChangeLogLevelActionModuleTest {
+public class ChangeLogLevelServiceModuleTest {
private WebServer webServer = mock(WebServer.class);
- private ChangeLogLevelActionModule underTest = new ChangeLogLevelActionModule(webServer);
+ private ChangeLogLevelServiceModule underTest = new ChangeLogLevelServiceModule(webServer);
@Test
public void provide_returns_ChangeLogLevelClusterService_if_cluster_not_on_SonarCloud() {
@@ -43,9 +43,9 @@ public class ChangeLogLevelActionModuleTest {
Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 2)
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 1)
.extracting(ComponentAdapter::getComponentKey)
- .contains(ChangeLogLevelClusterService.class, ChangeLogLevelAction.class)
+ .contains(ChangeLogLevelClusterService.class)
.doesNotContain(ChangeLogLevelStandaloneService.class);
}
@@ -62,9 +62,9 @@ public class ChangeLogLevelActionModuleTest {
private void verifyInStandaloneSQ(ComponentContainer container) {
Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 2)
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 1)
.extracting(ComponentAdapter::getComponentKey)
- .contains(ChangeLogLevelStandaloneService.class, ChangeLogLevelAction.class)
+ .contains(ChangeLogLevelStandaloneService.class)
.doesNotContain(ChangeLogLevelClusterService.class);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
index f628ad95c10..1819b595dbd 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthActionModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/HealthCheckerModuleTest.java
@@ -41,12 +41,12 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-public class HealthActionModuleTest {
+public class HealthCheckerModuleTest {
private WebServer webServer = mock(WebServer.class);
- private HealthActionModule underTest = new HealthActionModule(webServer);
+ private HealthCheckerModule underTest = new HealthCheckerModule(webServer);
@Test
- public void verify_action_and_HealthChecker() {
+ public void verify_HealthChecker() {
boolean standalone = new Random().nextBoolean();
when(webServer.isStandalone()).thenReturn(standalone);
ComponentContainer container = new ComponentContainer();
@@ -56,8 +56,8 @@ public class HealthActionModuleTest {
assertThat(classesAddedToContainer(container))
.describedAs("Verifying action and HealthChecker with standalone=%s", standalone)
.contains(HealthCheckerImpl.class)
- .contains(HealthActionSupport.class)
- .contains(HealthAction.class)
+ .doesNotContain(HealthActionSupport.class)
+ .doesNotContain(HealthAction.class)
.doesNotContain(SafeModeHealthAction.class);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java
index 8d63f470c41..b4d2eac3ed2 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/InfoActionTest.java
@@ -38,7 +38,7 @@ public class InfoActionTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
- private SystemInfoWriter jsonWriter = new SystemInfoWriter(null) {
+ private SystemInfoWriter jsonWriter = new AbstractSystemInfoWriter(null) {
@Override
public void write(JsonWriter json) {
json.prop("key", "value");
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafeModeHealthActionModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafeModeHealthCheckerModuleTest.java
index d328fac2e69..4506531f52c 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafeModeHealthActionModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafeModeHealthCheckerModuleTest.java
@@ -33,19 +33,19 @@ import org.sonar.server.health.WebServerSafemodeNodeCheck;
import static org.assertj.core.api.Assertions.assertThat;
-public class SafeModeHealthActionModuleTest {
- private SafeModeHealthActionModule underTest = new SafeModeHealthActionModule();
+public class SafeModeHealthCheckerModuleTest {
+ private SafeModeHealthCheckerModule underTest = new SafeModeHealthCheckerModule();
@Test
- public void verify_action_and_HealthChecker() {
+ public void verify_HealthChecker() {
ComponentContainer container = new ComponentContainer();
underTest.configure(container);
assertThat(classesAddedToContainer(container))
.contains(HealthCheckerImpl.class)
- .contains(HealthActionSupport.class)
- .contains(SafeModeHealthAction.class)
+ .doesNotContain(HealthActionSupport.class)
+ .doesNotContain(SafeModeHealthAction.class)
.doesNotContain(HealthAction.class);
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafemodeSystemWsModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafemodeSystemWsModuleTest.java
new file mode 100644
index 00000000000..066fe788321
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SafemodeSystemWsModuleTest.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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.ws;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
+
+public class SafemodeSystemWsModuleTest {
+ @Test
+ public void verify_count_of_added_components() {
+ ComponentContainer container = new ComponentContainer();
+ new SafemodeSystemWsModule().configure(container);
+ assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 6);
+ }
+
+}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemInfoWriterModuleTest.java
index fb6485a6cf3..664472ef744 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/WebSystemInfoModuleTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemInfoWriterModuleTest.java
@@ -30,9 +30,9 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
-public class WebSystemInfoModuleTest {
+public class SystemInfoWriterModuleTest {
private WebServer webServer = mock(WebServer.class);
- private WebSystemInfoModule underTest = new WebSystemInfoModule(webServer);
+ private SystemInfoWriterModule underTest = new SystemInfoWriterModule(webServer);
@Test
public void verify_system_info_configuration_in_cluster_mode() {
@@ -43,7 +43,7 @@ public class WebSystemInfoModuleTest {
Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 18);
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 17);
}
@Test
@@ -59,7 +59,7 @@ public class WebSystemInfoModuleTest {
public void verifyConfigurationStandaloneSQ(ComponentContainer container) {
Collection<ComponentAdapter<?>> adapters = container.getPicoContainer().getComponentAdapters();
assertThat(adapters)
- .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 12);
+ .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 11);
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsModuleTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsModuleTest.java
new file mode 100644
index 00000000000..855c2adc823
--- /dev/null
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsModuleTest.java
@@ -0,0 +1,37 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2019 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.ws;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.sonar.core.platform.ComponentContainer.COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER;
+
+public class SystemWsModuleTest {
+ @Test
+ public void verify_count_of_added_components() {
+ ComponentContainer container = new ComponentContainer();
+ new SystemWsModule().configure(container);
+ assertThat(container.size()).isEqualTo(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 12);
+ }
+
+
+}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
index 733c12cae02..de93a9d8d1e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
@@ -36,7 +36,7 @@ public class SystemWsTest {
public void define() {
RestartAction action1 = new RestartAction(mock(UserSession.class), mock(ProcessCommandWrapper.class),
mock(RestartFlagHolder.class), mock(WebServer.class));
- InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), mock(SystemInfoWriter.class));
+ InfoAction action2 = new InfoAction(new AnonymousMockUserSession(), mock(AbstractSystemInfoWriter.class));
SystemWs ws = new SystemWs(action1, action2);
WebService.Context context = new WebService.Context();
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
index b72635af2a9..c367e84d711 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
@@ -120,19 +120,12 @@ import org.sonar.server.platform.web.DeprecatedPropertiesWsFilter;
import org.sonar.server.platform.web.WebServiceFilter;
import org.sonar.server.platform.web.WebServiceReroutingFilter;
import org.sonar.server.platform.web.requestid.HttpRequestIdModule;
-import org.sonar.server.platform.ws.ChangeLogLevelActionModule;
-import org.sonar.server.platform.ws.DbMigrationStatusAction;
-import org.sonar.server.platform.ws.HealthActionModule;
+import org.sonar.server.platform.ws.ChangeLogLevelServiceModule;
+import org.sonar.server.platform.ws.HealthCheckerModule;
import org.sonar.server.platform.ws.L10nWs;
-import org.sonar.server.platform.ws.LogsAction;
-import org.sonar.server.platform.ws.MigrateDbAction;
-import org.sonar.server.platform.ws.PingAction;
-import org.sonar.server.platform.ws.RestartAction;
import org.sonar.server.platform.ws.ServerWs;
-import org.sonar.server.platform.ws.StatusAction;
-import org.sonar.server.platform.ws.SystemWs;
-import org.sonar.server.platform.ws.UpgradesAction;
-import org.sonar.server.platform.ws.WebSystemInfoModule;
+import org.sonar.server.platform.ws.SystemWsModule;
+import org.sonar.server.platform.ws.SystemInfoWriterModule;
import org.sonar.server.plugins.PluginDownloader;
import org.sonar.server.plugins.PluginUninstaller;
import org.sonar.server.plugins.ServerExtensionInstaller;
@@ -469,16 +462,9 @@ public class PlatformLevel4 extends PlatformLevel {
// System
ServerLogging.class,
- RestartAction.class,
- PingAction.class,
- UpgradesAction.class,
- StatusAction.class,
- MigrateDbAction.class,
- LogsAction.class,
- ChangeLogLevelActionModule.class,
- DbMigrationStatusAction.class,
- HealthActionModule.class,
- SystemWs.class,
+ ChangeLogLevelServiceModule.class,
+ HealthCheckerModule.class,
+ SystemWsModule.class,
// Plugins WS
PluginUpdateAggregator.class,
@@ -537,7 +523,7 @@ public class PlatformLevel4 extends PlatformLevel {
);
// system info
- add(WebSystemInfoModule.class);
+ add(SystemInfoWriterModule.class);
addAll(level4AddedComponents);
}
diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelSafeMode.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelSafeMode.java
index 81c6adf532e..6eacf03ff4d 100644
--- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelSafeMode.java
+++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelSafeMode.java
@@ -27,13 +27,10 @@ import org.sonar.server.platform.db.migration.DatabaseMigrationImpl;
import org.sonar.server.platform.db.migration.MigrationEngineModule;
import org.sonar.server.platform.db.migration.NoopDatabaseMigrationImpl;
import org.sonar.server.platform.web.WebServiceFilter;
-import org.sonar.server.platform.ws.DbMigrationStatusAction;
import org.sonar.server.platform.ws.IndexAction;
import org.sonar.server.platform.ws.L10nWs;
-import org.sonar.server.platform.ws.MigrateDbAction;
-import org.sonar.server.platform.ws.SafeModeHealthActionModule;
-import org.sonar.server.platform.ws.StatusAction;
-import org.sonar.server.platform.ws.SystemWs;
+import org.sonar.server.platform.ws.SafeModeHealthCheckerModule;
+import org.sonar.server.platform.ws.SafemodeSystemWsModule;
import org.sonar.server.ws.WebServiceEngine;
import org.sonar.server.ws.ws.WebServicesWsModule;
@@ -52,11 +49,8 @@ public class PlatformLevelSafeMode extends PlatformLevel {
IndexAction.class,
// Server WS
- StatusAction.class,
- MigrateDbAction.class,
- DbMigrationStatusAction.class,
- SafeModeHealthActionModule.class,
- SystemWs.class,
+ SafeModeHealthCheckerModule.class,
+ SafemodeSystemWsModule.class,
// Listing WS
WebServicesWsModule.class,