You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by al...@apache.org on 2015/08/20 20:30:01 UTC
[1/2] cassandra git commit: Fix post-9749 test failures
Repository: cassandra
Updated Branches:
refs/heads/cassandra-3.0 df52cd64e -> 0d866456a
Fix post-9749 test failures
patch by Branimir Lambov; reviewed by Ariel Weisberg for CASSANDRA-9749
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/7a85c8b8
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/7a85c8b8
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/7a85c8b8
Branch: refs/heads/cassandra-3.0
Commit: 7a85c8b8fbf753858c4334c4249475e6bb1a24e4
Parents: a6dd2b8
Author: Branimir Lambov <br...@datastax.com>
Authored: Wed Aug 19 19:56:58 2015 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Thu Aug 20 21:25:33 2015 +0300
----------------------------------------------------------------------
.../cassandra/db/commitlog/CommitLogTest.java | 102 ++++++++++---------
.../db/commitlog/CommitLogUpgradeTest.java | 38 ++++---
2 files changed, 78 insertions(+), 62 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a85c8b8/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java b/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
index da8058c..0ad880b 100644
--- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
+++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogTest.java
@@ -29,19 +29,18 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.zip.CRC32;
import java.util.zip.Checksum;
import com.google.common.collect.ImmutableMap;
+
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.Util;
-import org.apache.cassandra.config.Config.CommitFailurePolicy;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.config.KSMetaData;
import org.apache.cassandra.config.ParameterizedClass;
@@ -63,8 +62,7 @@ import org.apache.cassandra.io.util.ByteBufferDataInput;
import org.apache.cassandra.io.util.FileDataInput;
import org.apache.cassandra.locator.SimpleStrategy;
import org.apache.cassandra.net.MessagingService;
-import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.FBUtilities;
+import org.apache.cassandra.utils.*;
import static org.apache.cassandra.utils.ByteBufferUtil.bytes;
@@ -94,10 +92,15 @@ public class CommitLogTest
CompactionManager.instance.disableAutoCompaction();
}
- @Test(expected = CommitLogReplayException.class)
+ @Test
public void testRecoveryWithEmptyLog() throws Exception
{
- CommitLog.instance.recover(new File[]{ tmpFile(CommitLogDescriptor.current_version) });
+ runExpecting(new WrappedRunnable() {
+ public void runMayThrow() throws Exception
+ {
+ CommitLog.instance.recover(new File[]{ tmpFile(CommitLogDescriptor.current_version) });
+ }
+ }, CommitLogReplayException.class);
}
@Test
@@ -119,10 +122,15 @@ public class CommitLogTest
testRecoveryWithBadSizeArgument(100, 10);
}
- @Test(expected = CommitLogReplayException.class)
+ @Test
public void testRecoveryWithShortSize() throws Exception
{
- testRecovery(new byte[2], CommitLogDescriptor.VERSION_20);
+ runExpecting(new WrappedRunnable() {
+ public void runMayThrow() throws Exception
+ {
+ testRecovery(new byte[2], CommitLogDescriptor.VERSION_20);
+ }
+ }, CommitLogReplayException.class);
}
@Test
@@ -146,10 +154,15 @@ public class CommitLogTest
testRecovery(garbage, CommitLogDescriptor.current_version);
}
- @Test(expected = CommitLogReplayException.class)
+ @Test
public void testRecoveryWithGarbageLog_fail() throws Exception
{
- testRecoveryWithGarbageLog();
+ runExpecting(new WrappedRunnable() {
+ public void runMayThrow() throws Exception
+ {
+ testRecoveryWithGarbageLog();
+ }
+ }, CommitLogReplayException.class);
}
@Test
@@ -164,18 +177,6 @@ public class CommitLogTest
}
@Test
- public void testRecoveryWithGarbageLog_ignoredByPolicy() throws Exception
- {
- CommitFailurePolicy existingPolicy = DatabaseDescriptor.getCommitFailurePolicy();
- try {
- DatabaseDescriptor.setCommitFailurePolicy(CommitFailurePolicy.ignore);
- testRecoveryWithGarbageLog();
- } finally {
- DatabaseDescriptor.setCommitFailurePolicy(existingPolicy);
- }
- }
-
- @Test
public void testRecoveryWithBadSizeChecksum() throws Exception
{
Checksum checksum = new CRC32();
@@ -331,7 +332,7 @@ public class CommitLogTest
return logFile;
}
- protected Void testRecovery(byte[] logData, int version) throws Exception
+ protected void testRecovery(byte[] logData, int version) throws Exception
{
File logFile = tmpFile(version);
try (OutputStream lout = new FileOutputStream(logFile))
@@ -340,10 +341,9 @@ public class CommitLogTest
//statics make it annoying to test things correctly
CommitLog.instance.recover(logFile.getPath()); //CASSANDRA-1119 / CASSANDRA-1179 throw on failure*/
}
- return null;
}
- protected Void testRecovery(CommitLogDescriptor desc, byte[] logData) throws Exception
+ protected void testRecovery(CommitLogDescriptor desc, byte[] logData) throws Exception
{
File logFile = tmpFile(desc.version);
CommitLogDescriptor fromFile = CommitLogDescriptor.fromFileName(logFile.getName());
@@ -358,60 +358,66 @@ public class CommitLogTest
//statics make it annoying to test things correctly
CommitLog.instance.recover(logFile.getPath()); //CASSANDRA-1119 / CASSANDRA-1179 throw on failure*/
}
- return null;
}
- @Test(expected = CommitLogReplayException.class)
+ @Test
public void testRecoveryWithIdMismatch() throws Exception
{
CommitLogDescriptor desc = new CommitLogDescriptor(4, null);
- File logFile = tmpFile(desc.version);
+ final File logFile = tmpFile(desc.version);
ByteBuffer buf = ByteBuffer.allocate(1024);
CommitLogDescriptor.writeHeader(buf, desc);
try (OutputStream lout = new FileOutputStream(logFile))
{
lout.write(buf.array(), 0, buf.position());
- //statics make it annoying to test things correctly
- CommitLog.instance.recover(logFile.getPath()); //CASSANDRA-1119 / CASSANDRA-1179 throw on failure*/
+
+ runExpecting(new WrappedRunnable() {
+ public void runMayThrow() throws Exception
+ {
+ CommitLog.instance.recover(logFile.getPath()); //CASSANDRA-1119 / CASSANDRA-1179 throw on failure*/
+ }
+ }, CommitLogReplayException.class);
}
}
- @Test(expected = CommitLogReplayException.class)
- public void testRecoveryWithBadCompressor() throws Exception
+ protected void runExpecting(Runnable r, Class<?> expected)
{
- CommitLogDescriptor desc = new CommitLogDescriptor(4, new ParameterizedClass("UnknownCompressor", null));
- testRecovery(desc, new byte[0]);
- }
+ JVMStabilityInspector.Killer originalKiller;
+ KillerForTests killerForTests;
+
+ killerForTests = new KillerForTests();
+ originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
- protected void runExpecting(Callable<Void> r, Class<?> expected)
- {
Throwable caught = null;
try
{
- r.call();
+ r.run();
}
- catch (Throwable t)
+ catch (RuntimeException e)
{
- if (expected != t.getClass())
- throw new AssertionError("Expected exception " + expected + ", got " + t, t);
- caught = t;
+ if (expected != e.getCause().getClass())
+ throw new AssertionError("Expected exception " + expected + ", got " + e, e);
+ caught = e;
}
if (expected != null && caught == null)
Assert.fail("Expected exception " + expected + " but call completed successfully.");
+
+ JVMStabilityInspector.replaceKiller(originalKiller);
+ Assert.assertEquals("JVM killed", expected != null, killerForTests.wasKilled());
}
protected void testRecovery(final byte[] logData, Class<?> expected) throws Exception
{
- runExpecting(new Callable<Void>() {
- public Void call() throws Exception
+ runExpecting(new WrappedRunnable() {
+ public void runMayThrow() throws Exception
{
- return testRecovery(logData, CommitLogDescriptor.VERSION_20);
+ testRecovery(logData, CommitLogDescriptor.VERSION_20);
}
}, expected);
- runExpecting(new Callable<Void>() {
- public Void call() throws Exception
+ runExpecting(new WrappedRunnable() {
+ public void runMayThrow() throws Exception
{
- return testRecovery(new CommitLogDescriptor(4, null), logData);
+ testRecovery(new CommitLogDescriptor(4, null), logData);
}
}, expected);
}
http://git-wip-us.apache.org/repos/asf/cassandra/blob/7a85c8b8/test/unit/org/apache/cassandra/db/commitlog/CommitLogUpgradeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/commitlog/CommitLogUpgradeTest.java b/test/unit/org/apache/cassandra/db/commitlog/CommitLogUpgradeTest.java
index 2031475..af85d5d 100644
--- a/test/unit/org/apache/cassandra/db/commitlog/CommitLogUpgradeTest.java
+++ b/test/unit/org/apache/cassandra/db/commitlog/CommitLogUpgradeTest.java
@@ -31,18 +31,20 @@ import junit.framework.Assert;
import com.google.common.base.Predicate;
+import org.junit.After;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.CFMetaData;
-import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.db.Cell;
import org.apache.cassandra.db.ColumnFamily;
-import org.apache.cassandra.config.Config.CommitFailurePolicy;
import org.apache.cassandra.db.Mutation;
import org.apache.cassandra.db.commitlog.CommitLogReplayer.CommitLogReplayException;
+import org.apache.cassandra.utils.JVMStabilityInspector;
+import org.apache.cassandra.utils.KillerForTests;
public class CommitLogUpgradeTest
{
@@ -56,6 +58,24 @@ public class CommitLogUpgradeTest
static final String KEYSPACE = "Keyspace1";
static final String CELLNAME = "name";
+ private JVMStabilityInspector.Killer originalKiller;
+ private KillerForTests killerForTests;
+ private boolean shouldBeKilled = false;
+
+ @Before
+ public void prepareToBeKilled()
+ {
+ killerForTests = new KillerForTests();
+ originalKiller = JVMStabilityInspector.replaceKiller(killerForTests);
+ }
+
+ @After
+ public void cleanUp()
+ {
+ JVMStabilityInspector.replaceKiller(originalKiller);
+ Assert.assertEquals("JVM killed", shouldBeKilled, killerForTests.wasKilled());
+ }
+
@Test
public void test20() throws Exception
{
@@ -77,6 +97,7 @@ public class CommitLogUpgradeTest
@Test(expected = CommitLogReplayException.class)
public void test22_bitrot() throws Exception
{
+ shouldBeKilled = true;
testRestore(DATA_DIR + "2.2-lz4-bitrot");
}
@@ -91,21 +112,10 @@ public class CommitLogUpgradeTest
}
}
- @Test
- public void test22_bitrot_ignore_policy() throws Exception
- {
- CommitFailurePolicy existingPolicy = DatabaseDescriptor.getCommitFailurePolicy();
- try {
- DatabaseDescriptor.setCommitFailurePolicy(CommitFailurePolicy.ignore);
- testRestore(DATA_DIR + "2.2-lz4-bitrot");
- } finally {
- DatabaseDescriptor.setCommitFailurePolicy(existingPolicy);
- }
- }
-
@Test(expected = CommitLogReplayException.class)
public void test22_bitrot2() throws Exception
{
+ shouldBeKilled = true;
testRestore(DATA_DIR + "2.2-lz4-bitrot2");
}
[2/2] cassandra git commit: Merge branch 'cassandra-2.2' into
cassandra-3.0
Posted by al...@apache.org.
Merge branch 'cassandra-2.2' into cassandra-3.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0d866456
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0d866456
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0d866456
Branch: refs/heads/cassandra-3.0
Commit: 0d866456a144ea6b3f86f3677f0e8d90c7b1d2d5
Parents: df52cd6 7a85c8b
Author: Aleksey Yeschenko <al...@apache.org>
Authored: Thu Aug 20 21:30:15 2015 +0300
Committer: Aleksey Yeschenko <al...@apache.org>
Committed: Thu Aug 20 21:30:15 2015 +0300
----------------------------------------------------------------------
----------------------------------------------------------------------