Search in sources :

Example 1 with CACHE_NAME

use of org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME in project ignite by apache.

the class GridCommandHandlerIndexListTest method testCacheIndexList.

/**
 * Tests --index name option and output correctness.
 */
@Test
public void testCacheIndexList() {
    final String idxName = "PERSON_ORGID_ASC_IDX";
    final int expectedLinesNum = 15;
    final int expectedIndexDescrLinesNum = 2;
    injectTestSystemOut();
    final CommandHandler handler = new CommandHandler(createTestLogger());
    assertEquals(EXIT_CODE_OK, execute(handler, "--cache", "indexes_list", "--index-name", idxName));
    String outStr = testOut.toString();
    assertTrue(outStr.contains("grpName=" + GROUP_NAME + ", cacheName=" + CACHE_NAME + ", idxName=PERSON_ORGID_ASC_IDX, " + "colsNames=ArrayList [ORGID, _KEY], tblName=PERSON"));
    assertTrue(outStr.contains("grpName=" + GROUP_NAME_SECOND + ", cacheName=" + CACHE_NAME_SECOND + ", idxName=PERSON_ORGID_ASC_IDX, colsNames=ArrayList [ORGID, _KEY], tblName=PERSON"));
    final String[] outputLines = outStr.split("\n");
    int outputLinesNum = outputLines.length;
    assertEquals("Unexpected number of lines: " + outputLinesNum, outputLinesNum, expectedLinesNum);
    long indexDescrLinesNum = Arrays.stream(outputLines).filter(s -> s.contains("grpName=")).count();
    assertEquals("Unexpected number of index description lines: " + indexDescrLinesNum, indexDescrLinesNum, expectedIndexDescrLinesNum);
    Set<IndexListInfoContainer> cmdResult = handler.getLastOperationResult();
    assertNotNull(cmdResult);
    final int resSetSize = cmdResult.size();
    assertEquals("Unexpected result set size: " + resSetSize, resSetSize, 2);
    boolean isResSetCorrect = cmdResult.stream().map(IndexListInfoContainer::indexName).allMatch((name) -> name.equals(idxName));
    assertTrue("Unexpected result set", isResSetCorrect);
}
Also used : Arrays(java.util.Arrays) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) Predicate(java.util.function.Predicate) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) CACHE_NAME_SECOND(org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME_SECOND) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) GROUP_NAME_SECOND(org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME_SECOND) CacheCommands(org.apache.ignite.internal.commandline.cache.CacheCommands) CACHE_NAME(org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME) THREE_ENTRIES_CACHE_NAME_COMMON_PART(org.apache.ignite.util.GridCommandHandlerIndexingUtils.THREE_ENTRIES_CACHE_NAME_COMMON_PART) GridCommandHandlerIndexingUtils.createAndFillSeveralCaches(org.apache.ignite.util.GridCommandHandlerIndexingUtils.createAndFillSeveralCaches) IgniteDataStreamer(org.apache.ignite.IgniteDataStreamer) GROUP_NAME(org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer) CommandHandler(org.apache.ignite.internal.commandline.CommandHandler) IndexListInfoContainer(org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer) Test(org.junit.Test)

Aggregations

Arrays (java.util.Arrays)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Ignite (org.apache.ignite.Ignite)1 IgniteDataStreamer (org.apache.ignite.IgniteDataStreamer)1 IgniteEx (org.apache.ignite.internal.IgniteEx)1 CommandHandler (org.apache.ignite.internal.commandline.CommandHandler)1 EXIT_CODE_OK (org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK)1 CacheCommands (org.apache.ignite.internal.commandline.cache.CacheCommands)1 IndexListInfoContainer (org.apache.ignite.internal.visor.cache.index.IndexListInfoContainer)1 CACHE_NAME (org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME)1 CACHE_NAME_SECOND (org.apache.ignite.util.GridCommandHandlerIndexingUtils.CACHE_NAME_SECOND)1 GROUP_NAME (org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME)1 GROUP_NAME_SECOND (org.apache.ignite.util.GridCommandHandlerIndexingUtils.GROUP_NAME_SECOND)1 THREE_ENTRIES_CACHE_NAME_COMMON_PART (org.apache.ignite.util.GridCommandHandlerIndexingUtils.THREE_ENTRIES_CACHE_NAME_COMMON_PART)1 GridCommandHandlerIndexingUtils.createAndFillSeveralCaches (org.apache.ignite.util.GridCommandHandlerIndexingUtils.createAndFillSeveralCaches)1 Test (org.junit.Test)1