@ -78,6 +78,7 @@ static long TestGetTickerCount(const Options& options, Tickers ticker_type) {
return options . statistics - > getTickerCount ( ticker_type ) ;
return options . statistics - > getTickerCount ( ticker_type ) ;
}
}
# ifndef ROCKSDB_LITE
// A helper function that ensures the table properties returned in
// A helper function that ensures the table properties returned in
// `GetPropertiesOfAllTablesTest` is correct.
// `GetPropertiesOfAllTablesTest` is correct.
// This test assumes entries size is different for each of the tables.
// This test assumes entries size is different for each of the tables.
@ -113,6 +114,7 @@ uint64_t GetNumberOfSstFilesForColumnFamily(DB* db,
}
}
} // namespace
} // namespace
# endif // ROCKSDB_LITE
class DBTest : public DBTestBase {
class DBTest : public DBTestBase {
public :
public :
@ -131,46 +133,7 @@ class DBTestWithParam : public DBTest,
uint32_t max_subcompactions_ ;
uint32_t max_subcompactions_ ;
} ;
} ;
class BloomStatsTestWithParam
# ifndef ROCKSDB_LITE
: public DBTest ,
public testing : : WithParamInterface < std : : tuple < bool , bool > > {
public :
BloomStatsTestWithParam ( ) {
use_block_table_ = std : : get < 0 > ( GetParam ( ) ) ;
use_block_based_builder_ = std : : get < 1 > ( GetParam ( ) ) ;
options_ . create_if_missing = true ;
options_ . prefix_extractor . reset ( rocksdb : : NewFixedPrefixTransform ( 4 ) ) ;
options_ . memtable_prefix_bloom_bits = 8 * 1024 ;
if ( use_block_table_ ) {
BlockBasedTableOptions table_options ;
table_options . hash_index_allow_collision = false ;
table_options . filter_policy . reset (
NewBloomFilterPolicy ( 10 , use_block_based_builder_ ) ) ;
options_ . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ;
} else {
PlainTableOptions table_options ;
options_ . table_factory . reset ( NewPlainTableFactory ( table_options ) ) ;
}
perf_context . Reset ( ) ;
DestroyAndReopen ( options_ ) ;
}
~ BloomStatsTestWithParam ( ) {
perf_context . Reset ( ) ;
Destroy ( options_ ) ;
}
// Required if inheriting from testing::WithParamInterface<>
static void SetUpTestCase ( ) { }
static void TearDownTestCase ( ) { }
bool use_block_table_ ;
bool use_block_based_builder_ ;
Options options_ ;
} ;
TEST_F ( DBTest , Empty ) {
TEST_F ( DBTest , Empty ) {
do {
do {
Options options ;
Options options ;
@ -232,6 +195,7 @@ TEST_F(DBTest, Empty) {
ASSERT_EQ ( " 0 " , num ) ;
ASSERT_EQ ( " 0 " , num ) ;
} while ( ChangeOptions ( ) ) ;
} while ( ChangeOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , WriteEmptyBatch ) {
TEST_F ( DBTest , WriteEmptyBatch ) {
Options options ;
Options options ;
@ -254,6 +218,7 @@ TEST_F(DBTest, WriteEmptyBatch) {
ASSERT_EQ ( " bar " , Get ( 1 , " foo " ) ) ;
ASSERT_EQ ( " bar " , Get ( 1 , " foo " ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , ReadOnlyDB ) {
TEST_F ( DBTest , ReadOnlyDB ) {
ASSERT_OK ( Put ( " foo " , " v1 " ) ) ;
ASSERT_OK ( Put ( " foo " , " v1 " ) ) ;
ASSERT_OK ( Put ( " bar " , " v2 " ) ) ;
ASSERT_OK ( Put ( " bar " , " v2 " ) ) ;
@ -790,6 +755,7 @@ TEST_F(DBTest, AggregatedTablePropertiesAtLevel) {
}
}
}
}
}
}
# endif // ROCKSDB_LITE
class CoutingUserTblPropCollector : public TablePropertiesCollector {
class CoutingUserTblPropCollector : public TablePropertiesCollector {
public :
public :
@ -842,6 +808,7 @@ class CoutingUserTblPropCollectorFactory
uint32_t num_created_ ;
uint32_t num_created_ ;
} ;
} ;
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , GetUserDefinedTableProperties ) {
TEST_F ( DBTest , GetUserDefinedTableProperties ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . level0_file_num_compaction_trigger = ( 1 < < 30 ) ;
options . level0_file_num_compaction_trigger = ( 1 < < 30 ) ;
@ -881,6 +848,7 @@ TEST_F(DBTest, GetUserDefinedTableProperties) {
dbfull ( ) - > TEST_CompactRange ( 0 , nullptr , nullptr ) ;
dbfull ( ) - > TEST_CompactRange ( 0 , nullptr , nullptr ) ;
ASSERT_GT ( collector_factory - > num_created_ , 0 ) ;
ASSERT_GT ( collector_factory - > num_created_ , 0 ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , UserDefinedTablePropertiesContext ) {
TEST_F ( DBTest , UserDefinedTablePropertiesContext ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -943,6 +911,7 @@ TEST_F(DBTest, UserDefinedTablePropertiesContext) {
ASSERT_GT ( collector_factory - > num_created_ , 0 ) ;
ASSERT_GT ( collector_factory - > num_created_ , 0 ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , LevelLimitReopen ) {
TEST_F ( DBTest , LevelLimitReopen ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
CreateAndReopenWithCF ( { " pikachu " } , options ) ;
CreateAndReopenWithCF ( { " pikachu " } , options ) ;
@ -964,6 +933,7 @@ TEST_F(DBTest, LevelLimitReopen) {
options . max_bytes_for_level_multiplier_additional . resize ( 10 , 1 ) ;
options . max_bytes_for_level_multiplier_additional . resize ( 10 , 1 ) ;
ASSERT_OK ( TryReopenWithColumnFamilies ( { " default " , " pikachu " } , options ) ) ;
ASSERT_OK ( TryReopenWithColumnFamilies ( { " default " , " pikachu " } , options ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , PutDeleteGet ) {
TEST_F ( DBTest , PutDeleteGet ) {
do {
do {
@ -1110,6 +1080,7 @@ TEST_F(DBTest, GetFromVersions) {
} while ( ChangeOptions ( ) ) ;
} while ( ChangeOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , GetSnapshot ) {
TEST_F ( DBTest , GetSnapshot ) {
anon : : OptionsOverride options_override ;
anon : : OptionsOverride options_override ;
options_override . skip_policy = kSkipNoSnapshot ;
options_override . skip_policy = kSkipNoSnapshot ;
@ -1135,6 +1106,7 @@ TEST_F(DBTest, GetSnapshot) {
}
}
} while ( ChangeOptions ( ) ) ;
} while ( ChangeOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , GetLevel0Ordering ) {
TEST_F ( DBTest , GetLevel0Ordering ) {
do {
do {
@ -1162,6 +1134,7 @@ TEST_F(DBTest, WrongLevel0Config) {
ASSERT_OK ( DB : : Open ( options , dbname_ , & db_ ) ) ;
ASSERT_OK ( DB : : Open ( options , dbname_ , & db_ ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , GetOrderedByLevels ) {
TEST_F ( DBTest , GetOrderedByLevels ) {
do {
do {
CreateAndReopenWithCF ( { " pikachu " } , CurrentOptions ( ) ) ;
CreateAndReopenWithCF ( { " pikachu " } , CurrentOptions ( ) ) ;
@ -1233,6 +1206,7 @@ TEST_F(DBTest, GetEncountersEmptyLevel) {
ASSERT_EQ ( NumTableFilesAtLevel ( 0 , 1 ) , 1 ) ; // XXX
ASSERT_EQ ( NumTableFilesAtLevel ( 0 , 1 ) , 1 ) ; // XXX
} while ( ChangeOptions ( kSkipUniversalCompaction | kSkipFIFOCompaction ) ) ;
} while ( ChangeOptions ( kSkipUniversalCompaction | kSkipFIFOCompaction ) ) ;
}
}
# endif // ROCKSDB_LITE
// KeyMayExist can lead to a few false positives, but not false negatives.
// KeyMayExist can lead to a few false positives, but not false negatives.
// To make test deterministic, use a much larger number of bits per key-20 than
// To make test deterministic, use a much larger number of bits per key-20 than
@ -1365,6 +1339,7 @@ TEST_F(DBTest, NonBlockingIteration) {
kSkipMmapReads ) ) ;
kSkipMmapReads ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , ManagedNonBlockingIteration ) {
TEST_F ( DBTest , ManagedNonBlockingIteration ) {
do {
do {
ReadOptions non_blocking_opts , regular_opts ;
ReadOptions non_blocking_opts , regular_opts ;
@ -1429,6 +1404,7 @@ TEST_F(DBTest, ManagedNonBlockingIteration) {
} while ( ChangeOptions ( kSkipPlainTable | kSkipNoSeekToLast | kSkipHashCuckoo |
} while ( ChangeOptions ( kSkipPlainTable | kSkipNoSeekToLast | kSkipHashCuckoo |
kSkipMmapReads ) ) ;
kSkipMmapReads ) ) ;
}
}
# endif // ROCKSDB_LITE
// A delete is skipped for key if KeyMayExist(key) returns False
// A delete is skipped for key if KeyMayExist(key) returns False
// Tests Writebatch consistency and proper delete behaviour
// Tests Writebatch consistency and proper delete behaviour
@ -2333,6 +2309,7 @@ TEST_F(DBTest, FlushMultipleMemtable) {
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , NumImmutableMemTable ) {
TEST_F ( DBTest , NumImmutableMemTable ) {
do {
do {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -2442,6 +2419,7 @@ TEST_F(DBTest, NumImmutableMemTable) {
ASSERT_TRUE ( GetPerfLevel ( ) = = kDisable ) ;
ASSERT_TRUE ( GetPerfLevel ( ) = = kDisable ) ;
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , FlushEmptyColumnFamily ) {
TEST_F ( DBTest , FlushEmptyColumnFamily ) {
// Block flush thread and disable compaction thread
// Block flush thread and disable compaction thread
@ -2487,6 +2465,7 @@ TEST_F(DBTest, FlushEmptyColumnFamily) {
sleeping_task_low . WaitUntilDone ( ) ;
sleeping_task_low . WaitUntilDone ( ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , GetProperty ) {
TEST_F ( DBTest , GetProperty ) {
// Set sizes to both background thread pool to be 1 and block them.
// Set sizes to both background thread pool to be 1 and block them.
env_ - > SetBackgroundThreads ( 1 , Env : : HIGH ) ;
env_ - > SetBackgroundThreads ( 1 , Env : : HIGH ) ;
@ -2792,6 +2771,7 @@ TEST_F(DBTest, EstimatePendingCompBytes) {
" rocksdb.estimate-pending-compaction-bytes " , & int_num ) ) ;
" rocksdb.estimate-pending-compaction-bytes " , & int_num ) ) ;
ASSERT_EQ ( int_num , 0U ) ;
ASSERT_EQ ( int_num , 0U ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , FLUSH ) {
TEST_F ( DBTest , FLUSH ) {
do {
do {
@ -2851,7 +2831,7 @@ TEST_F(DBTest, RecoveryWithEmptyLog) {
} while ( ChangeOptions ( ) ) ;
} while ( ChangeOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , FlushSchedule ) {
TEST_F ( DBTest , FlushSchedule ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . disable_auto_compactions = true ;
options . disable_auto_compactions = true ;
@ -2892,7 +2872,7 @@ TEST_F(DBTest, FlushSchedule) {
ASSERT_LE ( pikachu_tables , static_cast < uint64_t > ( 10 ) ) ;
ASSERT_LE ( pikachu_tables , static_cast < uint64_t > ( 10 ) ) ;
ASSERT_GT ( pikachu_tables , static_cast < uint64_t > ( 0 ) ) ;
ASSERT_GT ( pikachu_tables , static_cast < uint64_t > ( 0 ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , ManifestRollOver ) {
TEST_F ( DBTest , ManifestRollOver ) {
do {
do {
@ -2940,6 +2920,7 @@ TEST_F(DBTest, IdentityAcrossRestarts) {
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , RecoverWithLargeLog ) {
TEST_F ( DBTest , RecoverWithLargeLog ) {
do {
do {
{
{
@ -2966,6 +2947,7 @@ TEST_F(DBTest, RecoverWithLargeLog) {
ASSERT_GT ( NumTableFilesAtLevel ( 0 , 1 ) , 1 ) ;
ASSERT_GT ( NumTableFilesAtLevel ( 0 , 1 ) , 1 ) ;
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
namespace {
namespace {
class KeepFilter : public CompactionFilter {
class KeepFilter : public CompactionFilter {
@ -3030,6 +3012,7 @@ class DelayFilterFactory : public CompactionFilterFactory {
} ;
} ;
} // namespace
} // namespace
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , CompressedCache ) {
TEST_F ( DBTest , CompressedCache ) {
if ( ! Snappy_Supported ( ) ) {
if ( ! Snappy_Supported ( ) ) {
return ;
return ;
@ -3153,6 +3136,7 @@ static std::string CompressibleString(Random* rnd, int len) {
test : : CompressibleString ( rnd , 0.8 , len , & r ) ;
test : : CompressibleString ( rnd , 0.8 , len , & r ) ;
return r ;
return r ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , FailMoreDbPaths ) {
TEST_F ( DBTest , FailMoreDbPaths ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -3183,6 +3167,7 @@ void CheckColumnFamilyMeta(const ColumnFamilyMetaData& cf_meta) {
ASSERT_EQ ( cf_meta . size , cf_size ) ;
ASSERT_EQ ( cf_meta . size , cf_size ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , ColumnFamilyMetaDataTest ) {
TEST_F ( DBTest , ColumnFamilyMetaDataTest ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . create_if_missing = true ;
options . create_if_missing = true ;
@ -3329,6 +3314,7 @@ TEST_F(DBTest, RepeatedWritesToSameKey) {
}
}
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , SparseMerge ) {
TEST_F ( DBTest , SparseMerge ) {
do {
do {
@ -3375,6 +3361,7 @@ TEST_F(DBTest, SparseMerge) {
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
static bool Between ( uint64_t val , uint64_t low , uint64_t high ) {
static bool Between ( uint64_t val , uint64_t low , uint64_t high ) {
bool result = ( val > = low ) & & ( val < = high ) ;
bool result = ( val > = low ) & & ( val < = high ) ;
if ( ! result ) {
if ( ! result ) {
@ -3587,6 +3574,7 @@ TEST_F(DBTest, ApproximateSizes_MixOfSmallAndLarge) {
// ApproximateOffsetOf() is not yet implemented in plain table format.
// ApproximateOffsetOf() is not yet implemented in plain table format.
} while ( ChangeOptions ( kSkipPlainTable ) ) ;
} while ( ChangeOptions ( kSkipPlainTable ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , IteratorPinsRef ) {
TEST_F ( DBTest , IteratorPinsRef ) {
do {
do {
@ -3614,6 +3602,7 @@ TEST_F(DBTest, IteratorPinsRef) {
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , Snapshot ) {
TEST_F ( DBTest , Snapshot ) {
anon : : OptionsOverride options_override ;
anon : : OptionsOverride options_override ;
options_override . skip_policy = kSkipNoSnapshot ;
options_override . skip_policy = kSkipNoSnapshot ;
@ -3716,6 +3705,7 @@ TEST_F(DBTest, HiddenValuesAreRemoved) {
} while ( ChangeOptions ( kSkipUniversalCompaction | kSkipFIFOCompaction |
} while ( ChangeOptions ( kSkipUniversalCompaction | kSkipFIFOCompaction |
kSkipPlainTable | kSkipHashCuckoo ) ) ;
kSkipPlainTable | kSkipHashCuckoo ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , CompactBetweenSnapshots ) {
TEST_F ( DBTest , CompactBetweenSnapshots ) {
anon : : OptionsOverride options_override ;
anon : : OptionsOverride options_override ;
@ -3821,6 +3811,7 @@ TEST_F(DBTest, UnremovableSingleDelete) {
kSkipUniversalCompaction | kSkipMergePut ) ) ;
kSkipUniversalCompaction | kSkipMergePut ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , DeletionMarkers1 ) {
TEST_F ( DBTest , DeletionMarkers1 ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . max_background_flushes = 0 ;
options . max_background_flushes = 0 ;
@ -3930,6 +3921,7 @@ TEST_F(DBTest, OverlapInLevel0) {
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , " 600 " ) ) ;
ASSERT_EQ ( " NOT_FOUND " , Get ( 1 , " 600 " ) ) ;
} while ( ChangeOptions ( kSkipUniversalCompaction | kSkipFIFOCompaction ) ) ;
} while ( ChangeOptions ( kSkipUniversalCompaction | kSkipFIFOCompaction ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , ComparatorCheck ) {
TEST_F ( DBTest , ComparatorCheck ) {
class NewComparator : public Comparator {
class NewComparator : public Comparator {
@ -4122,6 +4114,7 @@ TEST_F(DBTest, DestroyDBMetaDatabase) {
ASSERT_TRUE ( ! ( DB : : Open ( options , metametadbname , & db ) ) . ok ( ) ) ;
ASSERT_TRUE ( ! ( DB : : Open ( options , metametadbname , & db ) ) . ok ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
// Check that number of files does not grow when writes are dropped
// Check that number of files does not grow when writes are dropped
TEST_F ( DBTest , DropWrites ) {
TEST_F ( DBTest , DropWrites ) {
do {
do {
@ -4192,6 +4185,7 @@ TEST_F(DBTest, DropWritesFlush) {
env_ - > drop_writes_ . store ( false , std : : memory_order_release ) ;
env_ - > drop_writes_ . store ( false , std : : memory_order_release ) ;
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
// Check that CompactRange() returns failure if there is not enough space left
// Check that CompactRange() returns failure if there is not enough space left
// on device
// on device
@ -4241,6 +4235,7 @@ TEST_F(DBTest, NonWritableFileSystem) {
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , ManifestWriteError ) {
TEST_F ( DBTest , ManifestWriteError ) {
// Test for the following problem:
// Test for the following problem:
// (a) Compaction produces file F
// (a) Compaction produces file F
@ -4282,6 +4277,7 @@ TEST_F(DBTest, ManifestWriteError) {
ASSERT_EQ ( " bar " , Get ( " foo " ) ) ;
ASSERT_EQ ( " bar " , Get ( " foo " ) ) ;
}
}
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , PutFailsParanoid ) {
TEST_F ( DBTest , PutFailsParanoid ) {
// Test the following:
// Test the following:
@ -4540,6 +4536,7 @@ TEST_F(DBTest, BloomFilterWrapper) {
ASSERT_EQ ( 2U * maxKey , policy - > GetCounter ( ) ) ;
ASSERT_EQ ( 2U * maxKey , policy - > GetCounter ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , SnapshotFiles ) {
TEST_F ( DBTest , SnapshotFiles ) {
do {
do {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -4667,6 +4664,7 @@ TEST_F(DBTest, SnapshotFiles) {
dbfull ( ) - > DisableFileDeletions ( ) ;
dbfull ( ) - > DisableFileDeletions ( ) ;
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# endif
TEST_F ( DBTest , CompactOnFlush ) {
TEST_F ( DBTest , CompactOnFlush ) {
anon : : OptionsOverride options_override ;
anon : : OptionsOverride options_override ;
@ -4806,6 +4804,7 @@ TEST_F(DBTest, FlushOneColumnFamily) {
}
}
}
}
# ifndef ROCKSDB_LITE
// In https://reviews.facebook.net/D20661 we change
// In https://reviews.facebook.net/D20661 we change
// recovery behavior: previously for each log file each column family
// recovery behavior: previously for each log file each column family
// memtable was flushed, even it was empty. Now it's changed:
// memtable was flushed, even it was empty. Now it's changed:
@ -5011,6 +5010,7 @@ TEST_F(DBTest, SharedWriteBuffer) {
static_cast < uint64_t > ( 4 ) ) ;
static_cast < uint64_t > ( 4 ) ) ;
}
}
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , PurgeInfoLogs ) {
TEST_F ( DBTest , PurgeInfoLogs ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -5083,6 +5083,7 @@ TEST_F(DBTest, SyncMultipleLogs) {
ASSERT_OK ( dbfull ( ) - > SyncWAL ( ) ) ;
ASSERT_OK ( dbfull ( ) - > SyncWAL ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
//
//
// Test WAL recovery for the various modes available
// Test WAL recovery for the various modes available
//
//
@ -5365,7 +5366,6 @@ TEST_F(DBTest, kSkipAnyCorruptedRecords) {
}
}
}
}
// Multi-threaded test:
// Multi-threaded test:
namespace {
namespace {
@ -5532,6 +5532,7 @@ TEST_P(MultiThreadedDBTest, MultiThreaded) {
INSTANTIATE_TEST_CASE_P (
INSTANTIATE_TEST_CASE_P (
MultiThreaded , MultiThreadedDBTest ,
MultiThreaded , MultiThreadedDBTest ,
: : testing : : ValuesIn ( MultiThreadedDBTest : : GenerateOptionConfigs ( ) ) ) ;
: : testing : : ValuesIn ( MultiThreadedDBTest : : GenerateOptionConfigs ( ) ) ) ;
# endif // ROCKSDB_LITE
// Group commit test:
// Group commit test:
namespace {
namespace {
@ -5672,6 +5673,7 @@ class ModelDB: public DB {
return s ;
return s ;
}
}
# ifndef ROCKSDB_LITE
using DB : : AddFile ;
using DB : : AddFile ;
virtual Status AddFile ( ColumnFamilyHandle * column_family ,
virtual Status AddFile ( ColumnFamilyHandle * column_family ,
const ExternalSstFileInfo * file_path ,
const ExternalSstFileInfo * file_path ,
@ -5690,6 +5692,7 @@ class ModelDB: public DB {
TablePropertiesCollection * props ) override {
TablePropertiesCollection * props ) override {
return Status ( ) ;
return Status ( ) ;
}
}
# endif // ROCKSDB_LITE
using DB : : KeyMayExist ;
using DB : : KeyMayExist ;
virtual bool KeyMayExist ( const ReadOptions & options ,
virtual bool KeyMayExist ( const ReadOptions & options ,
@ -5834,7 +5837,9 @@ class ModelDB: public DB {
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
# ifndef ROCKSDB_LITE
virtual Status DisableFileDeletions ( ) override { return Status : : OK ( ) ; }
virtual Status DisableFileDeletions ( ) override { return Status : : OK ( ) ; }
virtual Status EnableFileDeletions ( bool force ) override {
virtual Status EnableFileDeletions ( bool force ) override {
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
@ -5849,11 +5854,6 @@ class ModelDB: public DB {
virtual Status DeleteFile ( std : : string name ) override { return Status : : OK ( ) ; }
virtual Status DeleteFile ( std : : string name ) override { return Status : : OK ( ) ; }
virtual Status GetDbIdentity ( std : : string & identity ) const override {
return Status : : OK ( ) ;
}
virtual SequenceNumber GetLatestSequenceNumber ( ) const override { return 0 ; }
virtual Status GetUpdatesSince (
virtual Status GetUpdatesSince (
rocksdb : : SequenceNumber , unique_ptr < rocksdb : : TransactionLogIterator > * ,
rocksdb : : SequenceNumber , unique_ptr < rocksdb : : TransactionLogIterator > * ,
const TransactionLogIterator : : ReadOptions &
const TransactionLogIterator : : ReadOptions &
@ -5861,13 +5861,20 @@ class ModelDB: public DB {
return Status : : NotSupported ( " Not supported in Model DB " ) ;
return Status : : NotSupported ( " Not supported in Model DB " ) ;
}
}
virtual ColumnFamilyHandle * DefaultColumnFamily ( ) const override {
return nullptr ;
}
virtual void GetColumnFamilyMetaData (
virtual void GetColumnFamilyMetaData (
ColumnFamilyHandle * column_family ,
ColumnFamilyHandle * column_family ,
ColumnFamilyMetaData * metadata ) override { }
ColumnFamilyMetaData * metadata ) override { }
# endif // ROCKSDB_LITE
virtual Status GetDbIdentity ( std : : string & identity ) const override {
return Status : : OK ( ) ;
}
virtual SequenceNumber GetLatestSequenceNumber ( ) const override { return 0 ; }
virtual ColumnFamilyHandle * DefaultColumnFamily ( ) const override {
return nullptr ;
}
private :
private :
class ModelIter : public Iterator {
class ModelIter : public Iterator {
@ -6128,6 +6135,7 @@ TEST_F(DBTest, MultiGetEmpty) {
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
namespace {
namespace {
void PrefixScanInit ( DBTest * dbtest ) {
void PrefixScanInit ( DBTest * dbtest ) {
char buf [ 100 ] ;
char buf [ 100 ] ;
@ -6230,6 +6238,7 @@ TEST_F(DBTest, PrefixScan) {
} // end of while
} // end of while
XFUNC_TEST ( " " , " dbtest_prefix " , prefix_skip1 , XFuncPoint : : SetSkip , 0 ) ;
XFUNC_TEST ( " " , " dbtest_prefix " , prefix_skip1 , XFuncPoint : : SetSkip , 0 ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , BlockBasedTablePrefixIndexTest ) {
TEST_F ( DBTest , BlockBasedTablePrefixIndexTest ) {
// create a DB with block prefix index
// create a DB with block prefix index
@ -6291,6 +6300,7 @@ TEST_F(DBTest, ChecksumTest) {
ASSERT_EQ ( " h " , Get ( " g " ) ) ;
ASSERT_EQ ( " h " , Get ( " g " ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_P ( DBTestWithParam , FIFOCompactionTest ) {
TEST_P ( DBTestWithParam , FIFOCompactionTest ) {
for ( int iter = 0 ; iter < 2 ; + + iter ) {
for ( int iter = 0 ; iter < 2 ; + + iter ) {
// first iteration -- auto compaction
// first iteration -- auto compaction
@ -6330,6 +6340,7 @@ TEST_P(DBTestWithParam, FIFOCompactionTest) {
}
}
}
}
}
}
# endif // ROCKSDB_LITE
// verify that we correctly deprecated timeout_hint_us
// verify that we correctly deprecated timeout_hint_us
TEST_F ( DBTest , SimpleWriteTimeoutTest ) {
TEST_F ( DBTest , SimpleWriteTimeoutTest ) {
@ -6340,6 +6351,7 @@ TEST_F(DBTest, SimpleWriteTimeoutTest) {
ASSERT_NOK ( Put ( Key ( 1 ) , Key ( 1 ) + std : : string ( 100 , ' v ' ) , write_opt ) ) ;
ASSERT_NOK ( Put ( Key ( 1 ) , Key ( 1 ) + std : : string ( 100 , ' v ' ) , write_opt ) ) ;
}
}
# ifndef ROCKSDB_LITE
/*
/*
* This test is not reliable enough as it heavily depends on disk behavior .
* This test is not reliable enough as it heavily depends on disk behavior .
*/
*/
@ -6432,6 +6444,7 @@ TEST_F(DBTest, TableOptionsSanitizeTest) {
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 1 ) ) ;
options . prefix_extractor . reset ( NewFixedPrefixTransform ( 1 ) ) ;
ASSERT_OK ( TryReopen ( options ) ) ;
ASSERT_OK ( TryReopen ( options ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , SanitizeNumThreads ) {
TEST_F ( DBTest , SanitizeNumThreads ) {
for ( int attempt = 0 ; attempt < 2 ; attempt + + ) {
for ( int attempt = 0 ; attempt < 2 ; attempt + + ) {
@ -6677,6 +6690,7 @@ TEST_F(DBTest, DisableDataSyncTest) {
}
}
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , DynamicMemtableOptions ) {
TEST_F ( DBTest , DynamicMemtableOptions ) {
const uint64_t k64KB = 1 < < 16 ;
const uint64_t k64KB = 1 < < 16 ;
const uint64_t k128KB = 1 < < 17 ;
const uint64_t k128KB = 1 < < 17 ;
@ -6818,6 +6832,7 @@ TEST_F(DBTest, DynamicMemtableOptions) {
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}
# endif // ROCKSDB_LITE
# if ROCKSDB_USING_THREAD_STATUS
# if ROCKSDB_USING_THREAD_STATUS
namespace {
namespace {
@ -7243,6 +7258,7 @@ TEST_P(DBTestWithParam, PreShutdownCompactionMiddle) {
# endif // ROCKSDB_USING_THREAD_STATUS
# endif // ROCKSDB_USING_THREAD_STATUS
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , FlushOnDestroy ) {
TEST_F ( DBTest , FlushOnDestroy ) {
WriteOptions wo ;
WriteOptions wo ;
wo . disableWAL = true ;
wo . disableWAL = true ;
@ -7696,6 +7712,7 @@ TEST_F(DBTest, DynamicCompactionOptions) {
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , FileCreationRandomFailure ) {
TEST_F ( DBTest , FileCreationRandomFailure ) {
Options options ;
Options options ;
@ -7757,6 +7774,7 @@ TEST_F(DBTest, FileCreationRandomFailure) {
}
}
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , DynamicMiscOptions ) {
TEST_F ( DBTest , DynamicMiscOptions ) {
// Test max_sequential_skip_in_iterations
// Test max_sequential_skip_in_iterations
Options options ;
Options options ;
@ -7806,6 +7824,7 @@ TEST_F(DBTest, DynamicMiscOptions) {
// No reseek
// No reseek
assert_reseek_count ( 300 , 1 ) ;
assert_reseek_count ( 300 , 1 ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , DontDeletePendingOutputs ) {
TEST_F ( DBTest , DontDeletePendingOutputs ) {
Options options ;
Options options ;
@ -7839,6 +7858,7 @@ TEST_F(DBTest, DontDeletePendingOutputs) {
Compact ( " a " , " b " ) ;
Compact ( " a " , " b " ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , DontDeleteMovedFile ) {
TEST_F ( DBTest , DontDeleteMovedFile ) {
// This test triggers move compaction and verifies that the file is not
// This test triggers move compaction and verifies that the file is not
// deleted when it's part of move compaction
// deleted when it's part of move compaction
@ -7941,6 +7961,7 @@ TEST_F(DBTest, OptimizeFiltersForHits) {
ASSERT_EQ ( Get ( 1 , Key ( i ) ) , " val " ) ;
ASSERT_EQ ( Get ( 1 , Key ( i ) ) , " val " ) ;
}
}
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , L0L1L2AndUpHitCounter ) {
TEST_F ( DBTest , L0L1L2AndUpHitCounter ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -8040,6 +8061,7 @@ TEST_F(DBTest, MutexWaitStats) {
ThreadStatus : : STATE_MUTEX_WAIT , 0 ) ;
ThreadStatus : : STATE_MUTEX_WAIT , 0 ) ;
}
}
# ifndef ROCKSDB_LITE
// This reproduces a bug where we don't delete a file because when it was
// This reproduces a bug where we don't delete a file because when it was
// supposed to be deleted, it was blocked by pending_outputs
// supposed to be deleted, it was blocked by pending_outputs
// Consider:
// Consider:
@ -8135,6 +8157,7 @@ TEST_F(DBTest, DeleteObsoleteFilesPendingOutputs) {
ASSERT_EQ ( Status : : NotFound ( ) , env_ - > FileExists ( dbname_ + file_on_L2 ) ) ;
ASSERT_EQ ( Status : : NotFound ( ) , env_ - > FileExists ( dbname_ + file_on_L2 ) ) ;
listener - > VerifyMatchedCount ( 1 ) ;
listener - > VerifyMatchedCount ( 1 ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , CloseSpeedup ) {
TEST_F ( DBTest , CloseSpeedup ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -8256,6 +8279,7 @@ TEST_F(DBTest, MergeTestTime) {
# endif // ROCKSDB_USING_THREAD_STATUS
# endif // ROCKSDB_USING_THREAD_STATUS
}
}
# ifndef ROCKSDB_LITE
TEST_P ( DBTestWithParam , MergeCompactionTimeTest ) {
TEST_P ( DBTestWithParam , MergeCompactionTimeTest ) {
SetPerfLevel ( kEnableTime ) ;
SetPerfLevel ( kEnableTime ) ;
Options options ;
Options options ;
@ -8306,6 +8330,7 @@ TEST_P(DBTestWithParam, FilterCompactionTimeTest) {
ASSERT_NE ( TestGetTickerCount ( options , FILTER_OPERATION_TOTAL_TIME ) , 0 ) ;
ASSERT_NE ( TestGetTickerCount ( options , FILTER_OPERATION_TOTAL_TIME ) , 0 ) ;
delete itr ;
delete itr ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , TestLogCleanup ) {
TEST_F ( DBTest , TestLogCleanup ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
@ -8322,6 +8347,7 @@ TEST_F(DBTest, TestLogCleanup) {
}
}
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , EmptyCompactedDB ) {
TEST_F ( DBTest , EmptyCompactedDB ) {
Options options ;
Options options ;
options . max_open_files = - 1 ;
options . max_open_files = - 1 ;
@ -8332,6 +8358,7 @@ TEST_F(DBTest, EmptyCompactedDB) {
ASSERT_TRUE ( s . IsNotSupported ( ) ) ;
ASSERT_TRUE ( s . IsNotSupported ( ) ) ;
Close ( ) ;
Close ( ) ;
}
}
# endif // ROCKSDB_LITE
class CountingDeleteTabPropCollector : public TablePropertiesCollector {
class CountingDeleteTabPropCollector : public TablePropertiesCollector {
public :
public :
@ -8373,6 +8400,7 @@ class CountingDeleteTabPropCollectorFactory
}
}
} ;
} ;
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , TablePropertiesNeedCompactTest ) {
TEST_F ( DBTest , TablePropertiesNeedCompactTest ) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
@ -8671,6 +8699,7 @@ TEST_F(DBTest, PromoteL0Failure) {
status = experimental : : PromoteL0 ( db_ , db_ - > DefaultColumnFamily ( ) ) ;
status = experimental : : PromoteL0 ( db_ , db_ - > DefaultColumnFamily ( ) ) ;
ASSERT_TRUE ( status . IsInvalidArgument ( ) ) ;
ASSERT_TRUE ( status . IsInvalidArgument ( ) ) ;
}
}
# endif // ROCKSDB_LITE
// Github issue #596
// Github issue #596
TEST_F ( DBTest , HugeNumberOfLevels ) {
TEST_F ( DBTest , HugeNumberOfLevels ) {
@ -8877,6 +8906,7 @@ TEST_F(DBTest, HardLimit) {
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , SoftLimit ) {
TEST_F ( DBTest , SoftLimit ) {
Options options ;
Options options ;
options . env = env_ ;
options . env = env_ ;
@ -8996,6 +9026,7 @@ TEST_F(DBTest, SoftLimit) {
ASSERT_EQ ( sleep_count . load ( ) , 0 ) ;
ASSERT_EQ ( sleep_count . load ( ) , 0 ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , FailWhenCompressionNotSupportedTest ) {
TEST_F ( DBTest , FailWhenCompressionNotSupportedTest ) {
CompressionType compressions [ ] = { kZlibCompression , kBZip2Compression ,
CompressionType compressions [ ] = { kZlibCompression , kBZip2Compression ,
@ -9017,6 +9048,7 @@ TEST_F(DBTest, FailWhenCompressionNotSupportedTest) {
}
}
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , RowCache ) {
TEST_F ( DBTest , RowCache ) {
Options options = CurrentOptions ( ) ;
Options options = CurrentOptions ( ) ;
options . statistics = rocksdb : : CreateDBStatistics ( ) ;
options . statistics = rocksdb : : CreateDBStatistics ( ) ;
@ -9035,6 +9067,7 @@ TEST_F(DBTest, RowCache) {
ASSERT_EQ ( TestGetTickerCount ( options , ROW_CACHE_HIT ) , 1 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , ROW_CACHE_HIT ) , 1 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , ROW_CACHE_MISS ) , 1 ) ;
ASSERT_EQ ( TestGetTickerCount ( options , ROW_CACHE_MISS ) , 1 ) ;
}
}
# endif // ROCKSDB_LITE
// TODO(3.13): fix the issue of Seek() + Prev() which might not necessary
// TODO(3.13): fix the issue of Seek() + Prev() which might not necessary
// return the biggest key which is smaller than the seek key.
// return the biggest key which is smaller than the seek key.
@ -9095,6 +9128,7 @@ TEST_F(DBTest, DeletingOldWalAfterDrop) {
EXPECT_GT ( lognum2 , lognum1 ) ;
EXPECT_GT ( lognum2 , lognum1 ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , RateLimitedDelete ) {
TEST_F ( DBTest , RateLimitedDelete ) {
rocksdb : : SyncPoint : : GetInstance ( ) - > LoadDependency ( {
rocksdb : : SyncPoint : : GetInstance ( ) - > LoadDependency ( {
{ " DBTest::RateLimitedDelete:1 " ,
{ " DBTest::RateLimitedDelete:1 " ,
@ -9263,6 +9297,7 @@ TEST_F(DBTest, DestroyDBWithRateLimitedDelete) {
// We have deleted the 4 sst files in the delete_scheduler
// We have deleted the 4 sst files in the delete_scheduler
ASSERT_EQ ( bg_delete_file , 4 ) ;
ASSERT_EQ ( bg_delete_file , 4 ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , UnsupportedManualSync ) {
TEST_F ( DBTest , UnsupportedManualSync ) {
DestroyAndReopen ( CurrentOptions ( ) ) ;
DestroyAndReopen ( CurrentOptions ( ) ) ;
@ -9271,6 +9306,7 @@ TEST_F(DBTest, UnsupportedManualSync) {
ASSERT_TRUE ( s . IsNotSupported ( ) ) ;
ASSERT_TRUE ( s . IsNotSupported ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , OpenDBWithInfiniteMaxOpenFiles ) {
TEST_F ( DBTest , OpenDBWithInfiniteMaxOpenFiles ) {
// Open DB with infinite max open files
// Open DB with infinite max open files
// - First iteration use 1 thread to open files
// - First iteration use 1 thread to open files
@ -9815,6 +9851,7 @@ TEST_F(DBTest, AddExternalSstFileMultiThreaded) {
} while ( ChangeOptions ( kSkipPlainTable | kSkipUniversalCompaction |
} while ( ChangeOptions ( kSkipPlainTable | kSkipUniversalCompaction |
kSkipFIFOCompaction ) ) ;
kSkipFIFOCompaction ) ) ;
}
}
# endif // ROCKSDB_LITE
// 1 Create some SST files by inserting K-V pairs into DB
// 1 Create some SST files by inserting K-V pairs into DB
// 2 Close DB and change suffix from ".sst" to ".ldb" for every other SST file
// 2 Close DB and change suffix from ".sst" to ".ldb" for every other SST file
@ -9887,6 +9924,47 @@ TEST_F(DBTest, PauseBackgroundWorkTest) {
ASSERT_EQ ( true , done . load ( ) ) ;
ASSERT_EQ ( true , done . load ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
class BloomStatsTestWithParam
: public DBTest ,
public testing : : WithParamInterface < std : : tuple < bool , bool > > {
public :
BloomStatsTestWithParam ( ) {
use_block_table_ = std : : get < 0 > ( GetParam ( ) ) ;
use_block_based_builder_ = std : : get < 1 > ( GetParam ( ) ) ;
options_ . create_if_missing = true ;
options_ . prefix_extractor . reset ( rocksdb : : NewFixedPrefixTransform ( 4 ) ) ;
options_ . memtable_prefix_bloom_bits = 8 * 1024 ;
if ( use_block_table_ ) {
BlockBasedTableOptions table_options ;
table_options . hash_index_allow_collision = false ;
table_options . filter_policy . reset (
NewBloomFilterPolicy ( 10 , use_block_based_builder_ ) ) ;
options_ . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ;
} else {
PlainTableOptions table_options ;
options_ . table_factory . reset ( NewPlainTableFactory ( table_options ) ) ;
}
perf_context . Reset ( ) ;
DestroyAndReopen ( options_ ) ;
}
~ BloomStatsTestWithParam ( ) {
perf_context . Reset ( ) ;
Destroy ( options_ ) ;
}
// Required if inheriting from testing::WithParamInterface<>
static void SetUpTestCase ( ) { }
static void TearDownTestCase ( ) { }
bool use_block_table_ ;
bool use_block_based_builder_ ;
Options options_ ;
} ;
// 1 Insert 2 K-V pairs into DB
// 1 Insert 2 K-V pairs into DB
// 2 Call Get() for both keys - expext memtable bloom hit stat to be 2
// 2 Call Get() for both keys - expext memtable bloom hit stat to be 2
// 3 Call Get() for nonexisting key - expect memtable bloom miss stat to be 1
// 3 Call Get() for nonexisting key - expect memtable bloom miss stat to be 1
@ -10000,6 +10078,7 @@ INSTANTIATE_TEST_CASE_P(BloomStatsTestWithParam, BloomStatsTestWithParam,
: : testing : : Values ( std : : make_tuple ( true , true ) ,
: : testing : : Values ( std : : make_tuple ( true , true ) ,
std : : make_tuple ( true , false ) ,
std : : make_tuple ( true , false ) ,
std : : make_tuple ( false , false ) ) ) ;
std : : make_tuple ( false , false ) ) ) ;
# endif // ROCKSDB_LITE
} // namespace rocksdb
} // namespace rocksdb
# endif
# endif