aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-server
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-10-18 14:17:10 +0200
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>2017-10-23 08:01:13 -0700
commit45f3d0af08cb5e8e3d54c3d6015962b2b6120cdb (patch)
tree79fb7538a42ef9e546ff78b2ea5682c189755773 /server/sonar-server
parentb2a04354f0a5467a64e6465ec5147a9e43305574 (diff)
downloadsonarqube-45f3d0af08cb5e8e3d54c3d6015962b2b6120cdb.tar.gz
sonarqube-45f3d0af08cb5e8e3d54c3d6015962b2b6120cdb.zip
SONAR-9996 synchronous uninstall of edition
Diffstat (limited to 'server/sonar-server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java15
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java16
2 files changed, 28 insertions, 3 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java
index 8b1e4240e4e..f72e157ee45 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionInstaller.java
@@ -21,6 +21,7 @@ package org.sonar.server.plugins.edition;
import com.google.common.base.Optional;
import java.util.Collection;
+import java.util.Collections;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReentrantLock;
@@ -75,6 +76,12 @@ public class EditionInstaller {
}
}
+ public void uninstall() {
+ Map<String, PluginInfo> pluginInfosByKeys = pluginRepository.getPluginInfosByKeys();
+ Set<String> pluginsToRemove = pluginsToRemove(Collections.emptySet(), pluginInfosByKeys.values());
+ uninstallPlugins(pluginsToRemove);
+ }
+
public boolean isOffline() {
return !updateCenterMatrixFactory.getUpdateCenter(true).isPresent();
}
@@ -93,9 +100,7 @@ public class EditionInstaller {
try {
editionPluginDownloader.downloadEditionPlugins(pluginsToInstall, updateCenter);
- for (String pluginKey : pluginsToRemove) {
- editionPluginUninstaller.uninstall(pluginKey);
- }
+ uninstallPlugins(pluginsToRemove);
editionManagementState.automaticInstallReady();
} finally {
lock.unlock();
@@ -103,6 +108,10 @@ public class EditionInstaller {
}
}
+ private void uninstallPlugins(Set<String> pluginsToRemove) {
+ pluginsToRemove.stream().forEach(editionPluginUninstaller::uninstall);
+ }
+
private Set<String> pluginsToInstall(Set<String> editionPluginKeys, Set<String> installedPluginKeys) {
return editionPluginKeys.stream()
.filter(p -> !installedPluginKeys.contains(p))
diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java
index ff988300f94..e4c0603642f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionInstallerTest.java
@@ -91,6 +91,22 @@ public class EditionInstallerTest {
}
@Test
+ public void uninstall_commercial_plugins() {
+ PluginInfo commercial1 = createPluginInfo("p1", true);
+ PluginInfo commercial2 = createPluginInfo("p2", true);
+ PluginInfo open1 = createPluginInfo("p3", false);
+ mockPluginRepository(commercial1, commercial2, open1);
+
+ installer.uninstall();
+
+ verify(uninstaller).uninstall("p2");
+ verify(uninstaller).uninstall("p1");
+
+ verifyNoMoreInteractions(uninstaller);
+ verifyZeroInteractions(downloader);
+ }
+
+ @Test
public void do_nothing_if_offline() {
mockPluginRepository(createPluginInfo("p1", true));
executor = mock(EditionInstallerExecutor.class);