]> source.dussan.org Git - sonarqube.git/commitdiff
Do not reuse previous Elasticsearch installations in EsTester
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 28 Nov 2014 15:04:59 +0000 (16:04 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 28 Nov 2014 15:05:12 +0000 (16:05 +0100)
server/sonar-server/src/test/java/org/sonar/server/es/EsTester.java

index d48414d87ec7dd97592c91e0dd536a02b60ba48f..032a11a7edd3636d2215d3942db994ff3d748de2 100644 (file)
@@ -51,12 +51,13 @@ import org.sonar.test.TestUtils;
 import java.io.FileInputStream;
 import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
 
 import static org.fest.assertions.Assertions.assertThat;
 
 public class EsTester extends ExternalResource {
 
-  private static int PROCESS_ID = RandomUtils.nextInt(Integer.MAX_VALUE);
+  private static final AtomicInteger INSTANCE_ID = new AtomicInteger();
   private Node node;
   private EsClient client;
   private final List<IndexDefinition> definitions = Lists.newArrayList();
@@ -67,7 +68,7 @@ public class EsTester extends ExternalResource {
   }
 
   protected void before() throws Throwable {
-    String nodeName = "es-ram-" + PROCESS_ID;
+    String nodeName = "es-ram-" + INSTANCE_ID.getAndIncrement();
     node = NodeBuilder.nodeBuilder().local(true).data(true).settings(ImmutableSettings.builder()
       .put("cluster.name", nodeName)
       .put("node.name", nodeName)
@@ -81,7 +82,7 @@ public class EsTester extends ExternalResource {
       .put("index.store.type", "memory")
       .put("config.ignore_system_properties", true)
       // reuse the same directory than other tests for faster initialization
-      .put("path.home", "target/es-" + PROCESS_ID)
+      .put("path.home", "target/" + nodeName)
       .put("gateway.type", "none"))
       .build();
     node.start();