Search in sources :

Example 6 with KillerForTests

use of org.apache.cassandra.utils.KillerForTests in project cassandra by apache.

the class CommitLogFailurePolicyTest method testCommitFailurePolicy_die.

@Test
public void testCommitFailurePolicy_die() {
    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.die);
        CommitLog.handleCommitError("Testing die policy", new Throwable());
        Assert.assertTrue(killerForTests.wasKilled());
        //only killed quietly on startup failure
        Assert.assertFalse(killerForTests.wasKilledQuietly());
    } finally {
        DatabaseDescriptor.setCommitFailurePolicy(oldPolicy);
        JVMStabilityInspector.replaceKiller(originalKiller);
    }
}
Also used : JVMStabilityInspector(org.apache.cassandra.utils.JVMStabilityInspector) KillerForTests(org.apache.cassandra.utils.KillerForTests) Config(org.apache.cassandra.config.Config) CassandraDaemon(org.apache.cassandra.service.CassandraDaemon) Test(org.junit.Test)

Example 7 with KillerForTests

use of org.apache.cassandra.utils.KillerForTests in project cassandra by apache.

the class CommitLogReaderTest method beforeClass.

@BeforeClass
public static void beforeClass() {
    DatabaseDescriptor.setCommitFailurePolicy(Config.CommitFailurePolicy.ignore);
    JVMStabilityInspector.replaceKiller(new KillerForTests(false));
}
Also used : KillerForTests(org.apache.cassandra.utils.KillerForTests) BeforeClass(org.junit.BeforeClass)

Aggregations

KillerForTests (org.apache.cassandra.utils.KillerForTests)7 JVMStabilityInspector (org.apache.cassandra.utils.JVMStabilityInspector)4 Test (org.junit.Test)4 Config (org.apache.cassandra.config.Config)3 CassandraDaemon (org.apache.cassandra.service.CassandraDaemon)3 Closeable (java.io.Closeable)1 DiskFailurePolicy (org.apache.cassandra.config.Config.DiskFailurePolicy)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1