From 273c53831faede08b6f539ea80517a454ab50a3a Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Thu, 14 Jul 2011 14:32:16 +0000 Subject: [PATCH] add test for including supercolumn tombstone time in max timestamp computation patch by Daniel Doubleday; reviewed by jbellis for CASSANDRA-2753 git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1146732 13f79535-47bb-0310-9956-ffa450edef68 --- .../io/sstable/SSTableWriterTest.java | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java index 313a785a17..9b9c4872cc 100644 --- a/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java +++ b/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java @@ -21,16 +21,15 @@ package org.apache.cassandra.io.sstable; */ +import static org.apache.cassandra.Util.addMutation; import static org.junit.Assert.*; import java.io.IOException; import java.nio.ByteBuffer; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ExecutionException; +import org.apache.cassandra.Util; import org.junit.Test; import org.apache.cassandra.CleanupHelper; @@ -137,4 +136,38 @@ public class SSTableWriterTest extends CleanupHelper { // ensure max timestamp is captured during rebuild assert sstr.getMaxTimestamp() == 4321L; } + + @Test + public void testSuperColumnMaxTimestamp() throws IOException, ExecutionException, InterruptedException + { + ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super1"); + RowMutation rm; + DecoratedKey dk = Util.dk("key1"); + + // add data + rm = new RowMutation("Keyspace1", dk.key); + addMutation(rm, "Super1", "SC1", 1, "val1", 0); + rm.apply(); + store.forceBlockingFlush(); + + validateMinTimeStamp(store.getSSTables(), 0); + + // remove + rm = new RowMutation("Keyspace1", dk.key); + rm.delete(new QueryPath("Super1", ByteBufferUtil.bytes("SC1")), 1); + rm.apply(); + store.forceBlockingFlush(); + + validateMinTimeStamp(store.getSSTables(), 0); + + CompactionManager.instance.performMaximal(store); + assertEquals(1, store.getSSTables().size()); + validateMinTimeStamp(store.getSSTables(), 1); + } + + private void validateMinTimeStamp(Collection ssTables, int timestamp) + { + for (SSTableReader ssTable : ssTables) + assertTrue(ssTable.getMaxTimestamp() >= timestamp); + } }