### Question:
IndexerForSearchSelector { protected boolean checkLoadLimiting(Indexer indexer) { boolean preventedByLoadLimiting = indexer.getConfig().getLoadLimitOnRandom().isPresent() && random.nextInt(indexer.getConfig().getLoadLimitOnRandom().get()) + 1 != 1; if (preventedByLoadLimiting) { boolean loadLimitIgnored = configProvider.getBaseConfig().getSearching().isIgnoreLoadLimitingForInternalSearches() && searchRequest.getSource() == SearchSource.INTERNAL; if (loadLimitIgnored) { logger.debug("Ignoring load limiting for internal search"); return true; } String message = String.format("Not using %s because load limiting prevented it. Chances of it being picked: 1/%d", indexer.getName(), indexer.getConfig().getLoadLimitOnRandom().get()); return handleIndexerNotSelected(indexer, message, "Load limiting"); } return true; }  IndexerForSearchSelection pickIndexers(SearchRequest searchRequest); static final Pattern SCHEDULER_PATTERN; }### Answer:
@Test public void shouldCheckForLoadLimiting() { indexerConfigMock.setLoadLimitOnRandom(null); assertTrue(testee.checkLoadLimiting(indexer)); indexerConfigMock.setLoadLimitOnRandom(1); for (int i = 0; i < 50; i++) { assertTrue(testee.checkLoadLimiting(indexer)); } indexerConfigMock.setLoadLimitOnRandom(2); int countNotPicked = 0; for (int i = 0; i < 500; i++) { countNotPicked += testee.checkLoadLimiting(indexer) ? 0 : 1; } assertTrue(countNotPicked > 0); }