From 386d2785b86cd08948ab669dea078e60929303cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Thu, 19 Oct 2017 11:13:39 +0200 Subject: [PATCH] SONAR-9951 move edition install commit to startup level because extensions from plugins (including license-manager) are loaded at startup level --- .../EditionManagementCommitModule.java | 33 --------------- .../server/edition/EditionsWsModule.java | 1 + .../platformlevel/PlatformLevel3.java | 4 +- .../platformlevel/PlatformLevelStartup.java | 4 +- .../CommitPendingEditionOnStartupTest.java | 6 +-- .../EditionManagementCommitModuleTest.java | 40 ------------------- .../server/edition/EditionsWsModuleTest.java | 2 +- 7 files changed, 9 insertions(+), 81 deletions(-) delete mode 100644 server/sonar-server/src/main/java/org/sonar/server/edition/EditionManagementCommitModule.java delete mode 100644 server/sonar-server/src/test/java/org/sonar/server/edition/EditionManagementCommitModuleTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/edition/EditionManagementCommitModule.java b/server/sonar-server/src/main/java/org/sonar/server/edition/EditionManagementCommitModule.java deleted file mode 100644 index 6e417a40f38..00000000000 --- a/server/sonar-server/src/main/java/org/sonar/server/edition/EditionManagementCommitModule.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.edition; - -import org.sonar.core.platform.Module; - -public class EditionManagementCommitModule extends Module { - @Override - protected void configureModule() { - add( - // TODO add cluster ready implementation when not running Standalone - // Edition management WebServices also depend on this class - StandaloneEditionManagementStateImpl.class, - CommitPendingEditionOnStartup.class); - } -} diff --git a/server/sonar-server/src/main/java/org/sonar/server/edition/EditionsWsModule.java b/server/sonar-server/src/main/java/org/sonar/server/edition/EditionsWsModule.java index 37027d6c5f0..75f2da37c91 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/edition/EditionsWsModule.java +++ b/server/sonar-server/src/main/java/org/sonar/server/edition/EditionsWsModule.java @@ -32,6 +32,7 @@ public class EditionsWsModule extends Module { @Override protected void configureModule() { add( + StandaloneEditionManagementStateImpl.class, StatusAction.class, ApplyLicenseAction.class, PreviewAction.class, diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel3.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel3.java index 8df49bfdf3a..d7c3a3753b6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel3.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel3.java @@ -21,7 +21,6 @@ package org.sonar.server.platform.platformlevel; import org.sonar.api.utils.UriReader; import org.sonar.core.util.DefaultHttpDownloader; -import org.sonar.server.edition.EditionManagementCommitModule; import org.sonar.server.organization.DefaultOrganizationProviderImpl; import org.sonar.server.organization.OrganizationFlagsImpl; import org.sonar.server.platform.ServerIdManager; @@ -48,7 +47,6 @@ public class PlatformLevel3 extends PlatformLevel { UriReader.class, DefaultHttpDownloader.class, DefaultOrganizationProviderImpl.class, - OrganizationFlagsImpl.class, - EditionManagementCommitModule.class); + OrganizationFlagsImpl.class); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java index f8c07e82b44..f8229f4f65a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevelStartup.java @@ -20,6 +20,7 @@ package org.sonar.server.platform.platformlevel; import org.sonar.server.app.ProcessCommandWrapper; +import org.sonar.server.edition.CommitPendingEditionOnStartup; import org.sonar.server.es.IndexerStartupTask; import org.sonar.server.organization.DefaultOrganizationEnforcer; import org.sonar.server.platform.ServerLifecycleNotifier; @@ -52,7 +53,8 @@ public class PlatformLevelStartup extends PlatformLevel { add(GeneratePluginIndex.class, RegisterPlugins.class, ServerLifecycleNotifier.class, - DefaultOrganizationEnforcer.class); + DefaultOrganizationEnforcer.class, + CommitPendingEditionOnStartup.class); addIfStartupLeader( IndexerStartupTask.class, diff --git a/server/sonar-server/src/test/java/org/sonar/server/edition/CommitPendingEditionOnStartupTest.java b/server/sonar-server/src/test/java/org/sonar/server/edition/CommitPendingEditionOnStartupTest.java index 5318e3a8944..94c128fcec2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/edition/CommitPendingEditionOnStartupTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/edition/CommitPendingEditionOnStartupTest.java @@ -44,7 +44,7 @@ public class CommitPendingEditionOnStartupTest { public ExpectedException expectedException = ExpectedException.none(); @Rule public LogTester logTester = new LogTester() - .setLevel(LoggerLevel.DEBUG); + .setLevel(LoggerLevel.DEBUG); private MutableEditionManagementState editionManagementState = mock(MutableEditionManagementState.class); private LicenseCommit licenseCommit = mock(LicenseCommit.class); @@ -83,7 +83,7 @@ public class CommitPendingEditionOnStartupTest { verifyZeroInteractions(licenseCommit); assertThat(logTester.logs()).hasSize(1); assertThat(logTester.logs(LoggerLevel.DEBUG)) - .containsOnly("No LicenseCommit instance is not available, can not finalize installation"); + .containsOnly("No LicenseCommit instance is not available, can not finalize installation"); } @Test @@ -113,7 +113,7 @@ public class CommitPendingEditionOnStartupTest { verifyZeroInteractions(licenseCommit); assertThat(logTester.logs()).hasSize(1); assertThat(logTester.logs(LoggerLevel.DEBUG)) - .containsOnly("No LicenseCommit instance is not available, can not finalize installation"); + .containsOnly("No LicenseCommit instance is not available, can not finalize installation"); } @Test diff --git a/server/sonar-server/src/test/java/org/sonar/server/edition/EditionManagementCommitModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/edition/EditionManagementCommitModuleTest.java deleted file mode 100644 index 859f87789a1..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/edition/EditionManagementCommitModuleTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.server.edition; - -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 EditionManagementCommitModuleTest { - private EditionManagementCommitModule underTest = new EditionManagementCommitModule(); - - @Test - public void verify_component_count() { - ComponentContainer container = new ComponentContainer(); - underTest.configure(container); - - assertThat(container.getPicoContainer().getComponentAdapters()) - .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 2); - } - -} diff --git a/server/sonar-server/src/test/java/org/sonar/server/edition/EditionsWsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/edition/EditionsWsModuleTest.java index 0a801053276..7a164d50b42 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/edition/EditionsWsModuleTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/edition/EditionsWsModuleTest.java @@ -34,6 +34,6 @@ public class EditionsWsModuleTest { underTest.configure(container); assertThat(container.getPicoContainer().getComponentAdapters()) - .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 7); + .hasSize(COMPONENTS_IN_EMPTY_COMPONENT_CONTAINER + 8); } } -- 2.39.5