Search in sources :

Example 1 with CacheCommands

use of org.apache.ignite.internal.commandline.cache.CacheCommands in project ignite by apache.

the class CommandHandlerParsingTest method testFindAndDeleteGarbage.

/**
 */
@Test
public void testFindAndDeleteGarbage() {
    String nodeId = UUID.randomUUID().toString();
    String delete = FindAndDeleteGarbageArg.DELETE.toString();
    String groups = "group1,grpoup2,group3";
    List<List<String>> lists = generateArgumentList(FIND_AND_DELETE_GARBAGE.text(), new T2<>(nodeId, false), new T2<>(delete, false), new T2<>(groups, false));
    for (List<String> list : lists) {
        ConnectionAndSslParameters args = parseArgs(list);
        assertTrue(args.command() instanceof CacheCommands);
        CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
        FindAndDeleteGarbage.Arguments arg = (FindAndDeleteGarbage.Arguments) subcommand.subcommand().arg();
        if (list.contains(nodeId))
            assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId().toString());
        else
            assertNull(arg.nodeId());
        assertEquals(list.contains(delete), arg.delete());
        if (list.contains(groups))
            assertEquals(3, arg.groups().size());
        else
            assertNull(arg.groups());
    }
}
Also used : CacheSubcommands(org.apache.ignite.internal.commandline.cache.CacheSubcommands) BaselineArguments(org.apache.ignite.internal.commandline.baseline.BaselineArguments) Collections.singletonList(java.util.Collections.singletonList) Arrays.asList(java.util.Arrays.asList) List(java.util.List) ArrayList(java.util.ArrayList) CacheCommands(org.apache.ignite.internal.commandline.cache.CacheCommands) FindAndDeleteGarbage(org.apache.ignite.internal.commandline.cache.FindAndDeleteGarbage) Test(org.junit.Test)

Example 2 with CacheCommands

use of org.apache.ignite.internal.commandline.cache.CacheCommands in project ignite by apache.

the class CommandHandlerParsingTest method testValidateIndexArguments.

/**
 * validate_indexes command arguments parsing and validation
 */
@Test
public void testValidateIndexArguments() {
    // happy case for all parameters
    try {
        int expectedCheckFirst = 10;
        int expectedCheckThrough = 11;
        UUID nodeId = UUID.randomUUID();
        ConnectionAndSslParameters args = parseArgs(asList(CACHE.text(), VALIDATE_INDEXES.text(), "cache1, cache2", nodeId.toString(), CHECK_FIRST.toString(), Integer.toString(expectedCheckFirst), CHECK_THROUGH.toString(), Integer.toString(expectedCheckThrough)));
        assertTrue(args.command() instanceof CacheCommands);
        CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
        CacheValidateIndexes.Arguments arg = (CacheValidateIndexes.Arguments) subcommand.subcommand().arg();
        assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId());
        assertEquals("checkFirst parameter unexpected value", expectedCheckFirst, arg.checkFirst());
        assertEquals("checkThrough parameter unexpected value", expectedCheckThrough, arg.checkThrough());
    } catch (IllegalArgumentException e) {
        fail("Unexpected exception: " + e);
    }
    try {
        int expectedParam = 11;
        UUID nodeId = UUID.randomUUID();
        ConnectionAndSslParameters args = parseArgs(asList(CACHE.text(), VALIDATE_INDEXES.text(), nodeId.toString(), CHECK_THROUGH.toString(), Integer.toString(expectedParam)));
        assertTrue(args.command() instanceof CacheCommands);
        CacheSubcommands subcommand = ((CacheCommands) args.command()).arg();
        CacheValidateIndexes.Arguments arg = (CacheValidateIndexes.Arguments) subcommand.subcommand().arg();
        assertNull("caches weren't specified, null value expected", arg.caches());
        assertEquals("nodeId parameter unexpected value", nodeId, arg.nodeId());
        assertEquals("checkFirst parameter unexpected value", -1, arg.checkFirst());
        assertEquals("checkThrough parameter unexpected value", expectedParam, arg.checkThrough());
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
    assertParseArgsThrows("Value for '--check-first' property should be positive.", CACHE.text(), VALIDATE_INDEXES.text(), CHECK_FIRST.toString(), "0");
    assertParseArgsThrows("Numeric value for '--check-through' parameter expected.", CACHE.text(), VALIDATE_INDEXES.text(), CHECK_THROUGH.toString());
}
Also used : CacheSubcommands(org.apache.ignite.internal.commandline.cache.CacheSubcommands) BaselineArguments(org.apache.ignite.internal.commandline.baseline.BaselineArguments) CacheCommands(org.apache.ignite.internal.commandline.cache.CacheCommands) UUID(java.util.UUID) CacheValidateIndexes(org.apache.ignite.internal.commandline.cache.CacheValidateIndexes) Test(org.junit.Test)

Aggregations

BaselineArguments (org.apache.ignite.internal.commandline.baseline.BaselineArguments)2 CacheCommands (org.apache.ignite.internal.commandline.cache.CacheCommands)2 CacheSubcommands (org.apache.ignite.internal.commandline.cache.CacheSubcommands)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 UUID (java.util.UUID)1 CacheValidateIndexes (org.apache.ignite.internal.commandline.cache.CacheValidateIndexes)1 FindAndDeleteGarbage (org.apache.ignite.internal.commandline.cache.FindAndDeleteGarbage)1