use of org.apache.cassandra.utils.KillerForTests in project cassandra by apache.
the class OutOfSpaceTest method testFlushUnwriteableDie.
@Test
public void testFlushUnwriteableDie() throws Throwable {
makeTable();
KillerForTests killerForTests = new KillerForTests();
JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
DiskFailurePolicy oldPolicy = DatabaseDescriptor.getDiskFailurePolicy();
try (Closeable c = Util.markDirectoriesUnwriteable(getCurrentColumnFamilyStore())) {
DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.die);
flushAndExpectError();
Assert.assertTrue(killerForTests.wasKilled());
//only killed quietly on startup failure
Assert.assertFalse(killerForTests.wasKilledQuietly());
} finally {
DatabaseDescriptor.setDiskFailurePolicy(oldPolicy);
JVMStabilityInspector.replaceKiller(originalKiller);
}
}
use of org.apache.cassandra.utils.KillerForTests in project cassandra by apache.
the class CommitLogFailurePolicyTest method testCommitFailurePolicy_ignore_beforeStartup.
@Test
public void testCommitFailurePolicy_ignore_beforeStartup() {
//startup was not completed successfuly (since method completeSetup() was not called)
CassandraDaemon daemon = new CassandraDaemon();
StorageService.instance.registerDaemon(daemon);
KillerForTests killerForTests = new KillerForTests();
JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
try {
DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.ignore);
CommitLog.handleCommitError("Testing ignore policy", new Throwable());
//even though policy is ignore, JVM must die because Daemon has not finished initializing
Assert.assertTrue(killerForTests.wasKilled());
//killed quietly due to startup failure
Assert.assertTrue(killerForTests.wasKilledQuietly());
} finally {
DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
JVMStabilityInspector.replaceKiller(originalKiller);
}
}
use of org.apache.cassandra.utils.KillerForTests in project cassandra by apache.
the class CommitLogTest method beforeClass.
@BeforeClass
public static void beforeClass() throws ConfigurationException {
// Disable durable writes for system keyspaces to prevent system mutations, e.g. sstable_activity,
// to end up in CL segments and cause unexpected results in this test wrt counting CL segments,
// see CASSANDRA-12854
KeyspaceParams.DEFAULT_LOCAL_DURABLE_WRITES = false;
SchemaLoader.prepareServer();
SchemaLoader.createKeyspace(KEYSPACE1, KeyspaceParams.simple(1), SchemaLoader.standardCFMD(KEYSPACE1, STANDARD1, 0, AsciiType.instance, BytesType.instance), SchemaLoader.standardCFMD(KEYSPACE1, STANDARD2, 0, AsciiType.instance, BytesType.instance));
SchemaLoader.createKeyspace(KEYSPACE2, KeyspaceParams.simpleTransient(1), SchemaLoader.standardCFMD(KEYSPACE1, STANDARD1, 0, AsciiType.instance, BytesType.instance), SchemaLoader.standardCFMD(KEYSPACE1, STANDARD2, 0, AsciiType.instance, BytesType.instance));
CompactionManager.instance.disableAutoCompaction();
testKiller = new KillerForTests();
// While we don't want the JVM to be nuked from under us on a test failure, we DO want some indication of
// an error. If we hit a "Kill the JVM" condition while working with the CL when we don't expect it, an aggressive
// KillerForTests will assertion out on us.
oldKiller = JVMStabilityInspector.replaceKiller(testKiller);
}
use of org.apache.cassandra.utils.KillerForTests in project cassandra by apache.
the class CommitLogUpgradeTest method prepareToBeKilled.
@Before
public void prepareToBeKilled() {
killerForTests = new KillerForTests();
originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
}
use of org.apache.cassandra.utils.KillerForTests in project cassandra by apache.
the class CommitLogFailurePolicyTest method testCommitFailurePolicy_ignore_afterStartup.
@Test
public void testCommitFailurePolicy_ignore_afterStartup() throws Exception {
CassandraDaemon daemon = new CassandraDaemon();
//startup must be completed, otherwise commit log failure must kill JVM regardless of failure policy
daemon.completeSetup();
StorageService.instance.registerDaemon(daemon);
KillerForTests killerForTests = new KillerForTests();
JVMStabilityInspector.Killer originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
Config.CommitFailurePolicy oldPolicy = DatabaseDescriptor.getCommitFailurePolicy();
try {
DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.ignore);
CommitLog.handleCommitError("Testing ignore policy", new Throwable());
//error policy is set to IGNORE, so JVM must not be killed if error ocurs after startup
Assert.assertFalse(killerForTests.wasKilled());
} finally {
DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
JVMStabilityInspector.replaceKiller(originalKiller);
}
}
Aggregations