protected void assertStorageLocationUnchangedAfterRestart() throws Exception { // register the total size and last modified timestamp of the place where indexes are stored for the default provider.. File indexesDir = new File("target/persistent_repository/indexes/local"); assertTrue(indexesDir.exists() && indexesDir.isDirectory() && indexesDir.canRead()); long size = FileUtil.size(indexesDir.getPath()); final AtomicLong lastModifiedDate = lastModifiedFileTime(indexesDir, ".*\\.db"); startRepository(); printMessage("Repository restart complete"); // and now check that the storage folder is unchanged assertTrue(indexesDir.exists() && indexesDir.isDirectory() && indexesDir.canRead()); assertEquals(size, FileUtil.size(indexesDir.getPath())); assertEquals(lastModifiedDate.get(), lastModifiedFileTime(indexesDir, ".*\\.db").get()); }
@Test @FixFor( "MODE-2391" ) public void shouldNotReindexBetweenRestartsLocalProviderIfExists() throws Exception { // clean the indexes TestingUtil.waitUntilFolderCleanedUp("target/startup_test_indexes"); startRunStop(repository -> { long initialSize = FileUtil.size("target/startup_test_indexes"); JcrSession session = repository.login(); int nodeCount = 100; for (int i = 0; i < nodeCount; i++) { session.getRootNode().addNode("node_" + i); } session.save(); session.logout(); // the indexes are sync, so the FS size should've increased because of the new nodes assertTrue(initialSize < FileUtil.size("target/startup_test_indexes")); }, "config/repo-config-persistent-local-indexes.json"); long indexFolderSize = FileUtil.size("target/startup_test_indexes"); assertTrue(indexFolderSize > 0); startRunStop(repository -> { // wait a bit so that if reindexing was happening it would be finished before shutting down Thread.sleep(200); repository.login().logout(); }, "config/repo-config-persistent-local-indexes.json"); // if reindexing was happening, it would be async so the next assert would normally fail assertEquals("Re-indexing should not be happening", indexFolderSize, FileUtil.size("target/startup_test_indexes")); }
@Test @FixFor( "MODE-2341" ) public void shouldAllowReindexingWithLocalProviderBetweenRestartsWhenMissing() throws Exception { // clean the indexes TestingUtil.waitUntilFolderCleanedUp("target/startup_test_indexes"); // setup the external content prepareExternalDirectory("target/federation_persistent_2"); RepositoryOperation reindexingExternalContentOperation = reindexingExternalContentOperation(); // run 1 startRunStop(reindexingExternalContentOperation, "config/repo-config-persistent-cache-fs-connector2.json"); long indexFolderSize1 = FileUtil.size("target/startup_test_indexes"); // clean the indexes TestingUtil.waitUntilFolderCleanedUp("target/startup_test_indexes"); // run 2 startRunStop(reindexingExternalContentOperation, "config/repo-config-persistent-cache-fs-connector2.json"); long indexFolderSize2 = FileUtil.size("target/startup_test_indexes"); assertEquals("The sizes of the index folder are different between 2 identical reindex runs", indexFolderSize1, indexFolderSize2); }