Source:
private TestStatsLogger startAuditorAndWaitForReplicasCheck(ServerConfiguration servConf, MutableObject<Auditor> auditorRef, MultiKeyMap<String, AvailabilityOfEntriesOfLedger> expectedReturnAvailabilityOfEntriesOfLedger, MultiKeyMap<String, Integer> errorReturnValueForGetAvailabilityOfEntriesOfLedger) throws MetadataException, CompatibilityException, KeeperException, InterruptedException, UnavailableException, UnknownHostException { LedgerManagerFactory mFactory = driver.getLedgerManagerFactory(); LedgerUnderreplicationManager urm = mFactory.newLedgerUnderreplicationManager(); TestStatsProvider statsProvider = new TestStatsProvider(); TestStatsLogger statsLogger = statsProvider.getStatsLogger(AUDITOR_SCOPE); TestOpStatsLogger replicasCheckStatsLogger = (TestOpStatsLogger) statsLogger .getOpStatsLogger(ReplicationStats.REPLICAS_CHECK_TIME); final TestAuditor auditor = new TestAuditor(Bookie.getBookieAddress(servConf).toString(), servConf, bkc, true, new TestBookKeeperAdmin(bkc, statsLogger, expectedReturnAvailabilityOfEntriesOfLedger, errorReturnValueForGetAvailabilityOfEntriesOfLedger), true, statsLogger); auditorRef.setValue(auditor); CountDownLatch latch = auditor.getLatch(); assertEquals("REPLICAS_CHECK_TIME SuccessCount", 0, replicasCheckStatsLogger.getSuccessCount()); urm.setReplicasCheckCTime(-1); auditor.start(); assertTrue("replicasCheck should have executed", latch.await(20, TimeUnit.SECONDS)); for (int i = 0; i < 20; i++) { Thread.sleep(100); if (replicasCheckStatsLogger.getSuccessCount() >= 1) { break; } } assertEquals("REPLICAS_CHECK_TIME SuccessCount", 1, replicasCheckStatsLogger.getSuccessCount()); return statsLogger; }

Target:
private TestStatsLogger startAuditorAndWaitForReplicasCheck(ServerConfiguration servConf, MutableObject<Auditor> auditorRef, MultiKeyMap<String, AvailabilityOfEntriesOfLedger> expectedReturnAvailabilityOfEntriesOfLedger, MultiKeyMap<String, Integer> errorReturnValueForGetAvailabilityOfEntriesOfLedger) throws MetadataException, CompatibilityException, KeeperException, InterruptedException, UnavailableException, UnknownHostException { LedgerManagerFactory mFactory = driver.getLedgerManagerFactory(); LedgerUnderreplicationManager urm = mFactory.newLedgerUnderreplicationManager(); TestStatsProvider statsProvider = new TestStatsProvider(); TestStatsLogger statsLogger = statsProvider.getStatsLogger(AUDITOR_SCOPE); TestOpStatsLogger replicasCheckStatsLogger = (TestOpStatsLogger) statsLogger .getOpStatsLogger(ReplicationStats.REPLICAS_CHECK_TIME); final TestAuditor auditor = new TestAuditor(Bookie.getBookieAddress(servConf).toString(), servConf, bkc, true, new TestBookKeeperAdmin(bkc, statsLogger, expectedReturnAvailabilityOfEntriesOfLedger, errorReturnValueForGetAvailabilityOfEntriesOfLedger), true, statsLogger); auditorRef.setValue(auditor); CountDownLatch latch = auditor.getLatch(); assertEquals("REPLICAS_CHECK_TIME SuccessCount", 0, replicasCheckStatsLogger.getSuccessCount()); urm.setReplicasCheckCTime(-1); auditor.start(); assertTrue("replicasCheck should have executed", latch.await(20, TimeUnit.SECONDS)); for (int i = 0; i < 200; i++) { Thread.sleep(100); if (replicasCheckStatsLogger.getSuccessCount() >= 1) { break; } } assertEquals("REPLICAS_CHECK_TIME SuccessCount", 1, replicasCheckStatsLogger.getSuccessCount()); return statsLogger; }