Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
wi11dey committed Nov 13, 2024
1 parent a688efd commit 659a880
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
Expand Down Expand Up @@ -118,6 +120,7 @@ public class ColumnFamilyStoreTest
public static final String CF_STANDARD5 = "Standard5";
public static final String CF_STANDARD6 = "Standard6";
public static final String CF_STANDARD7 = "Standard7";
public static final String CF_STANDARD8 = "Standard8";
public static final String CF_STANDARDINT = "StandardInteger1";
public static final String CF_SUPER1 = "Super1";
public static final String CF_SUPER6 = "Super6";
Expand Down Expand Up @@ -148,6 +151,7 @@ public static void defineSchema() throws ConfigurationException
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD5),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD6),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD7),
SchemaLoader.standardCFMD(KEYSPACE1, CF_STANDARD8),
SchemaLoader.indexCFMD(KEYSPACE1, CF_INDEX1, true),
SchemaLoader.indexCFMD(KEYSPACE1, CF_INDEX2, false),
SchemaLoader.superCFMD(KEYSPACE1, CF_SUPER1, LongType.instance),
Expand Down Expand Up @@ -2002,6 +2006,38 @@ public void testRemoveUnusedSstablesOnlyRemovesFiltered() throws IOException
assertEquals(expected, sstables.keySet());
}

@Test
public void testRemoveUnusedSstablesDoesNotTouchProductsWhenAncestorDoesNotExist() throws IOException
{
final String ks = KEYSPACE1;
final String cf = CF_STANDARD8;

final CFMetaData cfmeta = Schema.instance.getCFMetaData(ks, cf);
Keyspace.open(KEYSPACE1).getColumnFamilyStore(cf).disableAutoCompaction();
Directories dir = new Directories(cfmeta);

int gen1 = writeNextGenerationSstable(ImmutableSet.of(), dir, cfmeta);
int gen2 = writeNextGenerationSstable(ImmutableSet.of(), dir, cfmeta);
int gen3 = writeNextGenerationSstable(ImmutableSet.of(gen1, gen2), dir, cfmeta);
int gen4 = writeNextGenerationSstable(ImmutableSet.of(), dir, cfmeta);
int gen5 = writeNextGenerationSstable(ImmutableSet.of(gen4), dir, cfmeta);

Map<Descriptor, Set<Component>> sstables = dir.sstableLister().list();
Descriptor sstable3Desc = sstables.keySet().iterator().next().withGeneration(gen3);
assertEquals(5, sstables.size());
assertTrue(sstables.containsKey(sstable3Desc));

Files.delete(Paths.get(sstables.keySet().iterator().next().withGeneration(gen3).filenameFor(Component.DATA)));

ColumnFamilyStore.removeUnusedSstables(cfmeta, ImmutableMap.of());

sstables = dir.sstableLister().list();
ImmutableSet<Descriptor> products = ImmutableSet.of(
sstable3Desc.withGeneration(gen3),
sstable3Desc.withGeneration(gen5));
assertTrue(sstables.keySet().containsAll(products));
}

@Test
public void testLoadNewSSTablesAvoidsOverwrites() throws Throwable
{
Expand Down

0 comments on commit 659a880

Please sign in to comment.