This is an automated email from the ASF dual-hosted git repository.
jmckenzie pushed a commit to branch cassandra-4.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-4.0 by this push:
new f2816f5 Better isolate tests from each other in SSTableReaderTest
f2816f5 is described below
commit f2816f5a7cd0e0416870bb21b8cec8f26c05d1f7
Author: Josh McKenzie <[email protected]>
AuthorDate: Thu Feb 3 14:35:52 2022 -0500
Better isolate tests from each other in SSTableReaderTest
Patch by Josh McKenzie; reviewed by Aleksei Zotov and Jeremiah Jordan for
CASSANDRA-17078
---
.../cassandra/io/sstable/SSTableReaderTest.java | 75 +++++++++-------------
1 file changed, 29 insertions(+), 46 deletions(-)
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
b/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
index f1fc4cb..1246130 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
@@ -69,6 +69,8 @@ public class SSTableReaderTest
public static final String KEYSPACE1 = "SSTableReaderTest";
public static final String CF_STANDARD = "Standard1";
public static final String CF_STANDARD2 = "Standard2";
+ public static final String CF_STANDARD3 = "Standard3";
+ public static final String CF_MOVE_AND_OPEN = "MoveAndOpen";
public static final String CF_COMPRESSED = "Compressed";
public static final String CF_INDEXED = "Indexed1";
public static final String CF_STANDARD_LOW_INDEX_INTERVAL =
"StandardLowIndexInterval";
@@ -89,6 +91,8 @@ public class SSTableReaderTest
KeyspaceParams.simple(1),
SchemaLoader.standardCFMD(KEYSPACE1,
CF_STANDARD),
SchemaLoader.standardCFMD(KEYSPACE1,
CF_STANDARD2),
+ SchemaLoader.standardCFMD(KEYSPACE1,
CF_STANDARD3),
+ SchemaLoader.standardCFMD(KEYSPACE1,
CF_MOVE_AND_OPEN),
SchemaLoader.standardCFMD(KEYSPACE1,
CF_COMPRESSED).compression(CompressionParams.DEFAULT),
SchemaLoader.compositeIndexCFMD(KEYSPACE1,
CF_INDEXED, true),
SchemaLoader.standardCFMD(KEYSPACE1,
CF_STANDARD_LOW_INDEX_INTERVAL)
@@ -107,9 +111,7 @@ public class SSTableReaderTest
@Test
public void testGetPositionsForRanges()
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD2);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD2);
partitioner = store.getPartitioner();
// insert data and compact to a single sstable
@@ -153,9 +155,7 @@ public class SSTableReaderTest
try
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store =
keyspace.getColumnFamilyStore(CF_STANDARD);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD);
partitioner = store.getPartitioner();
// insert a bunch of data and compact to a single sstable
@@ -196,10 +196,7 @@ public class SSTableReaderTest
@Test
public void testPersistentStatistics()
{
-
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD3);
partitioner = store.getPartitioner();
for (int j = 0; j < 100; j += 2)
@@ -226,9 +223,7 @@ public class SSTableReaderTest
public void testReadRateTracking()
{
// try to make sure CASSANDRA-8239 never happens again
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD);
partitioner = store.getPartitioner();
for (int j = 0; j < 10; j++)
@@ -256,9 +251,7 @@ public class SSTableReaderTest
@Test
public void testGetPositionsForRangesWithKeyCache()
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD2);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD2);
partitioner = store.getPartitioner();
CacheService.instance.keyCache.setCapacity(100);
@@ -295,9 +288,7 @@ public class SSTableReaderTest
public void testPersistentStatisticsWithSecondaryIndex()
{
// Create secondary index and flush to disk
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_INDEXED);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_INDEXED);
partitioner = store.getPartitioner();
new RowUpdateBuilder(store.metadata(), System.currentTimeMillis(),
"k1")
@@ -315,9 +306,7 @@ public class SSTableReaderTest
@Test
public void testGetPositionsKeyCacheStats()
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD2);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD2);
partitioner = store.getPartitioner();
CacheService.instance.keyCache.setCapacity(1000);
@@ -525,9 +514,7 @@ public class SSTableReaderTest
@Test
public void testLoadingSummaryUsesCorrectPartitioner()
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_INDEXED);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_INDEXED);
new RowUpdateBuilder(store.metadata(), System.currentTimeMillis(),
"k1")
.clustering("0")
@@ -554,9 +541,7 @@ public class SSTableReaderTest
@Test
public void testGetScannerForNoIntersectingRanges() throws Exception
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD);
partitioner = store.getPartitioner();
new RowUpdateBuilder(store.metadata(), 0, "k1")
@@ -581,9 +566,7 @@ public class SSTableReaderTest
@Test
public void testGetPositionsForRangesFromTableOpenedForBulkLoading()
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store = keyspace.getColumnFamilyStore(CF_STANDARD2);
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD2);
partitioner = store.getPartitioner();
// insert data and compact to a single sstable. The
@@ -624,9 +607,7 @@ public class SSTableReaderTest
@Test
public void testIndexSummaryReplacement() throws IOException,
ExecutionException, InterruptedException
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store =
keyspace.getColumnFamilyStore(CF_STANDARD_LOW_INDEX_INTERVAL); // index
interval of 8, no key caching
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1,
CF_STANDARD_LOW_INDEX_INTERVAL); // index interval of 8, no key caching
final int NUM_PARTITIONS = 512;
for (int j = 0; j < NUM_PARTITIONS; j++)
@@ -703,9 +684,7 @@ public class SSTableReaderTest
private void testIndexSummaryUpsampleAndReload0() throws Exception
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore store =
keyspace.getColumnFamilyStore(CF_STANDARD_LOW_INDEX_INTERVAL); // index
interval of 8, no key caching
- store.discardSSTables(System.currentTimeMillis());
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1,
CF_STANDARD_LOW_INDEX_INTERVAL); // index interval of 8, no key caching
final int NUM_PARTITIONS = 512;
for (int j = 0; j < NUM_PARTITIONS; j++)
@@ -790,7 +769,7 @@ public class SSTableReaderTest
public void testMoveAndOpenSSTable() throws IOException
{
Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARD);
+ ColumnFamilyStore cfs =
keyspace.getColumnFamilyStore(CF_MOVE_AND_OPEN);
SSTableReader sstable = getNewSSTable(cfs);
cfs.clearUnsafe();
sstable.selfRef().release();
@@ -816,8 +795,6 @@ public class SSTableReaderTest
}
}
-
-
private SSTableReader getNewSSTable(ColumnFamilyStore cfs)
{
Set<SSTableReader> before = cfs.getLiveSSTables();
@@ -836,14 +813,12 @@ public class SSTableReaderTest
@Test
public void testGetApproximateKeyCount() throws InterruptedException
{
- Keyspace keyspace = Keyspace.open(KEYSPACE1);
- ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(CF_STANDARD);
- cfs.discardSSTables(System.currentTimeMillis());
- getNewSSTable(cfs);
+ ColumnFamilyStore store = discardSSTables(KEYSPACE1, CF_STANDARD);
+ getNewSSTable(store);
- try (ColumnFamilyStore.RefViewFragment viewFragment1 =
cfs.selectAndReference(View.selectFunction(SSTableSet.CANONICAL)))
+ try (ColumnFamilyStore.RefViewFragment viewFragment1 =
store.selectAndReference(View.selectFunction(SSTableSet.CANONICAL)))
{
- cfs.discardSSTables(System.currentTimeMillis());
+ store.discardSSTables(System.currentTimeMillis());
TimeUnit.MILLISECONDS.sleep(1000); //Giving enough time to clear
files.
List<SSTableReader> sstables = new
ArrayList<>(viewFragment1.sstables);
@@ -910,4 +885,12 @@ public class SSTableReaderTest
assertTrue("TOC file should exist", tocFile.exists());
return desc;
}
+
+ private ColumnFamilyStore discardSSTables(String ks, String cf)
+ {
+ Keyspace keyspace = Keyspace.open(ks);
+ ColumnFamilyStore cfs = keyspace.getColumnFamilyStore(cf);
+ cfs.discardSSTables(System.currentTimeMillis());
+ return cfs;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]