try {
Optional<UpdateCenter> updateCenter = updateCenterMatrixFactory.getUpdateCenter(true);
if (!updateCenter.isPresent()) {
+ LOG.info("Installation of edition '{}' needs to be done manually", newLicense.getEditionKey());
editionManagementState.startManualInstall(newLicense);
return;
}
Set<String> pluginsToRemove = pluginsToRemove(editionPluginKeys, pluginInfosByKeys.values());
Set<String> pluginsToInstall = pluginsToInstall(editionPluginKeys, pluginInfosByKeys.keySet());
+ LOG.info("Installing edition '{}', download: {}, remove: {}",
+ newLicense.getEditionKey(), pluginsToInstall, pluginsToRemove);
+
editionPluginDownloader.downloadEditionPlugins(pluginsToInstall, updateCenter);
uninstallPlugins(pluginsToRemove);
editionManagementState.automaticInstallReady();
pluginsToRemove.stream().forEach(editionPluginUninstaller::uninstall);
}
- private Set<String> pluginsToInstall(Set<String> editionPluginKeys, Set<String> installedPluginKeys) {
+ private static Set<String> pluginsToInstall(Set<String> editionPluginKeys, Set<String> installedPluginKeys) {
return editionPluginKeys.stream()
.filter(p -> !installedPluginKeys.contains(p))
.collect(Collectors.toSet());
}
- private Set<String> pluginsToRemove(Set<String> editionPluginKeys, Collection<PluginInfo> installedPluginInfos) {
+ private static Set<String> pluginsToRemove(Set<String> editionPluginKeys, Collection<PluginInfo> installedPluginInfos) {
Set<String> installedCommercialPluginKeys = installedPluginInfos.stream()
.filter(EditionBundledPlugins::isEditionBundled)
.map(PluginInfo::getKey)
protected void download(Release release) {
try {
+ LOG.info("Downloading plugin: {}", release.getArtifact().getKey());
downloadRelease(release);
} catch (Exception e) {
String message = String.format("Fail to download the plugin (%s, version %s) from %s (error is : %s)",
verify(uninstaller).uninstall("p2");
verifyNoMoreInteractions(uninstaller);
verifyNoMoreInteractions(downloader);
+ assertThat(logTester.logs()).containsOnly("Installing edition 'edition-key', download: [p4], remove: [p2]");
+
}
@Test
verifyZeroInteractions(downloader);
verify(editionManagementState).startManualInstall(newLicense);
verifyNoMoreInteractions(editionManagementState);
+ assertThat(logTester.logs()).containsOnly("Installation of edition 'edition-key' needs to be done manually");
}
@Test
verify(editionManagementState).startAutomaticInstall(newLicense);
verify(editionManagementState).installFailed(expectedErrorMessage);
verifyNoMoreInteractions(editionManagementState);
- assertThat(logTester.logs()).hasSize(1);
assertThat(logTester.logs(LoggerLevel.ERROR))
.containsOnly("Failed to install edition " + newLicense.getEditionKey() + " with plugins " + newLicense.getPluginKeys());
}
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.utils.HttpDownloader;
+import org.sonar.api.utils.log.LogTester;
import org.sonar.server.platform.ServerFileSystem;
import org.sonar.updatecenter.common.Plugin;
import org.sonar.updatecenter.common.Release;
import static org.mockito.Mockito.when;
public class EditionPluginDownloaderTest {
+ @Rule
+ public LogTester logTester = new LogTester();
+
@Rule
public TemporaryFolder temp = new TemporaryFolder();
verify(httpDownloader).download(new URI("http://host/plugin1.jar"), new File(tmpDir, "plugin1.jar"));
verify(httpDownloader).download(new URI("http://host/plugin2.jar"), new File(tmpDir, "plugin2.jar"));
+ assertThat(logTester.logs()).containsOnly("Downloading plugin: plugin1", "Downloading plugin: plugin2");
assertThat(downloadDir).isDirectory();
assertThat(tmpDir).doesNotExist();
}