From ed02521046020a37140eb84ec536c5cdf31e6d4b Mon Sep 17 00:00:00 2001 From: Alain Kermis Date: Mon, 8 Jul 2024 17:45:13 +0200 Subject: [PATCH] SONAR-22479 Create new telemetry module --- server/sonar-telemetry/build.gradle | 32 +++++++++++ .../QualityProfileDataProviderIT.java | 2 +- .../TelemetryDataLoaderImplIT.java | 12 ++-- .../deprecated}/CloudUsageDataProvider.java | 2 +- .../QualityProfileDataProvider.java | 2 +- .../deprecated}/TelemetryClient.java | 2 +- .../deprecated}/TelemetryDaemon.java | 2 +- .../telemetry/deprecated}/TelemetryData.java | 2 +- .../deprecated}/TelemetryDataJsonWriter.java | 2 +- .../deprecated}/TelemetryDataLoader.java | 2 +- .../deprecated}/TelemetryDataLoaderImpl.java | 8 +-- .../telemetry/deprecated}/package-info.java | 2 +- .../CloudUsageDataProviderTest.java | 17 +++--- .../telemetry/deprecated}/FakeServer.java | 3 +- .../TelemetryClientCompressionTest.java | 2 +- .../deprecated}/TelemetryClientTest.java | 2 +- .../deprecated}/TelemetryDaemonTest.java | 2 +- .../TelemetryDataJsonWriterTest.java | 2 +- .../org/sonar/telemetry/deprecated}/dummy.crt | 0 .../sonar/server/telemetry/package-info.java | 24 -------- .../server/telemetry/telemetry-example.json | 56 ------------------- server/sonar-webserver/build.gradle | 1 + .../platformlevel/PlatformLevel4.java | 12 ++-- settings.gradle | 1 + 24 files changed, 72 insertions(+), 120 deletions(-) create mode 100644 server/sonar-telemetry/build.gradle rename server/{sonar-webserver-core/src/it/java/org/sonar/server/telemetry => sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated}/QualityProfileDataProviderIT.java (99%) rename server/{sonar-webserver-core/src/it/java/org/sonar/server/telemetry => sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated}/TelemetryDataLoaderImplIT.java (98%) rename server/{sonar-webserver-core/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/CloudUsageDataProvider.java (99%) rename server/{sonar-webserver-core/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/QualityProfileDataProvider.java (98%) rename server/{sonar-webserver-core/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/TelemetryClient.java (99%) rename server/{sonar-webserver-core/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/TelemetryDaemon.java (99%) rename server/{sonar-server-common/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/TelemetryData.java (99%) rename server/{sonar-server-common/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/TelemetryDataJsonWriter.java (99%) rename server/{sonar-server-common/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/TelemetryDataLoader.java (95%) rename server/{sonar-webserver-core/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/TelemetryDataLoaderImpl.java (99%) rename server/{sonar-server-common/src/main/java/org/sonar/server/telemetry => sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated}/package-info.java (95%) rename server/{sonar-webserver-core/src/test/java/org/sonar/server/telemetry => sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated}/CloudUsageDataProviderTest.java (93%) rename server/{sonar-webserver-core/src/test/java/org/sonar/server/telemetry => sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated}/FakeServer.java (95%) rename server/{sonar-webserver-core/src/test/java/org/sonar/server/telemetry => sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated}/TelemetryClientCompressionTest.java (98%) rename server/{sonar-webserver-core/src/test/java/org/sonar/server/telemetry => sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated}/TelemetryClientTest.java (98%) rename server/{sonar-webserver-core/src/test/java/org/sonar/server/telemetry => sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated}/TelemetryDaemonTest.java (99%) rename server/{sonar-server-common/src/test/java/org/sonar/server/telemetry => sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated}/TelemetryDataJsonWriterTest.java (99%) rename server/{sonar-webserver-core/src/test/resources/org/sonar/server/telemetry => sonar-telemetry/src/test/resources/org/sonar/telemetry/deprecated}/dummy.crt (100%) delete mode 100644 server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/package-info.java delete mode 100644 server/sonar-webserver-core/src/test/resources/org/sonar/server/telemetry/telemetry-example.json diff --git a/server/sonar-telemetry/build.gradle b/server/sonar-telemetry/build.gradle new file mode 100644 index 00000000000..8bbc9e29e4c --- /dev/null +++ b/server/sonar-telemetry/build.gradle @@ -0,0 +1,32 @@ +description = 'Module providing a platform for telemetry in SonarQube. Contains both old and new versions of telemetry.' + +sonar { + properties { + property 'sonar.projectName', "${projectTitle} :: Server :: Telemetry" + } +} + +dependencies { + testImplementation(platform("org.junit:junit-bom:5.9.1")) + testImplementation 'com.squareup.okhttp3:mockwebserver' + testImplementation 'com.tngtech.java:junit-dataprovider' + testImplementation 'org.assertj:assertj-core' + testImplementation("org.junit.jupiter:junit-jupiter") + testImplementation 'org.mockito:mockito-core' + testImplementation 'org.sonarsource.api.plugin:sonar-plugin-api-test-fixtures' + testImplementation project(':sonar-testing-harness') + testImplementation testFixtures(project(':server:sonar-server-common')) + + api project(':server:sonar-process') + api project(':server:sonar-server-common') + api project(':server:sonar-webserver-core') + api project(':server:sonar-webserver-webapi') + api project(':sonar-core') + + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' + testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' +} + +tasks.test { + useJUnitPlatform() +} \ No newline at end of file diff --git a/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/QualityProfileDataProviderIT.java b/server/sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated/QualityProfileDataProviderIT.java similarity index 99% rename from server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/QualityProfileDataProviderIT.java rename to server/sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated/QualityProfileDataProviderIT.java index e5aefdcd36a..3da1cf0ca83 100644 --- a/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/QualityProfileDataProviderIT.java +++ b/server/sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated/QualityProfileDataProviderIT.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import javax.annotation.Nullable; import org.assertj.core.api.Assertions; diff --git a/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java b/server/sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated/TelemetryDataLoaderImplIT.java similarity index 98% rename from server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java rename to server/sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated/TelemetryDataLoaderImplIT.java index c02e03a0881..4f47a549ee9 100644 --- a/server/sonar-webserver-core/src/it/java/org/sonar/server/telemetry/TelemetryDataLoaderImplIT.java +++ b/server/sonar-telemetry/src/it/java/org/sonar/telemetry/deprecated/TelemetryDataLoaderImplIT.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; @@ -67,10 +67,10 @@ import org.sonar.server.property.MapInternalProperties; import org.sonar.server.qualitygate.QualityGateCaycChecker; import org.sonar.server.qualitygate.QualityGateFinder; import org.sonar.server.qualityprofile.QProfileComparison; -import org.sonar.server.telemetry.TelemetryData.Branch; -import org.sonar.server.telemetry.TelemetryData.CloudUsage; -import org.sonar.server.telemetry.TelemetryData.NewCodeDefinition; -import org.sonar.server.telemetry.TelemetryData.ProjectStatistics; +import org.sonar.telemetry.deprecated.TelemetryData.Branch; +import org.sonar.telemetry.deprecated.TelemetryData.CloudUsage; +import org.sonar.telemetry.deprecated.TelemetryData.NewCodeDefinition; +import org.sonar.telemetry.deprecated.TelemetryData.ProjectStatistics; import org.sonar.updatecenter.common.Version; import static java.util.Arrays.asList; @@ -101,7 +101,7 @@ import static org.sonar.db.component.BranchType.BRANCH; import static org.sonar.server.metric.UnanalyzedLanguageMetrics.UNANALYZED_CPP_KEY; import static org.sonar.server.metric.UnanalyzedLanguageMetrics.UNANALYZED_C_KEY; import static org.sonar.server.qualitygate.QualityGateCaycStatus.NON_COMPLIANT; -import static org.sonar.server.telemetry.TelemetryDataLoaderImpl.EXTERNAL_SECURITY_REPORT_EXPORTED_AT; +import static org.sonar.telemetry.deprecated.TelemetryDataLoaderImpl.EXTERNAL_SECURITY_REPORT_EXPORTED_AT; @RunWith(DataProviderRunner.class) public class TelemetryDataLoaderImplIT { diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/CloudUsageDataProvider.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/CloudUsageDataProvider.java similarity index 99% rename from server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/CloudUsageDataProvider.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/CloudUsageDataProvider.java index 7959407d245..ac4c6cda698 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/CloudUsageDataProvider.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/CloudUsageDataProvider.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import com.google.common.annotations.VisibleForTesting; import com.google.gson.Gson; diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/QualityProfileDataProvider.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/QualityProfileDataProvider.java similarity index 98% rename from server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/QualityProfileDataProvider.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/QualityProfileDataProvider.java index ed5fa907baf..fd0747529e3 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/QualityProfileDataProvider.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/QualityProfileDataProvider.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.util.List; import java.util.Map; diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryClient.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryClient.java similarity index 99% rename from server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryClient.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryClient.java index 3163ea3c79f..20d792aff4b 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryClient.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryClient.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.io.IOException; import okhttp3.Call; diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDaemon.java similarity index 99% rename from server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDaemon.java index 102c007eafb..a65a1d9ccd9 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDaemon.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDaemon.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import com.google.common.util.concurrent.ThreadFactoryBuilder; import java.io.IOException; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryData.java similarity index 99% rename from server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryData.java index 33c2739d23d..28c270fb3c9 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryData.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.util.Arrays; import java.util.Collection; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataJsonWriter.java similarity index 99% rename from server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataJsonWriter.java index 393d0e87857..d2cb6cd231c 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataJsonWriter.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import com.google.common.annotations.VisibleForTesting; import java.time.Instant; diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataLoader.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataLoader.java similarity index 95% rename from server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataLoader.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataLoader.java index 010d67e5dd9..658c2deccee 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataLoader.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataLoader.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; public interface TelemetryDataLoader { TelemetryData load(); diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataLoaderImpl.java similarity index 99% rename from server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataLoaderImpl.java index 728300033c9..183d7f3eca0 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/TelemetryDataLoaderImpl.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.sql.DatabaseMetaData; import java.sql.SQLException; @@ -65,8 +65,8 @@ import org.sonar.server.property.InternalProperties; import org.sonar.server.qualitygate.Condition; import org.sonar.server.qualitygate.QualityGateCaycChecker; import org.sonar.server.qualitygate.QualityGateFinder; -import org.sonar.server.telemetry.TelemetryData.Database; -import org.sonar.server.telemetry.TelemetryData.NewCodeDefinition; +import org.sonar.telemetry.deprecated.TelemetryData.Database; +import org.sonar.telemetry.deprecated.TelemetryData.NewCodeDefinition; import static java.util.Arrays.asList; import static java.util.Optional.ofNullable; @@ -89,7 +89,7 @@ import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH; import static org.sonar.server.metric.UnanalyzedLanguageMetrics.UNANALYZED_CPP_KEY; import static org.sonar.server.metric.UnanalyzedLanguageMetrics.UNANALYZED_C_KEY; import static org.sonar.server.qualitygate.Condition.Operator.fromDbValue; -import static org.sonar.server.telemetry.TelemetryDaemon.I_PROP_MESSAGE_SEQUENCE; +import static org.sonar.telemetry.deprecated.TelemetryDaemon.I_PROP_MESSAGE_SEQUENCE; @ServerSide public class TelemetryDataLoaderImpl implements TelemetryDataLoader { diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/package-info.java b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/package-info.java similarity index 95% rename from server/sonar-server-common/src/main/java/org/sonar/server/telemetry/package-info.java rename to server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/package-info.java index a1adc893867..6e334e48264 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/package-info.java +++ b/server/sonar-telemetry/src/main/java/org/sonar/telemetry/deprecated/package-info.java @@ -18,6 +18,6 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ @ParametersAreNonnullByDefault -package org.sonar.server.telemetry; +package org.sonar.telemetry.deprecated; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/CloudUsageDataProviderTest.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/CloudUsageDataProviderTest.java similarity index 93% rename from server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/CloudUsageDataProviderTest.java rename to server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/CloudUsageDataProviderTest.java index 3ec1d0e1582..ef7b9f0cde3 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/CloudUsageDataProviderTest.java +++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/CloudUsageDataProviderTest.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -33,7 +33,6 @@ import okhttp3.Response; import okhttp3.ResponseBody; import org.junit.Before; import org.junit.Test; -import org.mockito.Mockito; import org.sonar.api.utils.System2; import org.sonar.server.platform.ContainerSupport; import org.sonar.server.util.Paths2; @@ -45,16 +44,16 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.sonar.server.telemetry.CloudUsageDataProvider.DOCKER_RUNNING; -import static org.sonar.server.telemetry.CloudUsageDataProvider.KUBERNETES_SERVICE_HOST; -import static org.sonar.server.telemetry.CloudUsageDataProvider.KUBERNETES_SERVICE_PORT; -import static org.sonar.server.telemetry.CloudUsageDataProvider.SONAR_HELM_CHART_VERSION; +import static org.sonar.telemetry.deprecated.CloudUsageDataProvider.DOCKER_RUNNING; +import static org.sonar.telemetry.deprecated.CloudUsageDataProvider.KUBERNETES_SERVICE_HOST; +import static org.sonar.telemetry.deprecated.CloudUsageDataProvider.KUBERNETES_SERVICE_PORT; +import static org.sonar.telemetry.deprecated.CloudUsageDataProvider.SONAR_HELM_CHART_VERSION; public class CloudUsageDataProviderTest { - private final System2 system2 = Mockito.mock(System2.class); - private final Paths2 paths2 = Mockito.mock(Paths2.class); - private final OkHttpClient httpClient = Mockito.mock(OkHttpClient.class); + private final System2 system2 = mock(System2.class); + private final Paths2 paths2 = mock(Paths2.class); + private final OkHttpClient httpClient = mock(OkHttpClient.class); private final ContainerSupport containerSupport = mock(ContainerSupport.class); private final ProcessBuilder processBuilder = mock(ProcessBuilder.class); private final CloudUsageDataProvider underTest = new CloudUsageDataProvider(containerSupport, system2, paths2, () -> processBuilder, diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/FakeServer.java similarity index 95% rename from server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java rename to server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/FakeServer.java index 211bbc6836e..2aba4bd50b2 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/FakeServer.java +++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/FakeServer.java @@ -17,10 +17,9 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.util.Date; -import javax.annotation.CheckForNull; import org.sonar.api.platform.Server; import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientCompressionTest.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryClientCompressionTest.java similarity index 98% rename from server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientCompressionTest.java rename to server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryClientCompressionTest.java index da6891ddd0d..2e06214a36f 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientCompressionTest.java +++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryClientCompressionTest.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.io.IOException; import java.util.Objects; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryClientTest.java similarity index 98% rename from server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java rename to server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryClientTest.java index 95979c53ee3..c0adfc11629 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java +++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryClientTest.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.io.IOException; import okhttp3.MediaType; diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryDaemonTest.java similarity index 99% rename from server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java rename to server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryDaemonTest.java index d3b7a73ce41..56a3ac858f8 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDaemonTest.java +++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryDaemonTest.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import java.io.IOException; import java.util.Collections; diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryDataJsonWriterTest.java similarity index 99% rename from server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java rename to server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryDataJsonWriterTest.java index 72987c21c93..1041f2787b5 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java +++ b/server/sonar-telemetry/src/test/java/org/sonar/telemetry/deprecated/TelemetryDataJsonWriterTest.java @@ -17,7 +17,7 @@ * 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.telemetry; +package org.sonar.telemetry.deprecated; import com.tngtech.java.junit.dataprovider.DataProvider; import com.tngtech.java.junit.dataprovider.DataProviderRunner; diff --git a/server/sonar-webserver-core/src/test/resources/org/sonar/server/telemetry/dummy.crt b/server/sonar-telemetry/src/test/resources/org/sonar/telemetry/deprecated/dummy.crt similarity index 100% rename from server/sonar-webserver-core/src/test/resources/org/sonar/server/telemetry/dummy.crt rename to server/sonar-telemetry/src/test/resources/org/sonar/telemetry/deprecated/dummy.crt diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/package-info.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/package-info.java deleted file mode 100644 index 63923469e26..00000000000 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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. - */ -@ParametersAreNonnullByDefault -package org.sonar.server.telemetry; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/server/sonar-webserver-core/src/test/resources/org/sonar/server/telemetry/telemetry-example.json b/server/sonar-webserver-core/src/test/resources/org/sonar/server/telemetry/telemetry-example.json deleted file mode 100644 index d9edc0ee818..00000000000 --- a/server/sonar-webserver-core/src/test/resources/org/sonar/server/telemetry/telemetry-example.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "id": "AU-TpxcB-iU5OvuD2FL7", - "version": "7.5.4", - "edition": "developer", - "database": { - "name": "PostgreSQL", - "version": "9.6.5" - }, - "plugins": [ - { - "name": "java", - "version": "4.12.0.11033" - }, - { - "name": "scmgit", - "version": "1.2" - }, - { - "name": "other", - "version": "undefined" - } - ], - "userCount": 3, - "projectCount": 2, - "usingBranches": true, - "ncloc": 300, - "projectCountByLanguage": [ - { - "language": "java", - "count": 2 - }, - { - "language": "kotlin", - "count": 1 - }, - { - "language": "js", - "count": 1 - } - ], - "nclocByLanguage": [ - { - "language": "java", - "ncloc": 500 - }, - { - "language": "kotlin", - "ncloc": 2500 - }, - { - "language": "js", - "ncloc": 50 - } - ], - "docker": false -} diff --git a/server/sonar-webserver/build.gradle b/server/sonar-webserver/build.gradle index ab1bd8f4715..6b055e5d06a 100644 --- a/server/sonar-webserver/build.gradle +++ b/server/sonar-webserver/build.gradle @@ -19,6 +19,7 @@ dependencies { api project(':server:sonar-auth-saml') api project(':server:sonar-ce-task-projectanalysis') api project(':server:sonar-process') + api project(':server:sonar-telemetry') api project(':server:sonar-webserver-core') api project(':server:sonar-webserver-webapi') api project(':server:sonar-webserver-webapi-v2') 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 d773a9fb10f..39074ba7dba 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 @@ -259,12 +259,6 @@ import org.sonar.server.setting.SettingsChangeNotifier; import org.sonar.server.setting.ws.SettingsWsModule; import org.sonar.server.source.ws.SourceWsModule; import org.sonar.server.startup.LogServerId; -import org.sonar.server.telemetry.CloudUsageDataProvider; -import org.sonar.server.telemetry.QualityProfileDataProvider; -import org.sonar.server.telemetry.TelemetryClient; -import org.sonar.server.telemetry.TelemetryDaemon; -import org.sonar.server.telemetry.TelemetryDataJsonWriter; -import org.sonar.server.telemetry.TelemetryDataLoaderImpl; import org.sonar.server.ui.PageRepository; import org.sonar.server.ui.WebAnalyticsLoaderImpl; import org.sonar.server.ui.ws.NavigationWsModule; @@ -287,6 +281,12 @@ import org.sonar.server.webhook.WebhookQGChangeEventListener; import org.sonar.server.webhook.ws.WebhooksWsModule; import org.sonar.server.ws.WebServiceEngine; import org.sonar.server.ws.ws.WebServicesWsModule; +import org.sonar.telemetry.deprecated.CloudUsageDataProvider; +import org.sonar.telemetry.deprecated.QualityProfileDataProvider; +import org.sonar.telemetry.deprecated.TelemetryClient; +import org.sonar.telemetry.deprecated.TelemetryDaemon; +import org.sonar.telemetry.deprecated.TelemetryDataJsonWriter; +import org.sonar.telemetry.deprecated.TelemetryDataLoaderImpl; import static org.sonar.core.extension.CoreExtensionsInstaller.noAdditionalSideFilter; import static org.sonar.core.extension.PlatformLevelPredicates.hasPlatformLevel4OrNone; diff --git a/settings.gradle b/settings.gradle index d38de2a4534..b2a54bb3716 100644 --- a/settings.gradle +++ b/settings.gradle @@ -44,6 +44,7 @@ include 'server:sonar-db-migration' include 'server:sonar-main' include 'server:sonar-process' include 'server:sonar-server-common' +include 'server:sonar-telemetry' include 'server:sonar-web' include 'server:sonar-web:design-system' include 'server:sonar-webserver' -- 2.39.5