@After public void tearDown() { if (underTest != null) { underTest.stop(); } }
@Test public void display_default_configuration_at_startup() { underTest = newRecoveryIndexer(emptySettings.asConfig()); underTest.start(); underTest.stop(); assertThat(logTester.logs(LoggerLevel.DEBUG)).contains( "Elasticsearch recovery - sonar.search.recovery.delayInMs=300000", "Elasticsearch recovery - sonar.search.recovery.minAgeInMs=300000"); }
@Test public void soft_failures_are_logged_and_do_not_stop_recovery_scheduling() throws Exception { insertItem(FOO_TYPE, "f1"); SoftFailingFakeIndexer indexer = new SoftFailingFakeIndexer(FOO_TYPE); advanceInTime(); underTest = newRecoveryIndexer(indexer); underTest.start(); // all runs fail, but they are still scheduled // -> waiting for 2 runs while (indexer.called.size() < 2) { Thread.sleep(1L); } underTest.stop(); // No rows treated assertThatQueueHasSize(1); assertThatLogsContain(INFO, "Elasticsearch recovery - 1 documents processed [1 failures]"); }
@Test public void hard_failures_are_logged_and_do_not_stop_recovery_scheduling() throws Exception { insertItem(FOO_TYPE, "f1"); HardFailingFakeIndexer indexer = new HardFailingFakeIndexer(FOO_TYPE); advanceInTime(); underTest = newRecoveryIndexer(indexer); underTest.start(); // all runs fail, but they are still scheduled // -> waiting for 2 runs while (indexer.called.size() < 2) { Thread.sleep(1L); } underTest.stop(); // No rows treated assertThatQueueHasSize(1); assertThatLogsContain(ERROR, "Elasticsearch recovery - fail to recover documents"); }