Search in sources :

Example 1 with KillerForTests

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);
    }
}
Also used : JVMStabilityInspector(org.apache.cassandra.utils.JVMStabilityInspector) KillerForTests(org.apache.cassandra.utils.KillerForTests) DiskFailurePolicy(org.apache.cassandra.config.Config.DiskFailurePolicy) Closeable(java.io.Closeable) Test(org.junit.Test)

Example 2 with KillerForTests

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);
    }
}
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 3 with KillerForTests

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);
}
Also used : KillerForTests(org.apache.cassandra.utils.KillerForTests)

Example 4 with KillerForTests

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);
}
Also used : KillerForTests(org.apache.cassandra.utils.KillerForTests) Before(org.junit.Before)

Example 5 with 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);
    }
}
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)

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