Fix ViewTest.testCompaction patch by Stefania Alborghetti; reviewed by Marcus Eriksson for CASSANDRA-12789
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/250b5c1d Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/250b5c1d Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/250b5c1d Branch: refs/heads/trunk Commit: 250b5c1db00d7442b52f1b93c77e2c0e55a114cf Parents: 7d3062f Author: Stefania Alborghetti <stefania.alborghe...@datastax.com> Authored: Fri Oct 14 16:55:08 2016 +0800 Committer: Stefania Alborghetti <stefania.alborghe...@datastax.com> Committed: Wed Oct 19 09:43:37 2016 +0800 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/db/lifecycle/ViewTest.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/250b5c1d/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index bd186a1..31e96b9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.0.10 + * 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) http://git-wip-us.apache.org/repos/asf/cassandra/blob/250b5c1d/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java index 7e4ced1..436bf18 100644 --- a/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java +++ b/test/unit/org/apache/cassandra/db/lifecycle/ViewTest.java @@ -83,7 +83,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<SSTableReader> readers = ImmutableList.copyOf(initialView.sstables); Assert.assertTrue(View.permitCompacting(readers).apply(cur)); @@ -133,6 +133,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<View, ?> function, View view) @@ -205,12 +208,17 @@ 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<Memtable> memtables = new ArrayList<>(); List<SSTableReader> 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.<Memtable>emptyList(), Helpers.identityMap(sstables), Collections.<SSTableReader, SSTableReader>emptyMap(), SSTableIntervalTree.build(sstables)); }