From 93fa1a4ea7a58b14b39724d75cd73e960b076489 Mon Sep 17 00:00:00 2001 From: Alain Kermis Date: Fri, 2 Jun 2023 09:10:05 +0200 Subject: [PATCH] SONAR-19425 Rename docker to container in telemetry and system info --- .../sonar/server/telemetry/TelemetryData.java | 14 ++++++------- .../telemetry/TelemetryDataJsonWriter.java | 2 +- .../TelemetryDataJsonWriterTest.java | 8 ++++---- ...ckerSupport.java => ContainerSupport.java} | 4 ++-- ...ortImpl.java => ContainerSupportImpl.java} | 6 +++--- .../monitoring/StandaloneSystemSection.java | 10 +++++----- .../cluster/GlobalSystemSection.java | 10 +++++----- .../telemetry/TelemetryDataLoaderImpl.java | 10 +++++----- ...est.java => ContainerSupportImplTest.java} | 20 +++++++++---------- .../StandaloneSystemSectionTest.java | 12 +++++------ .../cluster/GlobalSystemSectionTest.java | 12 +++++------ .../TelemetryDataLoaderImplTest.java | 10 +++++----- .../platformlevel/PlatformLevel1.java | 4 ++-- 13 files changed, 61 insertions(+), 61 deletions(-) rename server/sonar-webserver-core/src/main/java/org/sonar/server/platform/{DockerSupport.java => ContainerSupport.java} (93%) rename server/sonar-webserver-core/src/main/java/org/sonar/server/platform/{DockerSupportImpl.java => ContainerSupportImpl.java} (90%) rename server/sonar-webserver-core/src/test/java/org/sonar/server/platform/{DockerSupportImplTest.java => ContainerSupportImplTest.java} (92%) diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java index 44b65e3395c..2f980f50d57 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryData.java @@ -44,7 +44,7 @@ public class TelemetryData { private final String defaultQualityGate; private final Long installationDate; private final String installationVersion; - private final boolean inDocker; + private final boolean inContainer; private final ManagedInstanceInformation managedInstanceInformation; private final CloudUsage cloudUsage; private final List users; @@ -68,7 +68,7 @@ public class TelemetryData { defaultQualityGate = builder.defaultQualityGate; installationDate = builder.installationDate; installationVersion = builder.installationVersion; - inDocker = builder.inDocker; + inContainer = builder.inContainer; users = builder.users; projects = builder.projects; projectStatistics = builder.projectStatistics; @@ -119,8 +119,8 @@ public class TelemetryData { return installationVersion; } - public boolean isInDocker() { - return inDocker; + public boolean isInContainer() { + return inContainer; } public ManagedInstanceInformation getManagedInstanceInformation() { @@ -185,7 +185,7 @@ public class TelemetryData { private String defaultQualityGate; private Long installationDate; private String installationVersion; - private boolean inDocker = false; + private boolean inContainer = false; private ManagedInstanceInformation managedInstanceInformation; private CloudUsage cloudUsage; private Boolean hasUnanalyzedC; @@ -248,8 +248,8 @@ public class TelemetryData { return this; } - Builder setInDocker(boolean inDocker) { - this.inDocker = inDocker; + Builder setInContainer(boolean inContainer) { + this.inContainer = inContainer; return this; } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java index 3712a810f10..d5243c541f7 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/telemetry/TelemetryDataJsonWriter.java @@ -94,7 +94,7 @@ public class TelemetryDataJsonWriter { if (telemetryData.getInstallationVersion() != null) { json.prop("installationVersion", telemetryData.getInstallationVersion()); } - json.prop("docker", telemetryData.isInDocker()); + json.prop("container", telemetryData.isInContainer()); writeUserData(json, telemetryData); writeProjectData(json, telemetryData); diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java index 30144e50ac4..dcec4033191 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/telemetry/TelemetryDataJsonWriterTest.java @@ -227,17 +227,17 @@ public class TelemetryDataJsonWriterTest { @Test @UseDataProvider("getFeatureFlagEnabledStates") - public void write_docker_flag(boolean isInDocker) { + public void write_container_flag(boolean isIncontainer) { TelemetryData data = telemetryBuilder() - .setInDocker(isInDocker) + .setInContainer(isIncontainer) .build(); String json = writeTelemetryData(data); assertJson(json).isSimilarTo(""" { - "docker": %s + "container": %s } - """.formatted(isInDocker)); + """.formatted(isIncontainer)); } @DataProvider diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DockerSupport.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ContainerSupport.java similarity index 93% rename from server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DockerSupport.java rename to server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ContainerSupport.java index 51dcc25029d..22a59f5207f 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DockerSupport.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ContainerSupport.java @@ -19,10 +19,10 @@ */ package org.sonar.server.platform; -public interface DockerSupport { +public interface ContainerSupport { /** * @return {@code true} if we can detect that SQ is running inside a docker container */ - boolean isRunningInDocker(); + boolean isRunningInContainer(); } diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DockerSupportImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ContainerSupportImpl.java similarity index 90% rename from server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DockerSupportImpl.java rename to server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ContainerSupportImpl.java index 84dac734045..38997c558f5 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/DockerSupportImpl.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/ContainerSupportImpl.java @@ -24,15 +24,15 @@ import java.nio.file.Files; import java.util.stream.Stream; import org.sonar.server.util.Paths2; -public class DockerSupportImpl implements DockerSupport { +public class ContainerSupportImpl implements ContainerSupport { private final Paths2 paths2; - public DockerSupportImpl(Paths2 paths2) { + public ContainerSupportImpl(Paths2 paths2) { this.paths2 = paths2; } @Override - public boolean isRunningInDocker() { + public boolean isRunningInContainer() { if (paths2.exists("/run/.containerenv")) { return true; } diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/StandaloneSystemSection.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/StandaloneSystemSection.java index c7f433985ef..0502556fef5 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/StandaloneSystemSection.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/StandaloneSystemSection.java @@ -25,7 +25,7 @@ import org.sonar.api.platform.Server; import org.sonar.process.systeminfo.BaseSectionMBean; import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo; import org.sonar.server.log.ServerLogging; -import org.sonar.server.platform.DockerSupport; +import org.sonar.server.platform.ContainerSupport; import org.sonar.server.platform.OfficialDistribution; import org.sonar.server.platform.StatisticsSupport; @@ -42,19 +42,19 @@ public class StandaloneSystemSection extends BaseSectionMBean implements SystemS private final Server server; private final ServerLogging serverLogging; private final OfficialDistribution officialDistribution; - private final DockerSupport dockerSupport; + private final ContainerSupport containerSupport; private final StatisticsSupport statisticsSupport; private final SonarRuntime sonarRuntime; private final CommonSystemInformation commonSystemInformation; public StandaloneSystemSection(Configuration config, Server server, ServerLogging serverLogging, - OfficialDistribution officialDistribution, DockerSupport dockerSupport, StatisticsSupport statisticsSupport, + OfficialDistribution officialDistribution, ContainerSupport containerSupport, StatisticsSupport statisticsSupport, SonarRuntime sonarRuntime, CommonSystemInformation commonSystemInformation) { this.config = config; this.server = server; this.serverLogging = serverLogging; this.officialDistribution = officialDistribution; - this.dockerSupport = dockerSupport; + this.containerSupport = containerSupport; this.statisticsSupport = statisticsSupport; this.sonarRuntime = sonarRuntime; this.commonSystemInformation = commonSystemInformation; @@ -90,7 +90,7 @@ public class StandaloneSystemSection extends BaseSectionMBean implements SystemS setAttribute(protobuf, "Version", getVersion()); setAttribute(protobuf, "Edition", sonarRuntime.getEdition().getLabel()); setAttribute(protobuf, NCLOC.getName(), statisticsSupport.getLinesOfCode()); - setAttribute(protobuf, "Docker", dockerSupport.isRunningInDocker()); + setAttribute(protobuf, "Container", containerSupport.isRunningInContainer()); setAttribute(protobuf, "External Users and Groups Provisioning", commonSystemInformation.getManagedInstanceProviderName()); setAttribute(protobuf, "External User Authentication", commonSystemInformation.getExternalUserAuthentication()); addIfNotEmpty(protobuf, "Accepted external identity providers", diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSection.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSection.java index 308b1733c1d..13fb551edc4 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSection.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSection.java @@ -25,7 +25,7 @@ import org.sonar.api.server.ServerSide; import org.sonar.process.systeminfo.Global; import org.sonar.process.systeminfo.SystemInfoSection; import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo; -import org.sonar.server.platform.DockerSupport; +import org.sonar.server.platform.ContainerSupport; import org.sonar.server.platform.StatisticsSupport; import org.sonar.server.platform.monitoring.CommonSystemInformation; @@ -37,15 +37,15 @@ import static org.sonar.process.systeminfo.SystemInfoUtils.setAttribute; public class GlobalSystemSection implements SystemInfoSection, Global { private final Server server; - private final DockerSupport dockerSupport; + private final ContainerSupport containerSupport; private final StatisticsSupport statisticsSupport; private final SonarRuntime sonarRuntime; private final CommonSystemInformation commonSystemInformation; - public GlobalSystemSection(Server server, DockerSupport dockerSupport, StatisticsSupport statisticsSupport, SonarRuntime sonarRuntime, + public GlobalSystemSection(Server server, ContainerSupport containerSupport, StatisticsSupport statisticsSupport, SonarRuntime sonarRuntime, CommonSystemInformation commonSystemInformation) { this.server = server; - this.dockerSupport = dockerSupport; + this.containerSupport = containerSupport; this.statisticsSupport = statisticsSupport; this.sonarRuntime = sonarRuntime; this.commonSystemInformation = commonSystemInformation; @@ -59,7 +59,7 @@ public class GlobalSystemSection implements SystemInfoSection, Global { setAttribute(protobuf, "Server ID", server.getId()); setAttribute(protobuf, "Edition", sonarRuntime.getEdition().getLabel()); setAttribute(protobuf, NCLOC.getName() ,statisticsSupport.getLinesOfCode()); - setAttribute(protobuf, "Docker", dockerSupport.isRunningInDocker()); + setAttribute(protobuf, "Container", containerSupport.isRunningInContainer()); setAttribute(protobuf, "High Availability", true); setAttribute(protobuf, "External Users and Groups Provisioning", commonSystemInformation.getManagedInstanceProviderName()); diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java index 384286685ea..c5fe2bfe8f2 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/telemetry/TelemetryDataLoaderImpl.java @@ -58,7 +58,7 @@ import org.sonar.db.newcodeperiod.NewCodePeriodDto; import org.sonar.db.qualitygate.ProjectQgateAssociationDto; import org.sonar.db.qualitygate.QualityGateDto; import org.sonar.server.management.ManagedInstanceService; -import org.sonar.server.platform.DockerSupport; +import org.sonar.server.platform.ContainerSupport; import org.sonar.server.property.InternalProperties; import org.sonar.server.qualitygate.QualityGateCaycChecker; import org.sonar.server.qualitygate.QualityGateFinder; @@ -105,7 +105,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader { private final PlatformEditionProvider editionProvider; private final Configuration configuration; private final InternalProperties internalProperties; - private final DockerSupport dockerSupport; + private final ContainerSupport containerSupport; private final QualityGateCaycChecker qualityGateCaycChecker; private final QualityGateFinder qualityGateFinder; private final ManagedInstanceService managedInstanceService; @@ -118,7 +118,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader { @Inject public TelemetryDataLoaderImpl(Server server, DbClient dbClient, PluginRepository pluginRepository, PlatformEditionProvider editionProvider, InternalProperties internalProperties, Configuration configuration, - DockerSupport dockerSupport, QualityGateCaycChecker qualityGateCaycChecker, QualityGateFinder qualityGateFinder, + ContainerSupport containerSupport, QualityGateCaycChecker qualityGateCaycChecker, QualityGateFinder qualityGateFinder, ManagedInstanceService managedInstanceService, CloudUsageDataProvider cloudUsageDataProvider) { this.server = server; this.dbClient = dbClient; @@ -126,7 +126,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader { this.editionProvider = editionProvider; this.internalProperties = internalProperties; this.configuration = configuration; - this.dockerSupport = dockerSupport; + this.containerSupport = containerSupport; this.qualityGateCaycChecker = qualityGateCaycChecker; this.qualityGateFinder = qualityGateFinder; this.managedInstanceService = managedInstanceService; @@ -181,7 +181,7 @@ public class TelemetryDataLoaderImpl implements TelemetryDataLoader { return data .setInstallationVersion(installationVersionProperty.orElse(null)) - .setInDocker(dockerSupport.isRunningInDocker()) + .setInContainer(containerSupport.isRunningInContainer()) .setManagedInstanceInformation(buildManagedInstanceInformation()) .setCloudUsage(buildCloudUsage()) .build(); diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DockerSupportImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ContainerSupportImplTest.java similarity index 92% rename from server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DockerSupportImplTest.java rename to server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ContainerSupportImplTest.java index c5e15fc0f56..7b3188a2171 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/DockerSupportImplTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/ContainerSupportImplTest.java @@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class DockerSupportImplTest { +public class ContainerSupportImplTest { private static final String CGROUP_DIR = "/proc/1/cgroup"; private static final String PODMAN_FILE_PATH = "/run/.containerenv"; @@ -42,7 +42,7 @@ public class DockerSupportImplTest { public TemporaryFolder temporaryFolder = new TemporaryFolder(); private Paths2 paths2 = mock(Paths2.class); - private DockerSupportImpl underTest = new DockerSupportImpl(paths2); + private ContainerSupportImpl underTest = new ContainerSupportImpl(paths2); @Test public void isInDocker_returns_false_if_cgroup_file_does_not_exist() throws IOException { @@ -50,7 +50,7 @@ public class DockerSupportImplTest { Files.delete(emptyFile); when(paths2.get(CGROUP_DIR)).thenReturn(emptyFile); - assertThat(underTest.isRunningInDocker()).isFalse(); + assertThat(underTest.isRunningInContainer()).isFalse(); } @Test @@ -58,7 +58,7 @@ public class DockerSupportImplTest { Path emptyFile = temporaryFolder.newFile().toPath(); when(paths2.get(CGROUP_DIR)).thenReturn(emptyFile); - assertThat(underTest.isRunningInDocker()).isFalse(); + assertThat(underTest.isRunningInContainer()).isFalse(); } @Test @@ -77,7 +77,7 @@ public class DockerSupportImplTest { FileUtils.write(cgroupFile.toFile(), content, StandardCharsets.UTF_8); when(paths2.get(CGROUP_DIR)).thenReturn(cgroupFile); - assertThat(underTest.isRunningInDocker()).isFalse(); + assertThat(underTest.isRunningInContainer()).isFalse(); } @Test @@ -96,7 +96,7 @@ public class DockerSupportImplTest { FileUtils.write(cgroupFile.toFile(), content, StandardCharsets.UTF_8); when(paths2.get(CGROUP_DIR)).thenReturn(cgroupFile); - assertThat(underTest.isRunningInDocker()).isTrue(); + assertThat(underTest.isRunningInContainer()).isTrue(); } @Test @@ -116,7 +116,7 @@ public class DockerSupportImplTest { FileUtils.write(cgroupFile.toFile(), content, StandardCharsets.UTF_8); when(paths2.get(CGROUP_DIR)).thenReturn(cgroupFile); - assertThat(underTest.isRunningInDocker()).isTrue(); + assertThat(underTest.isRunningInContainer()).isTrue(); } @Test @@ -138,13 +138,13 @@ public class DockerSupportImplTest { FileUtils.write(cgroupFile.toFile(), content, StandardCharsets.UTF_8); when(paths2.get(CGROUP_DIR)).thenReturn(cgroupFile); - assertThat(underTest.isRunningInDocker()).isTrue(); + assertThat(underTest.isRunningInContainer()).isTrue(); } @Test public void isInDocker_returns_true_if_podman_file_exists() throws IOException { when(paths2.exists(PODMAN_FILE_PATH)).thenReturn(true); - assertThat(underTest.isRunningInDocker()).isTrue(); + assertThat(underTest.isRunningInContainer()).isTrue(); } @Test @@ -152,7 +152,7 @@ public class DockerSupportImplTest { when(paths2.exists(PODMAN_FILE_PATH)).thenReturn(false); Path emptyFile = temporaryFolder.newFile().toPath(); when(paths2.get(CGROUP_DIR)).thenReturn(emptyFile); - assertThat(underTest.isRunningInDocker()).isFalse(); + assertThat(underTest.isRunningInContainer()).isFalse(); } } diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/StandaloneSystemSectionTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/StandaloneSystemSectionTest.java index 25b06a0dcbf..6b63912df9c 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/StandaloneSystemSectionTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/StandaloneSystemSectionTest.java @@ -34,7 +34,7 @@ import org.sonar.api.platform.Server; import org.sonar.api.utils.log.LoggerLevel; import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo; import org.sonar.server.log.ServerLogging; -import org.sonar.server.platform.DockerSupport; +import org.sonar.server.platform.ContainerSupport; import org.sonar.server.platform.OfficialDistribution; import org.sonar.server.platform.StatisticsSupport; @@ -58,13 +58,13 @@ public class StandaloneSystemSectionTest { private final Server server = mock(Server.class); private final ServerLogging serverLogging = mock(ServerLogging.class); private final OfficialDistribution officialDistribution = mock(OfficialDistribution.class); - private final DockerSupport dockerSupport = mock(DockerSupport.class); + private final ContainerSupport containerSupport = mock(ContainerSupport.class); private final StatisticsSupport statisticsSupport = mock(StatisticsSupport.class); private final SonarRuntime sonarRuntime = mock(SonarRuntime.class); private final CommonSystemInformation commonSystemInformation = mock(CommonSystemInformation.class); private final StandaloneSystemSection underTest = new StandaloneSystemSection(config, server, serverLogging, - officialDistribution, dockerSupport, statisticsSupport, sonarRuntime, commonSystemInformation); + officialDistribution, containerSupport, statisticsSupport, sonarRuntime, commonSystemInformation); @Before public void setUp() { @@ -168,10 +168,10 @@ public class StandaloneSystemSectionTest { @Test @UseDataProvider("trueOrFalse") - public void return_docker_flag_from_DockerSupport(boolean flag) { - when(dockerSupport.isRunningInDocker()).thenReturn(flag); + public void toProtobuf_whenRunningOrNotRunningInContainer_shouldReturnCorrectFlag(boolean flag) { + when(containerSupport.isRunningInContainer()).thenReturn(flag); ProtobufSystemInfo.Section protobuf = underTest.toProtobuf(); - assertThat(attribute(protobuf, "Docker").getBooleanValue()).isEqualTo(flag); + assertThat(attribute(protobuf, "Container").getBooleanValue()).isEqualTo(flag); } @Test diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSectionTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSectionTest.java index 95711e23360..83e30a01fd3 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSectionTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/monitoring/cluster/GlobalSystemSectionTest.java @@ -29,7 +29,7 @@ import org.junit.runner.RunWith; import org.sonar.api.SonarRuntime; import org.sonar.api.platform.Server; import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo; -import org.sonar.server.platform.DockerSupport; +import org.sonar.server.platform.ContainerSupport; import org.sonar.server.platform.StatisticsSupport; import org.sonar.server.platform.monitoring.CommonSystemInformation; @@ -45,12 +45,12 @@ import static org.sonar.server.platform.monitoring.SystemInfoTesting.assertThatA public class GlobalSystemSectionTest { private final Server server = mock(Server.class); - private final DockerSupport dockerSupport = mock(DockerSupport.class); + private final ContainerSupport containerSupport = mock(ContainerSupport.class); private final StatisticsSupport statisticsSupport = mock(StatisticsSupport.class); private final SonarRuntime sonarRuntime = mock(SonarRuntime.class); private final CommonSystemInformation commonSystemInformation = mock(CommonSystemInformation.class); - private final GlobalSystemSection underTest = new GlobalSystemSection(server, dockerSupport, statisticsSupport, sonarRuntime, commonSystemInformation); + private final GlobalSystemSection underTest = new GlobalSystemSection(server, containerSupport, statisticsSupport, sonarRuntime, commonSystemInformation); @Before public void setUp() { @@ -141,11 +141,11 @@ public class GlobalSystemSectionTest { @Test @UseDataProvider("trueOrFalse") - public void get_docker_flag(boolean flag) { - when(dockerSupport.isRunningInDocker()).thenReturn(flag); + public void toProtobuf_whenRunningOrNotRunningInContainer_shouldReturnCorrectFlag(boolean flag) { + when(containerSupport.isRunningInContainer()).thenReturn(flag); ProtobufSystemInfo.Section protobuf = underTest.toProtobuf(); - assertThatAttributeIs(protobuf, "Docker", flag); + assertThatAttributeIs(protobuf, "Container", flag); } @Test diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java index 40aa17d9dcf..2ffedd16707 100644 --- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryDataLoaderImplTest.java @@ -57,7 +57,7 @@ import org.sonar.db.user.UserDbTester; import org.sonar.db.user.UserDto; import org.sonar.db.user.UserTelemetryDto; import org.sonar.server.management.ManagedInstanceService; -import org.sonar.server.platform.DockerSupport; +import org.sonar.server.platform.ContainerSupport; import org.sonar.server.property.InternalProperties; import org.sonar.server.property.MapInternalProperties; import org.sonar.server.qualitygate.QualityGateCaycChecker; @@ -108,7 +108,7 @@ public class TelemetryDataLoaderImplTest { private final PluginRepository pluginRepository = mock(PluginRepository.class); private final Configuration configuration = mock(Configuration.class); private final PlatformEditionProvider editionProvider = mock(PlatformEditionProvider.class); - private final DockerSupport dockerSupport = mock(DockerSupport.class); + private final ContainerSupport containerSupport = mock(ContainerSupport.class); private final QualityGateCaycChecker qualityGateCaycChecker = mock(QualityGateCaycChecker.class); private final QualityGateFinder qualityGateFinder = new QualityGateFinder(db.getDbClient()); private final InternalProperties internalProperties = spy(new MapInternalProperties()); @@ -116,9 +116,9 @@ public class TelemetryDataLoaderImplTest { private final CloudUsageDataProvider cloudUsageDataProvider = mock(CloudUsageDataProvider.class); private final TelemetryDataLoader communityUnderTest = new TelemetryDataLoaderImpl(server, db.getDbClient(), pluginRepository, editionProvider, - internalProperties, configuration, dockerSupport, qualityGateCaycChecker, qualityGateFinder, managedInstanceService, cloudUsageDataProvider); + internalProperties, configuration, containerSupport, qualityGateCaycChecker, qualityGateFinder, managedInstanceService, cloudUsageDataProvider); private final TelemetryDataLoader commercialUnderTest = new TelemetryDataLoaderImpl(server, db.getDbClient(), pluginRepository, editionProvider, - internalProperties, configuration, dockerSupport, qualityGateCaycChecker, qualityGateFinder, managedInstanceService, cloudUsageDataProvider); + internalProperties, configuration, containerSupport, qualityGateCaycChecker, qualityGateFinder, managedInstanceService, cloudUsageDataProvider); private QualityGateDto builtInDefaultQualityGate; private MetricDto bugsDto; @@ -228,7 +228,7 @@ public class TelemetryDataLoaderImplTest { assertDatabaseMetadata(data.getDatabase()); assertThat(data.getPlugins()).containsOnly( entry("java", "4.12.0.11033"), entry("scmgit", "1.2"), entry("other", "undefined")); - assertThat(data.isInDocker()).isFalse(); + assertThat(data.isInContainer()).isFalse(); assertThat(data.getUserTelemetries()) .extracting(UserTelemetryDto::getUuid, UserTelemetryDto::getLastConnectionDate, UserTelemetryDto::getLastSonarlintConnectionDate, UserTelemetryDto::isActive) diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java index cfeb6a998b6..99dad1a58d3 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java @@ -52,7 +52,7 @@ import org.sonar.server.issue.index.IssueIndex; import org.sonar.server.issue.index.IssueIndexSyncProgressChecker; import org.sonar.server.permission.index.WebAuthorizationTypeSupport; import org.sonar.server.platform.DefaultNodeInformation; -import org.sonar.server.platform.DockerSupportImpl; +import org.sonar.server.platform.ContainerSupportImpl; import org.sonar.server.platform.LogServerVersion; import org.sonar.server.platform.Platform; import org.sonar.server.platform.ServerFileSystemImpl; @@ -115,7 +115,7 @@ public class PlatformLevel1 extends PlatformLevel { new TempFolderProvider(), System2.INSTANCE, Paths2Impl.getInstance(), - DockerSupportImpl.class, + ContainerSupportImpl.class, Clock.systemDefaultZone(), // user session -- 2.39.5