use of org.apache.ignite.internal.commandline.CommandList.CACHE in project ignite by apache.
the class GridCommandHandlerIndexingCheckSizeTest method validateCheckSizes.
/**
* Checking whether cache and index size check is correct.
*
* @param node Node.
* @param cacheName Cache name.
* @param rmvByTbl Number of deleted items per table.
* @param cacheSizeExp Function for getting expected cache size.
* @param idxSizeExp Function for getting expected index size.
*/
private void validateCheckSizes(IgniteEx node, String cacheName, Map<String, AtomicInteger> rmvByTbl, Function<AtomicInteger, Integer> cacheSizeExp, Function<AtomicInteger, Integer> idxSizeExp) {
requireNonNull(node);
requireNonNull(cacheName);
requireNonNull(rmvByTbl);
requireNonNull(cacheSizeExp);
requireNonNull(idxSizeExp);
injectTestSystemOut();
assertEquals(EXIT_CODE_OK, execute(CACHE.text(), VALIDATE_INDEXES.text(), cacheName, CHECK_SIZES.argName()));
String out = testOut.toString();
assertContains(log, out, "issues found (listed above)");
assertContains(log, out, "Size check");
Map<String, ValidateIndexesCheckSizeResult> valIdxCheckSizeResults = ((VisorValidateIndexesTaskResult) lastOperationResult).results().get(node.localNode().id()).checkSizeResult();
assertEquals(rmvByTbl.size(), valIdxCheckSizeResults.size());
for (Map.Entry<String, AtomicInteger> rmvByTblEntry : rmvByTbl.entrySet()) {
ValidateIndexesCheckSizeResult checkSizeRes = valIdxCheckSizeResults.entrySet().stream().filter(e -> e.getKey().contains(rmvByTblEntry.getKey())).map(Map.Entry::getValue).findAny().orElse(null);
assertNotNull(checkSizeRes);
assertEquals((int) cacheSizeExp.apply(rmvByTblEntry.getValue()), checkSizeRes.cacheSize());
Collection<ValidateIndexesCheckSizeIssue> issues = checkSizeRes.issues();
assertFalse(issues.isEmpty());
issues.forEach(issue -> {
assertEquals((int) idxSizeExp.apply(rmvByTblEntry.getValue()), issue.indexSize());
Throwable err = issue.error();
assertNotNull(err);
assertEquals("Cache and index size not same.", err.getMessage());
});
}
}
Aggregations