diff --git a/CHANGES.txt b/CHANGES.txt index 9c39e6f47d..30caf4fe36 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -86,6 +86,7 @@ * Restore resumable hints delivery (CASSANDRA-11960) * Properly report LWT contention (CASSANDRA-12626) Merged from 3.0: + * Fix ViewTest.testCompaction (CASSANDRA-12789) * Improve avg aggregate functions (CASSANDRA-12417) * Preserve quoted reserved keyword column names in MV creation (CASSANDRA-11803) * nodetool stopdaemon errors out (CASSANDRA-12646) diff --git a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java index 229f72c5b4..a0e6e5f8f0 100644 --- a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java +++ b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java @@ -86,7 +86,7 @@ public class ViewTest public void testCompaction() { ColumnFamilyStore cfs = MockSchema.newCFS(); - View initialView = fakeView(0, 5, cfs); + View initialView = fakeView(0, 5, cfs, true); View cur = initialView; List readers = ImmutableList.copyOf(initialView.sstables); Assert.assertTrue(View.permitCompacting(readers).apply(cur)); @@ -136,6 +136,9 @@ public class ViewTest Assert.assertTrue(nonCompacting.containsAll(readers.subList(2, 5))); Assert.assertTrue(nonCompacting.containsAll(readers.subList(0, 1))); Assert.assertEquals(4, nonCompacting.size()); + + for (SSTableReader sstable : initialView.sstables) + sstable.selfRef().release(); } private static void testFailure(Function function, View view) @@ -207,13 +210,18 @@ public class ViewTest } static View fakeView(int memtableCount, int sstableCount, ColumnFamilyStore cfs) + { + return fakeView(memtableCount, sstableCount, cfs, false); + } + + static View fakeView(int memtableCount, int sstableCount, ColumnFamilyStore cfs, boolean keepRef) { List memtables = new ArrayList<>(); List sstables = new ArrayList<>(); for (int i = 0 ; i < memtableCount ; i++) memtables.add(MockSchema.memtable(cfs)); for (int i = 0 ; i < sstableCount ; i++) - sstables.add(MockSchema.sstable(i, cfs)); + sstables.add(MockSchema.sstable(i, keepRef, cfs)); return new View(ImmutableList.copyOf(memtables), Collections.emptyList(), Helpers.identityMap(sstables), Collections.emptyMap(), SSTableIntervalTree.build(sstables)); }