Search in sources :

Example 21 with Verifier

use of org.apache.cassandra.db.compaction.Verifier in project cassandra by apache.

the class LegacySSTableTest method testVerifyOldSSTables.

@Test
public void testVerifyOldSSTables() throws IOException {
    for (String legacyVersion : legacyVersions) {
        ColumnFamilyStore cfs = Keyspace.open("legacy_tables").getColumnFamilyStore(String.format("legacy_%s_simple", legacyVersion));
        loadLegacyTable("legacy_%s_simple", legacyVersion);
        for (SSTableReader sstable : cfs.getLiveSSTables()) {
            try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().checkVersion(true).build())) {
                verifier.verify();
                if (!sstable.descriptor.version.isLatestVersion())
                    fail("Verify should throw RuntimeException for old sstables " + sstable);
            } catch (RuntimeException e) {
            }
        }
        // make sure we don't throw any exception if not checking version:
        for (SSTableReader sstable : cfs.getLiveSSTables()) {
            try (Verifier verifier = new Verifier(cfs, sstable, false, Verifier.options().checkVersion(false).build())) {
                verifier.verify();
            } catch (Throwable e) {
                fail("Verify should throw RuntimeException for old sstables " + sstable);
            }
        }
    }
}
Also used : SSTableReader(org.apache.cassandra.io.sstable.format.SSTableReader) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) Verifier(org.apache.cassandra.db.compaction.Verifier) SinglePartitionSliceCommandTest(org.apache.cassandra.db.SinglePartitionSliceCommandTest) Test(org.junit.Test)

Aggregations

Verifier (org.apache.cassandra.db.compaction.Verifier)21 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)21 Test (org.junit.Test)18 SchemaLoader.createKeyspace (org.apache.cassandra.SchemaLoader.createKeyspace)17 CorruptSSTableException (org.apache.cassandra.io.sstable.CorruptSSTableException)15 File (org.apache.cassandra.io.util.File)8 RandomAccessReader (org.apache.cassandra.io.util.RandomAccessReader)4 FileChannel (java.nio.channels.FileChannel)3 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)2 ByteOrderedPartitioner (org.apache.cassandra.dht.ByteOrderedPartitioner)2 TokenMetadata (org.apache.cassandra.locator.TokenMetadata)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1