use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneScrubberTest method testHeaderFixArg.
@Test
public void testHeaderFixArg() {
Arrays.asList(Pair.of("-e", ""), Pair.of("-e", "wrong"), Pair.of("--header-fix", ""), Pair.of("--header-fix", "wrong")).forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, arg.getLeft(), arg.getRight(), "system_schema", "tables");
assertThat("Arg: [" + arg + "]", tool.getStdout(), CoreMatchers.containsStringIgnoringCase("usage:"));
assertTrue("Arg: [" + arg + "]\n" + tool.getCleanedStderr(), tool.getCleanedStderr().contains("Invalid argument value"));
assertEquals(1, tool.getExitCode());
});
Arrays.asList(Pair.of("-e", "validate-only"), Pair.of("-e", "validate"), Pair.of("-e", "fix-only"), Pair.of("-e", "fix"), Pair.of("-e", "off"), Pair.of("--header-fix", "validate-only"), Pair.of("--header-fix", "validate"), Pair.of("--header-fix", "fix-only"), Pair.of("--header-fix", "fix"), Pair.of("--header-fix", "off")).forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, arg.getLeft(), arg.getRight(), "system_schema", "tables");
assertThat("Arg: [" + arg + "]", tool.getStdout(), CoreMatchers.containsStringIgnoringCase("Pre-scrub sstables snapshotted into snapshot"));
Assertions.assertThat(tool.getCleanedStderr()).as("Arg: [%s]", arg).isEmpty();
tool.assertOnExitCode();
assertCorrectEnvPostTest();
});
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneScrubberTest method testMaybeChangeDocs.
@Test
public void testMaybeChangeDocs() {
// If you added, modified options or help, please update docs if necessary
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, "-h");
String help = "usage: sstablescrub [options] <keyspace> <column_family>\n" + "--\n" + "Scrub the sstable for the provided table.\n" + "--\n" + "Options are:\n" + " --debug display stack traces\n" + " -e,--header-fix <arg> Option whether and how to perform a check of the sstable serialization-headers and fix\n" + " known, fixable issues.\n" + " Possible argument values:\n" + " - validate-only: validate the serialization-headers, but do not fix those. Do not continue with scrub - i.e. only\n" + " validate the header (dry-run of fix-only).\n" + " - validate: (default) validate the serialization-headers, but do not fix those and only continue with scrub if no error\n" + " were detected.\n" + " - fix-only: validate and fix the serialization-headers, don't continue with scrub.\n" + " - fix: validate and fix the serialization-headers, do not fix and do not continue with scrub if the serialization-header\n" + " check encountered errors.\n" + " - off: don't perform the serialization-header checks.\n" + " -h,--help display this help message\n" + " -m,--manifest-check only check and repair the leveled manifest, without actually scrubbing the sstables\n" + " -n,--no-validate do not validate columns using column validator\n" + " -r,--reinsert-overflowed-ttl Rewrites rows with overflowed expiration date affected by CASSANDRA-14092 with the\n" + " maximum supported expiration date of 2038-01-19T03:14:06+00:00. The rows are rewritten with the original timestamp\n" + " incremented by one millisecond to override/supersede any potential tombstone that may have been generated during\n" + " compaction of the affected rows.\n" + " -s,--skip-corrupted skip corrupt rows in counter tables\n" + " -v,--verbose verbose output\n";
Assertions.assertThat(tool.getStdout()).isEqualTo(help);
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneScrubberTest method testFlagArgs.
@Test
public void testFlagArgs() {
Arrays.asList("--debug", "-m", "--manifest-check", "-n", "--no-validate", "-r", "--reinsert-overflowed-ttl", "-s", "--skip-corrupted", "-v", "--verbose").forEach(arg -> {
ToolResult tool = ToolRunner.invokeClass(StandaloneScrubber.class, arg, "system_schema", "tables");
assertThat("Arg: [" + arg + "]", tool.getStdout(), CoreMatchers.containsStringIgnoringCase("Pre-scrub sstables snapshotted into snapshot"));
Assertions.assertThat(tool.getCleanedStderr()).as("Arg: [%s]", arg).isEmpty();
tool.assertOnExitCode();
assertCorrectEnvPostTest();
});
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneSplitterWithCQLTesterTest method testSplittingSSTable.
@Test
public void testSplittingSSTable() throws Throwable {
ToolResult tool = ToolRunner.invokeClass(StandaloneSplitter.class, "-s", "1", sstableFileName);
List<File> splitFiles = Arrays.asList(sstablesDir.tryList());
splitFiles.stream().forEach(f -> {
if (f.name().endsWith("Data.db") && !origSstables.contains(f))
assertTrue(f.name() + " is way bigger than 1MiB: [" + f.length() + "] bytes", // give a 20% margin on size check
f.length() <= 1024 * 1024 * 1.2);
});
assertTrue(origSstables.size() < splitFiles.size());
Assertions.assertThat(tool.getStdout()).contains("sstables snapshotted into");
assertTrue(tool.getCleanedStderr(), tool.getCleanedStderr().isEmpty());
assertEquals(0, tool.getExitCode());
}
use of org.apache.cassandra.tools.ToolRunner.ToolResult in project cassandra by apache.
the class StandaloneUpgraderTest method testMaybeChangeDocs.
@Test
public void testMaybeChangeDocs() {
// If you added, modified options or help, please update docs if necessary
ToolResult tool = ToolRunner.invokeClass(StandaloneUpgrader.class, "-h");
String help = "usage: sstableupgrade [options] <keyspace> <cf> [snapshot]\n" + "--\n" + "Upgrade the sstables in the given cf (or snapshot) to the current version\n" + "of Cassandra.This operation will rewrite the sstables in the specified cf\n" + "to match the currently installed version of Cassandra.\n" + "The snapshot option will only upgrade the specified snapshot. Upgrading\n" + "snapshots is required before attempting to restore a snapshot taken in a\n" + "major version older than the major version Cassandra is currently running.\n" + "This will replace the files in the given snapshot as well as break any\n" + "hard links to live sstables.\n" + "--\n" + "Options are:\n" + " --debug display stack traces\n" + " -h,--help display this help message\n" + " -k,--keep-source do not delete the source sstables\n";
Assertions.assertThat(tool.getStdout()).isEqualTo(help);
}
Aggregations