]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8092 only index empty types (not all types of an empty index)
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>
Fri, 24 Feb 2017 12:27:54 +0000 (13:27 +0100)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Fri, 24 Feb 2017 16:21:23 +0000 (17:21 +0100)
Old behaviour: If one of the types of an Indexer is empty, reindex all of its types. New behaviour: Reindex all empty types.

19 files changed:
server/sonar-server/src/main/java/org/sonar/server/component/index/ComponentIndexer.java
server/sonar-server/src/main/java/org/sonar/server/es/IndexerStartupTask.java
server/sonar-server/src/main/java/org/sonar/server/es/StartupIndexer.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java
server/sonar-server/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndexer.java
server/sonar-server/src/main/java/org/sonar/server/permission/index/PermissionIndexer.java
server/sonar-server/src/main/java/org/sonar/server/test/index/TestIndexer.java
server/sonar-server/src/main/java/org/sonar/server/user/index/UserIndexer.java
server/sonar-server/src/test/java/org/sonar/server/component/index/ComponentIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/component/ws/SuggestionsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/es/IndexerStartupTaskTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/index/PermissionIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/test/index/TestIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java
server/sonar-server/src/test/java/org/sonar/server/user/index/UserIndexerTest.java
server/sonar-server/src/test/java/org/sonar/server/user/ws/SearchActionTest.java
server/sonar-server/src/test/java/org/sonar/server/view/index/ViewIndexerTest.java

index 08078f17362c72a9da50ea2514c3add93281ca76..d5108be1cfdb1485ae459237ce1fe2a0bb1e0125 100644 (file)
@@ -68,7 +68,7 @@ public class ComponentIndexer implements ProjectIndexer, NeedAuthorizationIndexe
   }
 
   @Override
-  public void indexOnStartup() {
+  public void indexOnStartup(Set<IndexType> emptyIndexTypes) {
     doIndexByProjectUuid(null);
   }
 
index 1dd9ef3d467b72c53d9f82e1ecc8dd98b053eaa4..baae54c2d26c605d3d54bc9d75a976f00f56cf2b 100644 (file)
  */
 package org.sonar.server.es;
 
+import java.util.Set;
+import java.util.stream.Collectors;
 import org.sonar.api.config.Settings;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
 
 import static java.util.Arrays.stream;
+import static java.util.stream.Collectors.toSet;
 
 public class IndexerStartupTask {
 
@@ -42,9 +45,7 @@ public class IndexerStartupTask {
   public void execute() {
     if (indexesAreEnabled()) {
       stream(indexers)
-        .filter(this::doesIndexContainAtLeastOneEmptyType)
-        .peek(indexer -> LOG.info("Full reindexing using " + indexer.getClass().getSimpleName()))
-        .forEach(StartupIndexer::indexOnStartup);
+      .forEach(this::indexEmptyTypes);
     }
   }
 
@@ -52,7 +53,22 @@ public class IndexerStartupTask {
     return !settings.getBoolean("sonar.internal.es.disableIndexes");
   }
 
-  private boolean doesIndexContainAtLeastOneEmptyType(StartupIndexer indexer) {
-    return indexer.getIndexTypes().stream().filter(esClient::isEmpty).findAny().isPresent();
+  private void indexEmptyTypes(StartupIndexer indexer) {
+    Set<IndexType> emptyTypes = getEmptyTypes(indexer);
+    if (!emptyTypes.isEmpty()) {
+      log(indexer, emptyTypes);
+      indexer.indexOnStartup(emptyTypes);
+    }
+  }
+
+  private Set<IndexType> getEmptyTypes(StartupIndexer indexer) {
+    return indexer.getIndexTypes().stream().filter(esClient::isEmpty).collect(toSet());
+  }
+
+  private void log(StartupIndexer indexer, Set<IndexType> emptyTypes) {
+    String s = emptyTypes.size() == 1 ? "" : "s";
+    String typeList = emptyTypes.stream().map(Object::toString).collect(Collectors.joining(","));
+    String indexerName = indexer.getClass().getSimpleName();
+    LOG.info("Full indexing of type{} {} using {}", s, typeList, indexerName);
   }
 }
index efe2d98a1f5483d926be501ccb1249d2c8f8c60b..d007e402713e2de7f9f0e82736bfe6f4a69513d2 100644 (file)
@@ -28,9 +28,9 @@ public interface StartupIndexer {
 
   /**
    * This reindexing method will only be called on startup, and only,
-   * if at least one of the types returned by {@link #getIndexTypes()} is empty.
+   * if there is at least one empty types.
    */
-  void indexOnStartup();
+  void indexOnStartup(Set<IndexType> emptyIndexTypes);
 
   Set<IndexType> getIndexTypes();
 
index 06d81746d2dac10c258d18c0153438498ce692ab..79d23bec070fe24e9fe4ac0bf839cff6d7894043 100644 (file)
@@ -68,7 +68,7 @@ public class IssueIndexer implements ProjectIndexer, NeedAuthorizationIndexer, S
   }
 
   @Override
-  public void indexOnStartup() {
+  public void indexOnStartup(Set<IndexType> emptyIndexTypes) {
     doIndex(createBulkIndexer(true), (String) null);
   }
 
index 69d226f370c15b6e102017323ac7457a28c9fa01..90d758916afcbbcb7d2f372a55e64a137b0e3bde 100644 (file)
@@ -58,7 +58,7 @@ public class ProjectMeasuresIndexer implements ProjectIndexer, NeedAuthorization
   }
 
   @Override
-  public void indexOnStartup() {
+  public void indexOnStartup(Set<IndexType> emptyIndexTypes) {
     doIndex(createBulkIndexer(false), (String) null);
   }
 
index 31993121c1aee727e891da90a9053f39f914836c..570ca2d6e07ce71baa57dbda467295c1b639aa31 100644 (file)
@@ -33,7 +33,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-import org.elasticsearch.action.bulk.BulkRequestBuilder;
+import java.util.stream.Stream;
 import org.elasticsearch.action.index.IndexRequest;
 import org.picocontainer.Startable;
 import org.sonar.api.utils.DateUtils;
@@ -42,13 +42,12 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.server.es.BulkIndexer;
 import org.sonar.server.es.EsClient;
-import org.sonar.server.es.EsUtils;
 import org.sonar.server.es.IndexType;
 import org.sonar.server.es.ProjectIndexer;
 import org.sonar.server.es.StartupIndexer;
+import org.sonar.server.permission.index.PermissionIndexerDao.Dto;
 
 import static com.google.common.base.Preconditions.checkArgument;
-import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
 import static org.sonar.core.util.stream.Collectors.toSet;
 
 /**
@@ -63,8 +62,6 @@ public class PermissionIndexer implements ProjectIndexer, Startable, StartupInde
   @VisibleForTesting
   static final int MAX_BATCH_SIZE = 1000;
 
-  private static final String BULK_ERROR_MESSAGE = "Fail to index authorization";
-
   private final ThreadPoolExecutor executor;
   private final DbClient dbClient;
   private final EsClient esClient;
@@ -92,15 +89,11 @@ public class PermissionIndexer implements ProjectIndexer, Startable, StartupInde
   }
 
   @Override
-  public void indexOnStartup() {
+  public void indexOnStartup(Set<IndexType> emptyIndexTypes) {
     Future<?> submit = executor.submit(() -> {
-      authorizationScopes.stream()
-        .map(AuthorizationScope::getIndexType)
-        .forEach(this::truncateAuthorizationType);
-
-      try (DbSession dbSession = dbClient.openSession(false)) {
-        index(new PermissionIndexerDao().selectAll(dbClient, dbSession));
-      }
+      List<Dto> authorizations = getAllAuthorizations();
+      Stream<AuthorizationScope> scopes = getScopes(emptyIndexTypes);
+      index(authorizations, scopes);
     });
     try {
       Uninterruptibles.getUninterruptibly(submit);
@@ -109,10 +102,22 @@ public class PermissionIndexer implements ProjectIndexer, Startable, StartupInde
     }
   }
 
+  private List<Dto> getAllAuthorizations() {
+    try (DbSession dbSession = dbClient.openSession(false)) {
+      return new PermissionIndexerDao().selectAll(dbClient, dbSession);
+    }
+  }
+
   public void indexProjectsByUuids(DbSession dbSession, List<String> viewOrProjectUuids) {
     checkArgument(!viewOrProjectUuids.isEmpty(), "viewOrProjectUuids cannot be empty");
     PermissionIndexerDao dao = new PermissionIndexerDao();
-    index(dao.selectByUuids(dbClient, dbSession, viewOrProjectUuids));
+    List<Dto> authorizations = dao.selectByUuids(dbClient, dbSession, viewOrProjectUuids);
+    index(authorizations);
+  }
+
+  @VisibleForTesting
+  void index(List<Dto> authorizations) {
+    index(authorizations, authorizationScopes.stream());
   }
 
   @Override
@@ -141,37 +146,36 @@ public class PermissionIndexer implements ProjectIndexer, Startable, StartupInde
       .get());
   }
 
-  private void truncateAuthorizationType(IndexType indexType) {
-    BulkIndexer.delete(esClient, indexType.getIndex(), esClient.prepareSearch(indexType).setQuery(matchAllQuery()));
+  private Stream<AuthorizationScope> getScopes(Set<IndexType> indexTypes) {
+    return authorizationScopes.stream()
+      .filter(scope -> indexTypes.contains(scope.getIndexType()));
   }
 
-  @VisibleForTesting
-  void index(Collection<PermissionIndexerDao.Dto> authorizations) {
+  private void index(Collection<PermissionIndexerDao.Dto> authorizations, Stream<AuthorizationScope> scopes) {
     if (authorizations.isEmpty()) {
       return;
     }
-    int count = 0;
-    BulkRequestBuilder bulkRequest = esClient.prepareBulk().setRefresh(false);
-    for (PermissionIndexerDao.Dto dto : authorizations) {
-      for (AuthorizationScope scope : authorizationScopes) {
-        if (scope.getProjectPredicate().test(dto)) {
-          bulkRequest.add(newIndexRequest(dto, scope.getIndexType()));
-          count++;
-        }
-      }
-      if (count >= MAX_BATCH_SIZE) {
-        EsUtils.executeBulkRequest(bulkRequest, BULK_ERROR_MESSAGE);
-        bulkRequest = esClient.prepareBulk().setRefresh(false);
-        count = 0;
-      }
-    }
-    if (count > 0) {
-      EsUtils.executeBulkRequest(bulkRequest, BULK_ERROR_MESSAGE);
-    }
-    authorizationScopes.forEach(type -> esClient.prepareRefresh(type.getIndexType().getIndex()).get());
+
+    // index each authorization in each scope
+    scopes.forEach(scope -> index(authorizations, scope));
+  }
+
+  private void index(Collection<PermissionIndexerDao.Dto> authorizations, AuthorizationScope scope) {
+    IndexType indexType = scope.getIndexType();
+
+    BulkIndexer bulkIndexer = new BulkIndexer(esClient, indexType.getIndex());
+    bulkIndexer.setLarge(/* TODO */false);
+    bulkIndexer.start();
+
+    authorizations.stream()
+      .filter(scope.getProjectPredicate())
+      .map(dto -> newIndexRequest(dto, indexType))
+      .forEach(bulkIndexer::add);
+
+    bulkIndexer.stop();
   }
 
-  private static IndexRequest newIndexRequest(PermissionIndexerDao.Dto dto, IndexType indexTypeId) {
+  private static IndexRequest newIndexRequest(PermissionIndexerDao.Dto dto, IndexType indexType) {
     Map<String, Object> doc = new HashMap<>();
     doc.put(AuthorizationTypeSupport.FIELD_UPDATED_AT, DateUtils.longToDate(dto.getUpdatedAt()));
     if (dto.isAllowAnyone()) {
@@ -182,7 +186,7 @@ public class PermissionIndexer implements ProjectIndexer, Startable, StartupInde
       doc.put(AuthorizationTypeSupport.FIELD_GROUP_IDS, dto.getGroupIds());
       doc.put(AuthorizationTypeSupport.FIELD_USER_IDS, dto.getUserIds());
     }
-    return new IndexRequest(indexTypeId.getIndex(), indexTypeId.getType(), dto.getProjectUuid())
+    return new IndexRequest(indexType.getIndex(), indexType.getType(), dto.getProjectUuid())
       .routing(dto.getProjectUuid())
       .source(doc);
   }
index af3a4f7a120e5b1bd4a578ecad27da219f2b178e..f73b15f03c1a5cb9b84ef50ffef2b39469b692be 100644 (file)
@@ -75,7 +75,7 @@ public class TestIndexer implements ProjectIndexer, StartupIndexer {
   }
 
   @Override
-  public void indexOnStartup() {
+  public void indexOnStartup(Set<IndexType> emptyIndexTypes) {
     doIndex(null, Cause.NEW_ANALYSIS);
   }
 
index a2f7f720d1fc3c6715e309ac0b6c6c6e40479d5e..0589b99a1499b2be4dcc1ee5918ff953f2d9a56e 100644 (file)
@@ -50,7 +50,7 @@ public class UserIndexer implements StartupIndexer {
   }
 
   @Override
-  public void indexOnStartup() {
+  public void indexOnStartup(Set<IndexType> emptyIndexTypes) {
     doIndex(null);
   }
 
index 39581cc2e024140ab2ef704d1b64c8f26be9c261..db53112cdb01a095316a7920965b83830e30cf4d 100644 (file)
@@ -66,8 +66,8 @@ public class ComponentIndexerTest {
   public void index_on_startup() {
     ComponentIndexer indexer = spy(createIndexer());
     doNothing().when(indexer).index();
-    indexer.indexOnStartup();
-    verify(indexer).indexOnStartup();
+    indexer.indexOnStartup(null);
+    verify(indexer).indexOnStartup(null);
   }
 
   @Test
@@ -178,7 +178,7 @@ public class ComponentIndexerTest {
   }
 
   private void index() {
-    createIndexer().indexOnStartup();
+    createIndexer().indexOnStartup(null);
   }
 
   private void index(ComponentDto component) {
index 7eb714bd879f7ef8dd5a397a09760fcfbbafdf8f..0831417824a5a605dc80914dcb62eddf1be70375 100644 (file)
@@ -67,7 +67,7 @@ public class SuggestionsActionTest {
   public void exact_match_in_one_qualifier() {
     ComponentDto project = db.components().insertComponent(newProjectDto(organization));
 
-    componentIndexer.indexOnStartup();
+    componentIndexer.indexOnStartup(null);
     authorizationIndexerTester.allowOnlyAnyone(project);
 
     SuggestionsWsResponse response = action.doHandle(project.getKey());
index 1fc4ca64a29193d36a3bb04ba81731da50225e5f..1730f9933c70003fd83bf6a657308f051942e959 100644 (file)
@@ -22,6 +22,7 @@ package org.sonar.server.es;
 import com.google.common.collect.ImmutableSet;
 import org.junit.Rule;
 import org.junit.Test;
+import org.mockito.Mockito;
 import org.sonar.api.config.MapSettings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
@@ -60,7 +61,7 @@ public class IndexerStartupTaskTest {
     emulateStartup(indexer);
 
     verify(indexer).getIndexTypes();
-    verify(indexer).indexOnStartup();
+    verify(indexer).indexOnStartup(Mockito.eq(ImmutableSet.of(INDEX_TYPE_FAKE)));
   }
 
   private void insertDocumentIntoIndex() {
index fde781689c59594d237dc4437fd5be7eb1ca8aa2..f6fec3fb5f9f9f3d73db1df37ac7cf127c8c4e9e 100644 (file)
@@ -57,9 +57,9 @@ public class IssueIndexerTest {
   @Test
   public void index_on_startup() {
     IssueIndexer indexer = spy(underTest);
-    doNothing().when(indexer).indexOnStartup();
-    indexer.indexOnStartup();
-    verify(indexer).indexOnStartup();
+    doNothing().when(indexer).indexOnStartup(null);
+    indexer.indexOnStartup(null);
+    verify(indexer).indexOnStartup(null);
   }
 
   @Test
@@ -73,7 +73,7 @@ public class IssueIndexerTest {
   public void index_all_issues() {
     dbTester.prepareDbUnit(getClass(), "index.xml");
 
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     List<IssueDoc> docs = esTester.getDocuments(IssueIndexDefinition.INDEX_TYPE_ISSUE, IssueDoc.class);
     assertThat(docs).hasSize(1);
@@ -125,7 +125,7 @@ public class IssueIndexerTest {
   public void deleteProject_deletes_issues_of_a_specific_project() {
     dbTester.prepareDbUnit(getClass(), "index.xml");
 
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     assertThat(esTester.countDocuments("issues", "issue")).isEqualTo(1);
 
index b157ef3e2651eaf4accd0e4eb4b21eb956708b26..b2f8d88f76bf1dbc65f53bb1821a2a60931bbbab 100644 (file)
@@ -59,14 +59,14 @@ public class ProjectMeasuresIndexerTest {
   @Test
   public void index_on_startup() {
     ProjectMeasuresIndexer indexer = spy(underTest);
-    doNothing().when(indexer).indexOnStartup();
-    indexer.indexOnStartup();
-    verify(indexer).indexOnStartup();
+    doNothing().when(indexer).indexOnStartup(null);
+    indexer.indexOnStartup(null);
+    verify(indexer).indexOnStartup(null);
   }
 
   @Test
   public void index_nothing() {
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     assertThat(esTester.countDocuments(INDEX_TYPE_PROJECT_MEASURES)).isZero();
   }
@@ -78,7 +78,7 @@ public class ProjectMeasuresIndexerTest {
     componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto));
     componentDbTester.insertProjectAndSnapshot(newProjectDto(organizationDto));
 
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     assertThat(esTester.countDocuments(INDEX_TYPE_PROJECT_MEASURES)).isEqualTo(3);
   }
@@ -90,7 +90,7 @@ public class ProjectMeasuresIndexerTest {
   public void index_provisioned_projects() {
     ComponentDto project = componentDbTester.insertProject();
 
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     assertThat(esTester.getIds(INDEX_TYPE_PROJECT_MEASURES)).containsOnly(project.uuid());
   }
@@ -159,7 +159,7 @@ public class ProjectMeasuresIndexerTest {
     componentDbTester.insertProjectAndSnapshot(project2);
     ComponentDto project3 = newProjectDto(organizationDto);
     componentDbTester.insertProjectAndSnapshot(project3);
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     underTest.deleteProject(project1.uuid());
 
@@ -170,7 +170,7 @@ public class ProjectMeasuresIndexerTest {
   public void does_nothing_when_deleting_unknown_project() throws Exception {
     ComponentDto project = newProjectDto(dbTester.organizations().insert());
     componentDbTester.insertProjectAndSnapshot(project);
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     underTest.deleteProject("UNKNOWN");
 
index 9a6c0a78618f6316e77ccf8a382045dfaf3d7230..530654c754d55969d9efa90476e2a0cd0e47b184 100644 (file)
@@ -82,7 +82,7 @@ public class PermissionIndexerTest {
     userDbTester.insertProjectPermissionOnUser(user1, USER, project);
     userDbTester.insertProjectPermissionOnUser(user2, ADMIN, project);
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     // anonymous
     verifyAnyoneNotAuthorized(project);
@@ -105,7 +105,7 @@ public class PermissionIndexerTest {
     userDbTester.insertProjectPermissionOnGroup(group1, USER, project);
     userDbTester.insertProjectPermissionOnGroup(group2, ADMIN, project);
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     // anonymous
     verifyAnyoneNotAuthorized(project);
@@ -130,7 +130,7 @@ public class PermissionIndexerTest {
     userDbTester.insertProjectPermissionOnUser(user1, USER, project);
     userDbTester.insertProjectPermissionOnGroup(group, USER, project);
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     // anonymous
     verifyAnyoneNotAuthorized(project);
@@ -151,7 +151,7 @@ public class PermissionIndexerTest {
     UserDto user = userDbTester.insertUser();
     GroupDto group = userDbTester.insertGroup();
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     verifyAnyoneNotAuthorized(project);
     verifyNotAuthorized(project, user);
@@ -165,7 +165,7 @@ public class PermissionIndexerTest {
     GroupDto group = userDbTester.insertGroup();
     userDbTester.insertProjectPermissionOnAnyone(USER, project);
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     verifyAnyoneAuthorized(project);
     verifyAuthorized(project, user);
@@ -182,7 +182,7 @@ public class PermissionIndexerTest {
       userDbTester.insertProjectPermissionOnUser(user1, USER, project);
     }
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     verifyAnyoneNotAuthorized(project);
     verifyAuthorized(project, user1);
@@ -195,7 +195,7 @@ public class PermissionIndexerTest {
     ComponentDto project2 = createAndIndexProject();
     userDbTester.insertProjectPermissionOnAnyone(USER, project1);
     userDbTester.insertProjectPermissionOnAnyone(USER, project2);
-    underTest.indexOnStartup();
+    indexOnStartup();
     assertThat(esTester.countDocuments(INDEX_TYPE_FOO_AUTH)).isEqualTo(2);
 
     underTest.deleteProject(project1.uuid());
@@ -219,7 +219,7 @@ public class PermissionIndexerTest {
     ComponentDto project = createAndIndexProject();
     UserDto user1 = userDbTester.insertUser();
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     verifyAnyoneNotAuthorized(project);
     verifyNotAuthorized(project, user1);
@@ -233,7 +233,7 @@ public class PermissionIndexerTest {
     userDbTester.insertProjectPermissionOnAnyone(USER, projectOnOrg1);
     userDbTester.insertProjectPermissionOnUser(user, USER, projectOnOrg2);
 
-    underTest.indexOnStartup();
+    indexOnStartup();
 
     verifyAnyoneAuthorized(projectOnOrg1);
     verifyAnyoneNotAuthorized(projectOnOrg2);
@@ -241,6 +241,10 @@ public class PermissionIndexerTest {
     verifyAuthorized(projectOnOrg2, user);
   }
 
+  private void indexOnStartup() {
+    underTest.indexOnStartup(underTest.getIndexTypes());
+  }
+
   private void verifyAuthorized(ComponentDto project, UserDto user) {
     log_in(user);
     verifyAuthorized(project, true);
index 6494036f53b6a30bf49a2a6c7b4f04f57e836a74..341bb2e0125b712c0722f9b1cca9cf0717b276d1 100644 (file)
@@ -72,9 +72,9 @@ public class TestIndexerTest {
   @Test
   public void index_on_startup() {
     TestIndexer indexer = spy(underTest);
-    doNothing().when(indexer).indexOnStartup();
-    indexer.indexOnStartup();
-    verify(indexer).indexOnStartup();
+    doNothing().when(indexer).indexOnStartup(null);
+    indexer.indexOnStartup(null);
+    verify(indexer).indexOnStartup(null);
   }
 
   @Test
@@ -82,7 +82,7 @@ public class TestIndexerTest {
     db.prepareDbUnit(getClass(), "db.xml");
     TestTesting.updateDataColumn(db.getSession(), "FILE_UUID", TestTesting.newRandomTests(3));
 
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     assertThat(countDocuments()).isEqualTo(3);
   }
index f4a10f644763a783cbaea990103af10bdc32c9a3..4d2b0cdfa351fb7d93db4f2f97844def3c2fa895 100644 (file)
@@ -285,7 +285,7 @@ public class ListActionTest {
       .setFileUuid(testFile.uuid())
       .setTestData(asList(tests)));
     db.commit();
-    testIndexer.indexOnStartup();
+    testIndexer.indexOnStartup(null);
   }
 
   private static ListResponse call(TestRequest request) {
index 2def2c6e9cf4fdebeedab9d2409b032d3b828519..a293caee01dffef628a7fc007bb50ecd018ef148 100644 (file)
@@ -43,7 +43,7 @@ public class UserIndexerTest {
   @Test
   public void index_nothing() {
     UserIndexer indexer = createIndexer();
-    indexer.indexOnStartup();
+    indexer.indexOnStartup(null);
     assertThat(esTester.countDocuments(UserIndexDefinition.INDEX_TYPE_USER)).isEqualTo(0L);
   }
 
@@ -52,7 +52,7 @@ public class UserIndexerTest {
     dbTester.prepareDbUnit(getClass(), "index.xml");
 
     UserIndexer indexer = createIndexer();
-    indexer.indexOnStartup();
+    indexer.indexOnStartup(null);
 
     List<UserDoc> docs = esTester.getDocuments(UserIndexDefinition.INDEX_TYPE_USER, UserDoc.class);
     assertThat(docs).hasSize(1);
@@ -71,7 +71,7 @@ public class UserIndexerTest {
     UserDto user = dbTester.users().insertUser();
 
     UserIndexer indexer = createIndexer();
-    indexer.indexOnStartup();
+    indexer.indexOnStartup(null);
 
     List<UserDoc> docs = esTester.getDocuments(UserIndexDefinition.INDEX_TYPE_USER, UserDoc.class);
     assertThat(docs).hasSize(1);
index ba5c57555476fd7feb1a368795476ab811dd7c0f..cf5dc37bec4806dd849c8797484c8eb49a663039 100644 (file)
@@ -92,7 +92,7 @@ public class SearchActionTest {
     }
     dbClient.userTokenDao().insert(dbSession, newUserToken().setLogin(fmallet.getLogin()));
     db.commit();
-    userIndexer.indexOnStartup();
+    userIndexer.indexOnStartup(null);
     loginAsSystemAdministrator();
 
     String response = ws.newGetRequest("api/users", "search").execute().outputAsString();
@@ -213,7 +213,7 @@ public class SearchActionTest {
 
     dbClient.userDao().insert(dbSession, UserTesting.newUserDto("john", "John", "john@email.com"));
     dbSession.commit();
-    userIndexer.indexOnStartup();
+    userIndexer.indexOnStartup(null);
 
     ws.newGetRequest("api/users", "search").execute().assertJson(
       "{" +
@@ -255,7 +255,7 @@ public class SearchActionTest {
       }
     }
     dbSession.commit();
-    userIndexer.indexOnStartup();
+    userIndexer.indexOnStartup(null);
     return userDtos;
   }
 
index 1760758594dda45f01d3bcbabfc4ed7878548f86..5af146d43c022a66a3599ad05b989a088d95bb84 100644 (file)
@@ -75,7 +75,7 @@ public class ViewIndexerTest {
 
   @Test
   public void index_nothing() {
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
     assertThat(esTester.countDocuments(ViewIndexDefinition.INDEX_TYPE_VIEW)).isEqualTo(0L);
   }
 
@@ -83,7 +83,7 @@ public class ViewIndexerTest {
   public void index() {
     dbTester.prepareDbUnit(getClass(), "index.xml");
 
-    underTest.indexOnStartup();
+    underTest.indexOnStartup(null);
 
     List<ViewDoc> docs = esTester.getDocuments(ViewIndexDefinition.INDEX_TYPE_VIEW, ViewDoc.class);
     assertThat(docs).hasSize(4);