You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2015/06/07 13:48:25 UTC
[3/4] cassandra git commit: Lifecycle unit tests fail when run in
parallel
Lifecycle unit tests fail when run in parallel
patch by stefania; reviewed by benedict for CASSANDRA-9561
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/99a84bca
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/99a84bca
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/99a84bca
Branch: refs/heads/cassandra-2.2
Commit: 99a84bcafa215ae99b84b28a916764bb48512161
Parents: b0ae285
Author: stefania <st...@datastax.com>
Authored: Sun Jun 7 12:46:48 2015 +0100
Committer: Benedict Elliott Smith <be...@apache.org>
Committed: Sun Jun 7 12:47:06 2015 +0100
----------------------------------------------------------------------
test/unit/org/apache/cassandra/MockSchema.java | 19 ++++++++++++-------
.../cassandra/db/lifecycle/HelpersTest.java | 7 +++++++
.../db/lifecycle/LifecycleTransactionTest.java | 7 +++++++
.../apache/cassandra/db/lifecycle/ViewTest.java | 6 ++++++
4 files changed, 32 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99a84bca/test/unit/org/apache/cassandra/MockSchema.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/MockSchema.java b/test/unit/org/apache/cassandra/MockSchema.java
index 94313cd..c71c98b 100644
--- a/test/unit/org/apache/cassandra/MockSchema.java
+++ b/test/unit/org/apache/cassandra/MockSchema.java
@@ -21,7 +21,6 @@ package org.apache.cassandra;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
-import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -88,7 +87,11 @@ public class MockSchema
public static SSTableReader sstable(int generation, int size, boolean keepRef, ColumnFamilyStore cfs)
{
- Descriptor descriptor = new Descriptor(temp("mockcfdir").getParentFile(), ks.getName(), cfs.getColumnFamilyName(), generation, Descriptor.Type.FINAL);
+ Descriptor descriptor = new Descriptor(cfs.directories.getDirectoryForNewSSTables(),
+ cfs.keyspace.getName(),
+ cfs.getColumnFamilyName(),
+ generation,
+ Descriptor.Type.FINAL);
Set<Component> components = ImmutableSet.of(Component.DATA, Component.PRIMARY_INDEX, Component.FILTER, Component.TOC);
for (Component component : components)
{
@@ -100,7 +103,6 @@ public class MockSchema
catch (IOException e)
{
}
- file.deleteOnExit();
}
if (size > 0)
{
@@ -132,13 +134,16 @@ public class MockSchema
public static ColumnFamilyStore newCFS()
{
String cfname = "mockcf" + (id.incrementAndGet());
- CFMetaData metadata = newCFMetaData(cfname);
+ CFMetaData metadata = newCFMetaData(ks.getName(), cfname);
return new ColumnFamilyStore(ks, cfname, Murmur3Partitioner.instance, 0, metadata, new Directories(metadata), false, false);
}
- private static CFMetaData newCFMetaData(String cfname)
+ private static CFMetaData newCFMetaData(String ksname, String cfname)
{
- CFMetaData metadata = new CFMetaData("mockks", cfname, ColumnFamilyType.Standard, new SimpleSparseCellNameType(UTF8Type.instance));
+ CFMetaData metadata = new CFMetaData(ksname,
+ cfname,
+ ColumnFamilyType.Standard,
+ new SimpleSparseCellNameType(UTF8Type.instance));
metadata.caching(CachingOptions.NONE);
return metadata;
}
@@ -169,7 +174,7 @@ public class MockSchema
{
File dir = new File(dirName);
if (!dir.exists())
- throw new RuntimeException("No such directory: " + dir.getAbsolutePath());
+ continue;
String[] children = dir.list();
for (String child : children)
FileUtils.deleteRecursive(new File(dir, child));
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99a84bca/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java b/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
index 24d2bda..5d37059 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/HelpersTest.java
@@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
+import org.junit.BeforeClass;
import org.junit.Test;
import junit.framework.Assert;
@@ -39,6 +40,12 @@ import org.apache.cassandra.utils.concurrent.Refs;
public class HelpersTest
{
+ @BeforeClass
+ public static void setUp()
+ {
+ MockSchema.cleanup();
+ }
+
static Set<Integer> a = set(1, 2, 3);
static Set<Integer> b = set(4, 5, 6);
static Set<Integer> c = set(7, 8, 9);
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99a84bca/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java b/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
index 2c6c830..aaa9999 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/LifecycleTransactionTest.java
@@ -23,6 +23,7 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import junit.framework.Assert;
@@ -53,6 +54,12 @@ public class LifecycleTransactionTest extends AbstractTransactionalTest
{
private boolean incrementalBackups;
+ @BeforeClass
+ public static void setUp()
+ {
+ MockSchema.cleanup();
+ }
+
@Before
public void disableIncrementalBackup()
{
http://git-wip-us.apache.org/repos/asf/cassandra/blob/99a84bca/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
index aa99fbd..4c8006a 100644
--- a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
+++ b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java
@@ -26,6 +26,7 @@ import com.google.common.base.Function;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
+import org.junit.BeforeClass;
import org.junit.Test;
import junit.framework.Assert;
@@ -43,6 +44,11 @@ import static org.apache.cassandra.db.lifecycle.Helpers.emptySet;
public class ViewTest
{
+ @BeforeClass
+ public static void setUp()
+ {
+ MockSchema.cleanup();
+ }
@Test
public void testSSTablesInBounds()