cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [1/6] cassandra git commit: Avoid creating dir in DirectoriesTest
Date Thu, 08 Jan 2015 04:14:54 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 1eea31460 -> ad3753309
  refs/heads/cassandra-2.1 dcc90ef35 -> 5ac5ee666
  refs/heads/trunk 12f17b203 -> 9606a17b3


Avoid creating dir in DirectoriesTest

patch by Alan Boudreault; reviewed by yukim for CASSANDRA-6983


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ad375330
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ad375330
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ad375330

Branch: refs/heads/cassandra-2.0
Commit: ad3753309776fb0b7096d15a7535ac76511779e3
Parents: 1eea314
Author: Alan Boudreault <alan@alanb.ca>
Authored: Wed Jan 7 18:34:01 2015 -0600
Committer: Yuki Morishita <yukim@apache.org>
Committed: Wed Jan 7 18:36:01 2015 -0600

----------------------------------------------------------------------
 .../apache/cassandra/db/DirectoriesTest.java    | 22 ++++++++------------
 1 file changed, 9 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ad375330/test/unit/org/apache/cassandra/db/DirectoriesTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/DirectoriesTest.java b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
index 8754fe0..c4471e5 100644
--- a/test/unit/org/apache/cassandra/db/DirectoriesTest.java
+++ b/test/unit/org/apache/cassandra/db/DirectoriesTest.java
@@ -22,6 +22,8 @@ import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.*;
 
+import org.apache.commons.lang3.StringUtils;
+
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -34,6 +36,7 @@ import org.apache.cassandra.db.compaction.LeveledManifest;
 import org.apache.cassandra.io.sstable.Component;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.io.FSWriteError;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -190,15 +193,14 @@ public class DirectoriesTest
         try 
         {
             DatabaseDescriptor.setDiskFailurePolicy(DiskFailurePolicy.best_effort);
-            
-            for (DataDirectory dd : Directories.dataFileLocations)
+            // Fake a Directory creation failure
+            if (Directories.dataFileLocations.length > 0)
             {
-                dd.location.setExecutable(false);
-                dd.location.setWritable(false);
+                String[] path = new String[] {KS, "bad"};
+                File dir = new File(Directories.dataFileLocations[0].location, StringUtils.join(path,
File.separator));
+                FileUtils.handleFSError(new FSWriteError(new IOException("Unable to create
directory " + dir), dir));
             }
-            
-            Directories.create(KS, "bad");
-            
+
             for (DataDirectory dd : Directories.dataFileLocations)
             {
                 File file = new File(dd.location, new File(KS, "bad").getPath());
@@ -207,12 +209,6 @@ public class DirectoriesTest
         } 
         finally 
         {
-            for (DataDirectory dd : Directories.dataFileLocations)
-            {
-                dd.location.setExecutable(true);
-                dd.location.setWritable(true);
-            }
-            
             DatabaseDescriptor.setDiskFailurePolicy(origPolicy);
         }
     }


Mime
View raw message