@Test public void basics() throws Exception{ handler.setClock(clock); handler.indexUpdateFailed("async", "/oak:index/foo", new Exception()); //Index would not be considered corrupt until timeout assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); clock.waitUntil(clock.getTime() + handler.getCorruptIntervalMillis() + 1); assertTrue(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); //Should only be visible for "async" assertFalse(handler.getCorruptIndexData("async-fulltext").containsKey("/oak:index/foo")); handler.markWorkingIndexes(Collections.singleton("/oak:index/foo")); assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); }
@Test public void disbaled() throws Exception{ handler.setClock(clock); handler.indexUpdateFailed("async", "/oak:index/foo", new Exception()); clock.waitUntil(clock.getTime() + handler.getCorruptIntervalMillis() + 1); assertTrue(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); handler.setCorruptInterval(0, TimeUnit.SECONDS); //With timeout set to zero no corrupt index should be reported assertFalse(handler.getCorruptIndexData("async").containsKey("/oak:index/foo")); }
@Test public void corruptIndexTimeout() throws Exception{ injectDefaultServices(); Map<String,Object> config = ImmutableMap.<String, Object>of( "asyncConfigs", new String[] {"async:5"}, "failingIndexTimeoutSeconds" , "43", "errorWarnIntervalSeconds" , "53" ); MockOsgi.activate(service, context.bundleContext(), config); AsyncIndexUpdate indexUpdate = getIndexUpdate("async"); assertEquals(TimeUnit.SECONDS.toMillis(43), indexUpdate.getCorruptIndexHandler().getCorruptIntervalMillis()); assertEquals(TimeUnit.SECONDS.toMillis(53), indexUpdate.getCorruptIndexHandler().getErrorWarnIntervalMillis()); }
clock.waitUntil(clock.getTime() + async.getCorruptIndexHandler().getCorruptIntervalMillis() + 1);