]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9514 Disable automatic creation of unknown Elasticsearch indices
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 17 Jul 2017 16:14:14 +0000 (18:14 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 21 Jul 2017 22:31:15 +0000 (00:31 +0200)
server/sonar-search/src/main/java/org/sonar/search/EsSettings.java
server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java
server/sonar-server/src/test/java/org/sonar/server/es/request/ProxyDeleteRequestBuilderTest.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexerTest.java

index bb882f38a0d2e4f94b06d7b61c9e221564a45b22..052e5e26beffab624dd36adc7a76a7bb0e7235b5 100644 (file)
@@ -154,7 +154,8 @@ public class EsSettings implements EsSettingsMBean {
       .put("index.number_of_shards", "1")
       .put("index.refresh_interval", "30s")
       .put("action.auto_create_index", false)
-      .put("index.mapper.dynamic", false);
+      .put("index.mapper.dynamic", false)
+      .put("action.auto_create_index", false);
   }
 
   private void configureCluster(Settings.Builder builder) {
index 56fd0b9d5b521885e42da0bffd1ab1ee4842981c..077d997c2e86375d34d1968ba934ed80d232a84f 100644 (file)
@@ -219,6 +219,7 @@ public class EsTester extends ExternalResource {
           .put("processors", 1)
           .put("http.enabled", false)
           .put("config.ignore_system_properties", true)
+          .put("action.auto_create_index", false)
           .put("path.home", tmpDir))
           .build();
         node.start();
index ca7d09033241aa5b84cfb102becccc5c5be9e1cd..dda250c948ec71484e87ecf0a7c150d25bdb1b66 100644 (file)
@@ -26,6 +26,7 @@ import org.junit.Test;
 import org.sonar.api.utils.log.LogTester;
 import org.sonar.api.utils.log.LoggerLevel;
 import org.sonar.server.es.EsTester;
+import org.sonar.server.es.FakeIndexDefinition;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.fail;
@@ -33,7 +34,7 @@ import static org.junit.Assert.fail;
 public class ProxyDeleteRequestBuilderTest {
 
   @ClassRule
-  public static EsTester esTester = new EsTester();
+  public static EsTester esTester = new EsTester(new FakeIndexDefinition());
 
   @Rule
   public LogTester logTester = new LogTester();
index 32011df23d611002db376e42d51eb03bb3bb6a5e..0fa1fc57b54977c5e6fda85868df2777d9380230 100644 (file)
@@ -120,8 +120,7 @@ public class ActiveRuleIndexerTest {
   @Test
   public void commitAndIndex_keeps_elements_to_recover_in_ES_QUEUE_on_errors() {
     ActiveRuleDto ar = db.qualityProfiles().activateRule(profile1, rule1);
-    // force error by deleting the index
-    deleteRulesIndex();
+    es.lockWrites(INDEX_TYPE_ACTIVE_RULE);
 
     commitAndIndex(ar);
 
@@ -177,11 +176,6 @@ public class ActiveRuleIndexerTest {
     assertThat(es.countDocuments(INDEX_TYPE_ACTIVE_RULE)).isEqualTo(1);
   }
 
-
-  private void deleteRulesIndex() {
-    es.deleteIndex(RuleIndexDefinition.INDEX_TYPE_RULE.getIndex());
-  }
-
   private void assertThatEsQueueTableIsEmpty() {
     assertThat(db.countRowsOfTable(db.getSession(), "es_queue")).isEqualTo(0);
   }