Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions test/unit/org/apache/cassandra/db/DirectoriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@

import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -65,18 +67,23 @@ public class DirectoriesTest
{
private static File tempDataDir;
private static final String KS = "ks";
private static final String[] TABLES = new String[] { "cf1", "ks" };

private static final Set<TableMetadata> CFM = new HashSet<>(TABLES.length);

private static final Map<String, List<File>> files = new HashMap<>();
private static String[] TABLES;
private static Set<TableMetadata> CFM;
private static Map<String, List<File>> files;

@BeforeClass
public static void beforeClass() throws IOException
public static void beforeClass()
{
DatabaseDescriptor.daemonInitialization();

FileUtils.setFSErrorHandler(new DefaultFSErrorHandler());
}

@Before
public void beforeTest() throws IOException
{
TABLES = new String[] { "cf1", "ks" };
CFM = new HashSet<>(TABLES.length);
files = new HashMap<>();

for (String table : TABLES)
{
Expand All @@ -100,7 +107,7 @@ public static void afterClass()
FileUtils.deleteRecursive(tempDataDir);
}

private static DataDirectory[] toDataDirectories(File location) throws IOException
private static DataDirectory[] toDataDirectories(File location)
{
return new DataDirectory[] { new DataDirectory(location) };
}
Expand Down Expand Up @@ -174,7 +181,7 @@ public void testStandardDirs() throws IOException
}

@Test
public void testSecondaryIndexDirectories() throws IOException
public void testSecondaryIndexDirectories()
{
TableMetadata.Builder builder =
TableMetadata.builder(KS, "cf")
Expand Down Expand Up @@ -208,14 +215,9 @@ public void testSecondaryIndexDirectories() throws IOException
assertEquals(parentSnapshotDirectory, indexSnapshotDirectory.getParentFile());

// check if snapshot directory exists
parentSnapshotDirectory.mkdirs();
assertTrue(parentDirectories.snapshotExists("test"));
assertTrue(indexDirectories.snapshotExists("test"));

// check their creation time
assertEquals(parentDirectories.snapshotCreationTime("test"),
indexDirectories.snapshotCreationTime("test"));

// check true snapshot size
Descriptor parentSnapshot = new Descriptor(parentSnapshotDirectory, KS, PARENT_CFM.name, 0, SSTableFormat.Type.BIG);
createFile(parentSnapshot.filenameFor(Component.DATA), 30);
Expand Down Expand Up @@ -253,7 +255,7 @@ private File createFile(String fileName, int size)
}

@Test
public void testSSTableLister() throws IOException
public void testSSTableLister()
{
for (TableMetadata cfm : CFM)
{
Expand Down Expand Up @@ -622,7 +624,7 @@ private void testDirectoriesSymlinksHelper(boolean oldStyle) throws IOException
}

@Test
public void testIsStoredInLocalSystemKeyspacesDataLocation() throws IOException
public void testIsStoredInLocalSystemKeyspacesDataLocation()
{
for (String table : SystemKeyspace.TABLES_SPLIT_ACROSS_MULTIPLE_DISKS)
{
Expand Down