From: Sébastien Lesaint Date: Fri, 11 Mar 2016 16:04:29 +0000 (+0100) Subject: SONAR-6732 add components from PlatformLevel3 to CE container X-Git-Tag: 5.5-M11~79 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=01bd8bad45950a561d20b0b34c790268af3abfee;p=sonarqube.git SONAR-6732 add components from PlatformLevel3 to CE container --- diff --git a/server/sonar-ce/pom.xml b/server/sonar-ce/pom.xml index 357ead56d1a..f9ead798b1d 100644 --- a/server/sonar-ce/pom.xml +++ b/server/sonar-ce/pom.xml @@ -30,6 +30,18 @@ sonar-testing-harness test + + ${project.groupId} + sonar-db + ${project.version} + test-jar + test + + + org.dbunit + dbunit + test + diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java index 6bb67ee7f87..a3a4c65fec0 100644 --- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java +++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java @@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting; import java.util.List; import org.sonar.api.utils.Durations; import org.sonar.api.utils.System2; +import org.sonar.api.utils.UriReader; import org.sonar.core.config.CorePropertyDefinitions; import org.sonar.core.i18n.DefaultI18n; import org.sonar.core.i18n.RuleI18nManager; @@ -31,6 +32,7 @@ import org.sonar.core.platform.Module; import org.sonar.core.platform.PluginClassloaderFactory; import org.sonar.core.platform.PluginLoader; import org.sonar.core.platform.SonarQubeVersionProvider; +import org.sonar.core.util.DefaultHttpDownloader; import org.sonar.core.util.UuidFactoryImpl; import org.sonar.db.DaoModule; import org.sonar.db.DatabaseChecker; @@ -45,6 +47,8 @@ import org.sonar.server.issue.index.IssueIndex; import org.sonar.server.platform.DatabaseServerCompatibility; import org.sonar.server.platform.DefaultServerFileSystem; import org.sonar.server.platform.DefaultServerUpgradeStatus; +import org.sonar.server.platform.PersistentSettings; +import org.sonar.server.platform.ServerIdGenerator; import org.sonar.server.platform.ServerImpl; import org.sonar.server.platform.ServerSettings; import org.sonar.server.platform.TempFolderProvider; @@ -55,6 +59,7 @@ import org.sonar.server.plugins.ServerPluginRepository; import org.sonar.server.qualityprofile.index.ActiveRuleIndex; import org.sonar.server.rule.index.RuleIndex; import org.sonar.server.search.EsSearchModule; +import org.sonar.server.startup.ServerMetadataPersister; public class ComputeEngineContainerImpl implements ComputeEngineContainer { private static final Object[] LEVEL_1_COMPONENTS = new Object[] { @@ -113,6 +118,13 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { RuleI18nManager.class, // used by DebtRulesXMLImporter Durations.class, // used in Web Services and DebtCalculator }; + private static final Object[] LEVEL_3_COMPONENTS = new Object[] { + PersistentSettings.class, + ServerMetadataPersister.class, + DefaultHttpDownloader.class, + UriReader.class, + ServerIdGenerator.class + }; private final ComponentContainer componentContainer; @@ -127,7 +139,8 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer { .add(LEVEL_1_COMPONENTS) .add(toArray(CorePropertyDefinitions.all())) .add(toArray(CePropertyDefinitions.all())) - .add(LEVEL_2_COMPONENTS); + .add(LEVEL_2_COMPONENTS) + .add(LEVEL_3_COMPONENTS); configureFromModules(); diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java index dfba271036d..2dc1905e4f9 100644 --- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java +++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java @@ -22,13 +22,16 @@ package org.sonar.ce.container; import java.io.File; import java.io.IOException; import java.util.Properties; +import org.apache.commons.dbcp.BasicDataSource; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.picocontainer.MutablePicoContainer; import org.sonar.api.config.PropertyDefinitions; import org.sonar.api.database.DatabaseProperties; +import org.sonar.api.utils.System2; import org.sonar.core.platform.ComponentContainer; +import org.sonar.db.DbTester; import org.sonar.process.ProcessProperties; import org.sonar.process.Props; @@ -39,6 +42,8 @@ public class ComputeEngineContainerImplTest { @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); + @Rule + public DbTester dbTester = DbTester.create(System2.INSTANCE); private ComputeEngineContainerImpl underTest = new ComputeEngineContainerImpl(); @@ -66,13 +71,14 @@ public class ComputeEngineContainerImplTest { assertThat(underTest.getComponentContainer().getPicoContainer().getComponentAdapters()) .hasSize(COMPONENTS_IN_CONTAINER_AT_CONSTRUCTION - + 22 // level 1 - + 47 // content of DaoModule - + 1 // content of EsSearchModule - + 58 // content of CorePropertyDefinitions - + 1 // content of CePropertyDefinitions - + 59 // content of MigrationStepModule - + 10 // level 2 + + 22 // level 1 + + 47 // content of DaoModule + + 1 // content of EsSearchModule + + 58 // content of CorePropertyDefinitions + + 1 // content of CePropertyDefinitions + + 59 // content of MigrationStepModule + + 10 // level 2 + + 5 // level 3 ); } @@ -85,7 +91,10 @@ public class ComputeEngineContainerImplTest { properties.setProperty(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath()); properties.setProperty(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath()); properties.setProperty(ProcessProperties.PATH_TEMP, tmpDir.getAbsolutePath()); - properties.setProperty(DatabaseProperties.PROP_URL, "jdbc:h2:mem:sonar"); + String url = ((BasicDataSource) dbTester.database().getDataSource()).getUrl(); + properties.setProperty(DatabaseProperties.PROP_URL, url); + properties.setProperty(DatabaseProperties.PROP_USER, "sonar"); + properties.setProperty(DatabaseProperties.PROP_PASSWORD, "sonar"); underTest .configure(new Props(properties))