Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public enum CommandList {
METADATA("--meta", new MetadataCommand()),

/** */
SHUTDOWN_POLICY("--shutdown-policy", new ShutdownPolicyCommand());
SHUTDOWN_POLICY("--shutdown-policy", new ShutdownPolicyCommand()),

/** */
TRACING_CONFIGURATION("--tracing-configuration", new TracingConfigurationCommand());

/** Private values copy so there's no need in cloning it every time. */
private static final CommandList[] VALUES = CommandList.values();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.ignite.internal.commandline;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
Expand All @@ -32,6 +33,7 @@
import org.apache.ignite.internal.commandline.cache.CacheValidateIndexes;
import org.apache.ignite.internal.commandline.cache.FindAndDeleteGarbage;
import org.apache.ignite.internal.commandline.cache.argument.FindAndDeleteGarbageArg;
import org.apache.ignite.spi.tracing.Scope;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.visor.tx.VisorTxOperation;
import org.apache.ignite.internal.visor.tx.VisorTxProjection;
Expand Down Expand Up @@ -594,6 +596,195 @@ public void testKillArguments() {
"--kill", "continuous", UUID.randomUUID().toString(), "not_a_uuid");
}

/**
* Negative argument validation test for tracing-configuration command.
*
* validate that following tracing-configuration arguments validated as expected:
* <ul>
* <li>
* reset_all, get_all
* <ul>
* <li>
* --scope
* <ul>
* <li>
* if value is missing:
* IllegalArgumentException (The scope should be specified. The following values can be used: [DISCOVERY, EXCHANGE, COMMUNICATION, TX].")
* </li>
* <li>
* if unsupported value is used:
* IllegalArgumentException (Invalid scope 'aaa'. The following values can be used: [DISCOVERY, EXCHANGE, COMMUNICATION, TX])
* </li>
* </ul>
* </li>
* </ul>
* </li>
* <li>
* reset, get:
* <ul>
* <li>
* --scope
* <ul>
* <li>
* if value is missing:
* IllegalArgumentException (The scope should be specified. The following values can be used: [DISCOVERY, EXCHANGE, COMMUNICATION, TX].")
* </li>
* <li>
* if unsupported value is used:
* IllegalArgumentException (Invalid scope 'aaa'. The following values can be used: [DISCOVERY, EXCHANGE, COMMUNICATION, TX])
* </li>
* </ul>
* </li>
* <li>
* --label
* <ul>
* <li>
* if value is missing:
* IllegalArgumentException (The label should be specified.)
* </li>
* </ul>
* </li>
* </ul>
* </li>
* <li>
* set:
* <ul>
* <li>
* --scope
* <ul>
* <li>
* if value is missing:
* IllegalArgumentException (The scope should be specified. The following values can be used: [DISCOVERY, EXCHANGE, COMMUNICATION, TX].")
* </li>
* <li>
* if unsupported value is used:
* IllegalArgumentException (Invalid scope 'aaa'. The following values can be used: [DISCOVERY, EXCHANGE, COMMUNICATION, TX])
* </li>
* </ul>
* </li>
* <li>
* --label
* <ul>
* <li>
* if value is missing:
* IllegalArgumentException (The label should be specified.)
* </li>
* </ul>
* </li>
* <li>
* --sampling-rate
* <ul>
* <li>
* if value is missing:
* IllegalArgumentException (The sampling-rate should be specified. Decimal value between 0 and 1 should be used.)
* </li>
* <li>
* if unsupported value is used:
* IllegalArgumentException (Invalid samling-rate 'aaa'. Decimal value between 0 and 1 should be used.)
* </li>
* </ul>
* </li>
* <li>
* --included-scopes
* <ul>
* <li>
* if value is missing:
* IllegalArgumentException (At least one supported scope should be specified.)
* </li>
* <li>
* if unsupported value is used:
* IllegalArgumentException (Invalid supported scope: aaa. The following values can be used: [DISCOVERY, EXCHANGE, COMMUNICATION, TX].)
* </li>
* </ul>
* </li>
* </ul>
* </li>
* </ul>
*/
@Test
public void testTracingConfigurationArgumentsValidation() {
// reset
assertParseArgsThrows("The scope should be specified. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "reset", "--scope");

assertParseArgsThrows("Invalid scope 'aaa'. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "reset", "--scope", "aaa");

assertParseArgsThrows("The label should be specified.",
"--tracing-configuration", "reset", "--label");

// reset all
assertParseArgsThrows("The scope should be specified. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "reset_all", "--scope");

assertParseArgsThrows("Invalid scope 'aaa'. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "reset_all", "--scope", "aaa");

// get
assertParseArgsThrows("The scope should be specified. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "get", "--scope");

assertParseArgsThrows("Invalid scope 'aaa'. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "get", "--scope", "aaa");

assertParseArgsThrows("The label should be specified.",
"--tracing-configuration", "get", "--label");

// get all
assertParseArgsThrows("The scope should be specified. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "get_all", "--scope");

assertParseArgsThrows("Invalid scope 'aaa'. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "get_all", "--scope", "aaa");

// set
assertParseArgsThrows("The scope should be specified. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "set", "--scope");

assertParseArgsThrows("Invalid scope 'aaa'. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "set", "--scope", "aaa");

assertParseArgsThrows("The label should be specified.",
"--tracing-configuration", "set", "--label");

assertParseArgsThrows("The sampling rate should be specified. Decimal value between 0 and 1 should be used.",
"--tracing-configuration", "set", "--sampling-rate");

assertParseArgsThrows("Invalid sampling-rate 'aaa'. Decimal value between 0 and 1 should be used.",
"--tracing-configuration", "set", "--sampling-rate", "aaa");

assertParseArgsThrows("Invalid sampling-rate '-1'. Decimal value between 0 and 1 should be used.",
"--tracing-configuration", "set", "--sampling-rate", "-1");

assertParseArgsThrows("Invalid sampling-rate '2'. Decimal value between 0 and 1 should be used.",
"--tracing-configuration", "set", "--sampling-rate", "2");

assertParseArgsThrows("At least one supported scope should be specified.",
"--tracing-configuration", "set", "--included-scopes");

assertParseArgsThrows("Invalid supported scope 'aaa'. The following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "set", "--included-scopes", "TX,aaa");
}

/**
* Positive argument validation test for tracing-configuration command.
*/
@Test
public void testTracingConfigurationArgumentsValidationMandatoryArgumentSet() {
parseArgs(asList("--tracing-configuration"));

parseArgs(asList("--tracing-configuration", "get_all"));

assertParseArgsThrows("Scope attribute is missing. Following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "reset");

assertParseArgsThrows("Scope attribute is missing. Following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "get");

assertParseArgsThrows("Scope attribute is missing. Following values can be used: "
+ Arrays.toString(Scope.values()) + '.', "--tracing-configuration", "set");
}

/**
* Test checks that option {@link CommonArgParser#CMD_VERBOSE} is parsed
* correctly and if it is not present, it takes the default value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -98,6 +99,7 @@
import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR;
import static org.apache.ignite.internal.commandline.CommandHandler.UTILITY_NAME;
import static org.apache.ignite.internal.commandline.CommandList.BASELINE;
import static org.apache.ignite.internal.commandline.CommandList.TRACING_CONFIGURATION;
import static org.apache.ignite.internal.commandline.CommandList.METADATA;
import static org.apache.ignite.internal.commandline.CommandList.WAL;
import static org.apache.ignite.internal.commandline.CommonArgParser.CMD_VERBOSE;
Expand Down Expand Up @@ -1594,6 +1596,7 @@ public void testContainsWarnInsteadExecExperimentalCmdWhenEnableExperimentalFals

cmdArgs.put(WAL, asList("print", "delete"));
cmdArgs.put(METADATA, asList("help", "list"));
cmdArgs.put(TRACING_CONFIGURATION, Collections.singletonList("get_all"));

String warning = String.format(
"For use experimental command add %s=true to JVM_OPTS in %s",
Expand Down
Loading