expose failing test by moving it where other tests are not covering it up somehow. patch by jbellis

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@900964 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2010-01-19 21:23:08 +00:00
parent af9b7681e4
commit 3e06414b61
2 changed files with 134 additions and 91 deletions

View File

@ -0,0 +1,134 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.cassandra.db;
import java.io.IOException;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.junit.Test;
import org.apache.cassandra.CleanupHelper;
import org.apache.cassandra.db.filter.IdentityQueryFilter;
import org.apache.cassandra.db.filter.QueryPath;
import org.apache.cassandra.io.SSTableReader;
import org.apache.cassandra.utils.FBUtilities;
import static junit.framework.Assert.assertEquals;
public class CompactionsPurgeTest extends CleanupHelper
{
public static final String TABLE1 = "Keyspace1";
@Test
public void testCompactionPurge() throws IOException, ExecutionException, InterruptedException
{
CompactionManager.instance.disableAutoCompaction();
Table table = Table.open(TABLE1);
String cfName = "Standard1";
ColumnFamilyStore store = table.getColumnFamilyStore(cfName);
String key = "key1";
RowMutation rm;
// inserts
rm = new RowMutation(TABLE1, key);
for (int i = 0; i < 10; i++)
{
rm.add(new QueryPath(cfName, null, String.valueOf(i).getBytes()), new byte[0], 0);
}
rm.apply();
store.forceBlockingFlush();
// deletes
for (int i = 0; i < 10; i++)
{
rm = new RowMutation(TABLE1, key);
rm.delete(new QueryPath(cfName, null, String.valueOf(i).getBytes()), 1);
rm.apply();
}
store.forceBlockingFlush();
// resurrect one column
rm = new RowMutation(TABLE1, key);
rm.add(new QueryPath(cfName, null, String.valueOf(5).getBytes()), new byte[0], 2);
rm.apply();
store.forceBlockingFlush();
// verify that non-major compaction does no GC to ensure correctness (see CASSANDRA-604)
Collection<SSTableReader> sstablesIncomplete = store.getSSTables();
rm = new RowMutation(TABLE1, key + "x");
rm.add(new QueryPath(cfName, null, "0".getBytes()), new byte[0], 0);
rm.apply();
store.forceBlockingFlush();
CompactionManager.instance.doCompaction(store, sstablesIncomplete, CompactionManager.getDefaultGCBefore());
ColumnFamily cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key, new QueryPath(cfName)));
assert cf.getColumnCount() == 10;
// major compact and test that all columns but the resurrected one is completely gone
CompactionManager.instance.submitMajor(store, 0, Integer.MAX_VALUE).get();
cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key, new QueryPath(cfName)));
assert cf.getColumnCount() == 1;
assert cf.getColumn(String.valueOf(5).getBytes()) != null;
}
@Test
public void testCompactionPurgeOneFile() throws IOException, ExecutionException, InterruptedException
{
CompactionManager.instance.disableAutoCompaction();
Table table = Table.open(TABLE1);
String cfName = "Standard2";
ColumnFamilyStore store = table.getColumnFamilyStore(cfName);
String key = "key1";
RowMutation rm;
// inserts
rm = new RowMutation(TABLE1, key);
for (int i = 0; i < 5; i++)
{
rm.add(new QueryPath(cfName, null, String.valueOf(i).getBytes()), new byte[0], 0);
}
rm.apply();
// deletes
for (int i = 0; i < 5; i++)
{
rm = new RowMutation(TABLE1, key);
rm.delete(new QueryPath(cfName, null, String.valueOf(i).getBytes()), 1);
rm.apply();
}
store.forceBlockingFlush();
assert store.getSSTables().size() == 1 : store.getSSTables(); // inserts & deletes were in the same memtable -> only deletes in sstable
// compact and test that the row is completely gone
CompactionManager.instance.submitMajor(store, 0, Integer.MAX_VALUE).get();
assert store.getSSTables().isEmpty();
ColumnFamily cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key, new QueryPath(cfName)));
assert cf == null : cf;
}
}

View File

@ -77,97 +77,6 @@ public class CompactionsTest extends CleanupHelper
assertEquals(inserted.size(), table.getColumnFamilyStore("Standard1").getKeyRange("", "", 10000).keys.size());
}
@Test
public void testCompactionPurge() throws IOException, ExecutionException, InterruptedException
{
CompactionManager.instance.disableAutoCompaction();
Table table = Table.open(TABLE1);
String cfName = "Standard1";
ColumnFamilyStore store = table.getColumnFamilyStore(cfName);
String key = "key1";
RowMutation rm;
// inserts
rm = new RowMutation(TABLE1, key);
for (int i = 0; i < 10; i++)
{
rm.add(new QueryPath(cfName, null, String.valueOf(i).getBytes()), new byte[0], 0);
}
rm.apply();
store.forceBlockingFlush();
// deletes
for (int i = 0; i < 10; i++)
{
rm = new RowMutation(TABLE1, key);
rm.delete(new QueryPath(cfName, null, String.valueOf(i).getBytes()), 1);
rm.apply();
}
store.forceBlockingFlush();
// resurrect one column
rm = new RowMutation(TABLE1, key);
rm.add(new QueryPath(cfName, null, String.valueOf(5).getBytes()), new byte[0], 2);
rm.apply();
store.forceBlockingFlush();
// verify that non-major compaction does no GC to ensure correctness (see CASSANDRA-604)
Collection<SSTableReader> sstablesIncomplete = store.getSSTables();
rm = new RowMutation(TABLE1, key + "x");
rm.add(new QueryPath(cfName, null, "0".getBytes()), new byte[0], 0);
rm.apply();
store.forceBlockingFlush();
CompactionManager.instance.doCompaction(store, sstablesIncomplete, CompactionManager.getDefaultGCBefore());
ColumnFamily cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key, new QueryPath(cfName)));
assert cf.getColumnCount() == 10;
// major compact and test that all columns but the resurrected one is completely gone
CompactionManager.instance.submitMajor(store, 0, Integer.MAX_VALUE).get();
cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key, new QueryPath(cfName)));
assert cf.getColumnCount() == 1;
assert cf.getColumn(String.valueOf(5).getBytes()) != null;
}
@Test
public void testCompactionPurgeOneFile() throws IOException, ExecutionException, InterruptedException
{
CompactionManager.instance.disableAutoCompaction();
Table table = Table.open(TABLE1);
String cfName = "Standard2";
ColumnFamilyStore store = table.getColumnFamilyStore(cfName);
String key = "key1";
RowMutation rm;
// inserts
rm = new RowMutation(TABLE1, key);
for (int i = 0; i < 5; i++)
{
rm.add(new QueryPath(cfName, null, String.valueOf(i).getBytes()), new byte[0], 0);
}
rm.apply();
// deletes
for (int i = 0; i < 5; i++)
{
rm = new RowMutation(TABLE1, key);
rm.delete(new QueryPath(cfName, null, String.valueOf(i).getBytes()), 1);
rm.apply();
}
store.forceBlockingFlush();
assert store.getSSTables().size() == 1 : store.getSSTables(); // inserts & deletes were in the same memtable -> only deletes in sstable
// compact and test that the row is completely gone
CompactionManager.instance.submitMajor(store, 0, Integer.MAX_VALUE).get();
assert store.getSSTables().isEmpty();
ColumnFamily cf = table.getColumnFamilyStore(cfName).getColumnFamily(new IdentityQueryFilter(key, new QueryPath(cfName)));
assert cf == null : cf;
}
@Test
public void testCompactionReadonly() throws IOException, ExecutionException, InterruptedException
{