Author: jbellis
Date: Tue Dec 29 23:40:44 2009
New Revision: 894517
URL: http://svn.apache.org/viewvc?rev=894517&view=rev
Log:
extend cleanuphelper in more places, and make cleanuphelper stricter about
cleaning out old data. fixes test heisenbugs. patch by jbellis
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/OneCompactionTest.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
incubator/cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java
(original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/CleanupHelper.java
Tue Dec 29 23:40:44 2009
@@ -24,6 +24,8 @@
import org.junit.BeforeClass;
import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.io.util.FileUtils;
+
import org.apache.log4j.Logger;
public class CleanupHelper
@@ -31,25 +33,19 @@
private static Logger logger = Logger.getLogger(CleanupHelper.class);
@BeforeClass
- public static void cleanupAndLeaveDirs()
+ public static void cleanupAndLeaveDirs() throws IOException
{
mkdirs();
cleanup();
mkdirs();
}
- public static void cleanup()
+ public static void cleanup() throws IOException
{
- // we clean the fs twice, once to start with (so old data files don't
get stored by anything static if this is the first run)
- // and once after flushing stuff (to try to clean things out if it is
not.) part #2 seems to be less than perfect.
+ // clean up commitlog
String[] directoryNames = {
DatabaseDescriptor.getLogFileLocation(),
};
-
- // try to delete the directories themselves too. don't panic if this
fails. it probably means that the process
- // doesn't have permissions to do so, or it contains non-cassandra
generated files that were intentionally
- // put there.
-
for (String dirName : directoryNames)
{
File dir = new File(dirName);
@@ -59,17 +55,12 @@
}
for (File f : dir.listFiles())
{
- if (!f.delete())
- {
- logger.error("could not delete " + f);
- }
+ FileUtils.deleteWithConfirm(f);
}
-
- if (!dir.delete())
- logger.warn("could not delete " + dir.getPath());
+ FileUtils.deleteWithConfirm(dir);
}
- // cleanup data directory which are stored as data
directory/table/data files
+ // clean up data directory which are stored as data
directory/table/data files
for (String dirName : DatabaseDescriptor.getAllDataFileLocations())
{
File dir = new File(dirName);
@@ -80,19 +71,16 @@
for (File tableFile : dir.listFiles())
{
// table directory
- if (tableFile.isDirectory()) {
- for (File dataFile : tableFile.listFiles()) {
- if (!dataFile.delete()) {
- logger.error("could not delete " + dataFile);
- }
+ if (tableFile.isDirectory())
+ {
+ for (File dataFile : tableFile.listFiles())
+ {
+ FileUtils.deleteWithConfirm(dataFile);
}
}
- if (!tableFile.delete())
- logger.warn("could not delete " + dir.getPath());
+ FileUtils.deleteWithConfirm(tableFile);
}
-
- if (!dir.delete())
- logger.warn("could not delete " + dir.getPath());
+ FileUtils.deleteWithConfirm(dir);
}
}
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/OneCompactionTest.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/OneCompactionTest.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/OneCompactionTest.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/OneCompactionTest.java
Tue Dec 29 23:40:44 2009
@@ -28,8 +28,9 @@
import static junit.framework.Assert.assertEquals;
import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.CleanupHelper;
-public class OneCompactionTest
+public class OneCompactionTest extends CleanupHelper
{
private void testCompaction(String columnFamilyName, int insertsPerTable)
throws IOException, ExecutionException, InterruptedException
{
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
Tue Dec 29 23:40:44 2009
@@ -26,8 +26,9 @@
import static junit.framework.Assert.assertNull;
import org.apache.cassandra.db.filter.IdentityQueryFilter;
import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.CleanupHelper;
-public class RemoveColumnFamilyTest
+public class RemoveColumnFamilyTest extends CleanupHelper
{
@Test
public void testRemoveColumnFamily() throws IOException,
ExecutionException, InterruptedException
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
Tue Dec 29 23:40:44 2009
@@ -26,8 +26,9 @@
import static junit.framework.Assert.assertNull;
import org.apache.cassandra.db.filter.IdentityQueryFilter;
import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.CleanupHelper;
-public class RemoveColumnFamilyWithFlush1Test
+public class RemoveColumnFamilyWithFlush1Test extends CleanupHelper
{
@Test
public void testRemoveColumnFamilyWithFlush1() throws IOException,
ExecutionException, InterruptedException
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
Tue Dec 29 23:40:44 2009
@@ -26,8 +26,9 @@
import static junit.framework.Assert.assertNull;
import org.apache.cassandra.db.filter.IdentityQueryFilter;
import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.CleanupHelper;
-public class RemoveColumnFamilyWithFlush2Test
+public class RemoveColumnFamilyWithFlush2Test extends CleanupHelper
{
@Test
public void testRemoveColumnFamilyWithFlush2() throws IOException,
ExecutionException, InterruptedException
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnTest.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
Tue Dec 29 23:40:44 2009
@@ -27,8 +27,9 @@
import org.apache.cassandra.db.filter.IdentityQueryFilter;
import org.apache.cassandra.db.filter.NamesQueryFilter;
import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.CleanupHelper;
-public class RemoveColumnTest
+public class RemoveColumnTest extends CleanupHelper
{
@Test
public void testRemoveColumn() throws IOException, ExecutionException,
InterruptedException
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
Tue Dec 29 23:40:44 2009
@@ -28,8 +28,9 @@
import org.apache.cassandra.db.filter.QueryPath;
import static org.apache.cassandra.Util.addMutation;
import static org.apache.cassandra.Util.getBytes;
+import org.apache.cassandra.CleanupHelper;
-public class RemoveSubColumnTest
+public class RemoveSubColumnTest extends CleanupHelper
{
@Test
public void testRemoveSubColumn() throws IOException, ExecutionException,
InterruptedException
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
Tue Dec 29 23:40:44 2009
@@ -33,9 +33,10 @@
import static org.apache.cassandra.Util.addMutation;
import static org.apache.cassandra.Util.getBytes;
import org.apache.cassandra.Util;
+import org.apache.cassandra.CleanupHelper;
import static junit.framework.Assert.assertNotNull;
-public class RemoveSuperColumnTest
+public class RemoveSuperColumnTest extends CleanupHelper
{
@Test
public void testRemoveSuperColumn() throws IOException,
ExecutionException, InterruptedException
Modified:
incubator/cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java?rev=894517&r1=894516&r2=894517&view=diff
==============================================================================
---
incubator/cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
(original)
+++
incubator/cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
Tue Dec 29 23:40:44 2009
@@ -45,19 +45,21 @@
public class AntiEntropyServiceTest extends CleanupHelper
{
- public static InetAddress LOCAL = FBUtilities.getLocalAddress();
-
// table and column family to test against
public AntiEntropyService aes;
public static String tablename;
public static String cfname;
- public static InetAddress REMOTE;
+ public static InetAddress LOCAL, REMOTE;
+
+ private static boolean initialized;
- static
+ @Before
+ public void prepare() throws Exception
{
- try
+ if (!initialized)
{
+ LOCAL = FBUtilities.getLocalAddress();
// bump the replication factor so that local overlaps with REMOTE
below
DatabaseDescriptorTest.setReplicationFactor(2);
@@ -71,16 +73,8 @@
tablename = DatabaseDescriptor.getTables().get(0);
cfname =
Table.open(tablename).getColumnFamilies().iterator().next();
+ initialized = true;
}
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- @Before
- public void prepare() throws Exception
- {
aes = AntiEntropyService.instance();
}