]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11792 change ES data directory to es6
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 11 Mar 2019 13:20:30 +0000 (14:20 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 19 Mar 2019 19:21:24 +0000 (20:21 +0100)
server/sonar-main/src/main/java/org/sonar/application/es/EsInstallation.java
server/sonar-main/src/test/java/org/sonar/application/es/EsInstallationTest.java

index 1aa567f2f8446f717fef85299bdf7f12ded707de..12789f8c38b683d86b7f2147ca3950719ae4f3b0 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.application.es;
 
 import java.io.File;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
@@ -64,12 +65,12 @@ public class EsInstallation {
 
   private static List<File> buildOutdatedSearchDirs(Props props) {
     String dataPath = props.nonNullValue(PATH_DATA.getKey());
-    return Collections.singletonList(new File(dataPath, "es"));
+    return Arrays.asList(new File(dataPath, "es"), new File(dataPath, "es5"));
   }
 
   private static File buildDataDir(Props props) {
     String dataPath = props.nonNullValue(PATH_DATA.getKey());
-    return new File(dataPath, "es5");
+    return new File(dataPath, "es6");
   }
 
   private static File buildLogPath(Props props) {
index 99c436edcf07927d78d552aac0a172d53c70b7a2..31cb90d41152727ff27a61fd648cfdca275b2c42 100644 (file)
@@ -102,7 +102,7 @@ public class EsInstallationTest {
 
     EsInstallation underTest = new EsInstallation(props);
 
-    assertThat(underTest.getDataDirectory()).isEqualTo(new File(dataDir, "es5"));
+    assertThat(underTest.getDataDirectory()).isEqualTo(new File(dataDir, "es6"));
   }
 
   @Test
@@ -120,6 +120,23 @@ public class EsInstallationTest {
     assertThat(underTest.getLogDirectory()).isEqualTo(logDir);
   }
 
+  @Test
+  public void getOutdatedSearchDirectories_returns_all_previously_used_es_data_directory_names() throws IOException {
+    File sqHomeDir = temp.newFolder();
+    File logDir = temp.newFolder();
+    Props props = new Props(new Properties());
+    props.set(PATH_DATA.getKey(), temp.newFolder().getAbsolutePath());
+    props.set(PATH_HOME.getKey(), sqHomeDir.getAbsolutePath());
+    props.set(PATH_TEMP.getKey(), temp.newFolder().getAbsolutePath());
+    props.set(PATH_LOGS.getKey(), logDir.getAbsolutePath());
+
+    EsInstallation underTest = new EsInstallation(props);
+
+    assertThat(underTest.getOutdatedSearchDirectories())
+      .extracting(t -> t.getName())
+      .containsOnly("es", "es5");
+  }
+
   @Test
   public void conf_directory_is_conf_es_subdirectory_of_sq_temp_directory() throws IOException {
     File tempDir = temp.newFolder();