@ -30,6 +30,7 @@
# include "db/job_context.h"
# include "db/job_context.h"
# include "db/version_set.h"
# include "db/version_set.h"
# include "db/write_batch_internal.h"
# include "db/write_batch_internal.h"
# include "memtable/hash_linklist_rep.h"
# include "port/stack_trace.h"
# include "port/stack_trace.h"
# include "rocksdb/cache.h"
# include "rocksdb/cache.h"
# include "rocksdb/compaction_filter.h"
# include "rocksdb/compaction_filter.h"
@ -55,9 +56,9 @@
# include "table/block_based_table_factory.h"
# include "table/block_based_table_factory.h"
# include "table/mock_table.h"
# include "table/mock_table.h"
# include "table/plain_table_factory.h"
# include "table/plain_table_factory.h"
# include "table/scoped_arena_iterator.h"
# include "util/file_reader_writer.h"
# include "util/file_reader_writer.h"
# include "util/hash.h"
# include "util/hash.h"
# include "util/hash_linklist_rep.h"
# include "utilities/merge_operators.h"
# include "utilities/merge_operators.h"
# include "util/logging.h"
# include "util/logging.h"
# include "util/compression.h"
# include "util/compression.h"
@ -65,7 +66,6 @@
# include "util/rate_limiter.h"
# include "util/rate_limiter.h"
# include "util/statistics.h"
# include "util/statistics.h"
# include "util/testharness.h"
# include "util/testharness.h"
# include "util/scoped_arena_iterator.h"
# include "util/sync_point.h"
# include "util/sync_point.h"
# include "util/testutil.h"
# include "util/testutil.h"
# include "util/mock_env.h"
# include "util/mock_env.h"
@ -79,29 +79,12 @@ 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.
namespace {
namespace {
void VerifyTableProperties ( DB * db , uint64_t expected_entries_size ) {
TablePropertiesCollection props ;
ASSERT_OK ( db - > GetPropertiesOfAllTables ( & props ) ) ;
ASSERT_EQ ( 4U , props . size ( ) ) ;
std : : unordered_set < uint64_t > unique_entries ;
// Indirect test
uint64_t sum = 0 ;
for ( const auto & item : props ) {
unique_entries . insert ( item . second - > num_entries ) ;
sum + = item . second - > num_entries ;
}
ASSERT_EQ ( props . size ( ) , unique_entries . size ( ) ) ;
ASSERT_EQ ( expected_entries_size , sum ) ;
}
uint64_t GetNumberOfSstFilesForColumnFamily ( DB * db ,
uint64_t GetNumberOfSstFilesForColumnFamily ( DB * db ,
std : : string column_family_name ) {
std : : string column_family_name ) {
std : : vector < LiveFileMetaData > metadata ;
std : : vector < LiveFileMetaData > metadata ;
@ -114,6 +97,7 @@ uint64_t GetNumberOfSstFilesForColumnFamily(DB* db,
}
}
} // namespace
} // namespace
# endif // ROCKSDB_LITE
class DBTest : public DBTestBase {
class DBTest : public DBTestBase {
public :
public :
@ -132,46 +116,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 ;
@ -233,6 +178,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 ;
@ -255,6 +201,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 " ) ) ;
@ -476,42 +423,6 @@ TEST_F(DBTest, ParanoidFileChecks) {
TestGetTickerCount ( options , BLOCK_CACHE_ADD ) ) ;
TestGetTickerCount ( options , BLOCK_CACHE_ADD ) ) ;
}
}
TEST_F ( DBTest , GetPropertiesOfAllTablesTest ) {
Options options = CurrentOptions ( ) ;
options . level0_file_num_compaction_trigger = 8 ;
Reopen ( options ) ;
// Create 4 tables
for ( int table = 0 ; table < 4 ; + + table ) {
for ( int i = 0 ; i < 10 + table ; + + i ) {
db_ - > Put ( WriteOptions ( ) , ToString ( table * 100 + i ) , " val " ) ;
}
db_ - > Flush ( FlushOptions ( ) ) ;
}
// 1. Read table properties directly from file
Reopen ( options ) ;
VerifyTableProperties ( db_ , 10 + 11 + 12 + 13 ) ;
// 2. Put two tables to table cache and
Reopen ( options ) ;
// fetch key from 1st and 2nd table, which will internally place that table to
// the table cache.
for ( int i = 0 ; i < 2 ; + + i ) {
Get ( ToString ( i * 100 + 0 ) ) ;
}
VerifyTableProperties ( db_ , 10 + 11 + 12 + 13 ) ;
// 3. Put all tables to table cache
Reopen ( options ) ;
// fetch key from 1st and 2nd table, which will internally place that table to
// the table cache.
for ( int i = 0 ; i < 4 ; + + i ) {
Get ( ToString ( i * 100 + 0 ) ) ;
}
VerifyTableProperties ( db_ , 10 + 11 + 12 + 13 ) ;
}
namespace {
namespace {
void ResetTableProperties ( TableProperties * tp ) {
void ResetTableProperties ( TableProperties * tp ) {
tp - > data_size = 0 ;
tp - > data_size = 0 ;
@ -658,9 +569,10 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) {
DestroyAndReopen ( options ) ;
DestroyAndReopen ( options ) ;
int key_index = 0 ;
int key_index = 0 ;
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
for ( int num = 0 ; num < 7 ; num + + ) {
for ( int num = 0 ; num < 8 ; num + + ) {
Put ( " foo " , " bar " ) ;
Put ( " foo " , " bar " ) ;
GenerateNewFile ( & rnd , & key_index ) ;
GenerateNewFile ( & rnd , & key_index ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
}
}
dbfull ( ) - > TEST_WaitForCompact ( ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
@ -668,7 +580,7 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) {
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
// Get() after flushes, See latency histogram tracked.
// Get() after flushes, See latency histogram tracked.
for ( int key = 0 ; key < 500 ; key + + ) {
for ( int key = 0 ; key < key_index ; key + + ) {
Get ( Key ( key ) ) ;
Get ( Key ( key ) ) ;
}
}
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
@ -679,7 +591,7 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) {
// Reopen and issue Get(). See thee latency tracked
// Reopen and issue Get(). See thee latency tracked
Reopen ( options ) ;
Reopen ( options ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
dbfull ( ) - > TEST_WaitForCompact ( ) ;
for ( int key = 0 ; key < 500 ; key + + ) {
for ( int key = 0 ; key < key_index ; key + + ) {
Get ( Key ( key ) ) ;
Get ( Key ( key ) ) ;
}
}
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
@ -710,7 +622,7 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) {
ASSERT_NE ( std : : string : : npos , prop . find ( " ** Level 0 read latency histogram " ) ) ;
ASSERT_NE ( std : : string : : npos , prop . find ( " ** Level 0 read latency histogram " ) ) ;
ASSERT_NE ( std : : string : : npos , prop . find ( " ** Level 1 read latency histogram " ) ) ;
ASSERT_NE ( std : : string : : npos , prop . find ( " ** Level 1 read latency histogram " ) ) ;
ASSERT_EQ ( std : : string : : npos , prop . find ( " ** Level 2 read latency histogram " ) ) ;
ASSERT_EQ ( std : : string : : npos , prop . find ( " ** Level 2 read latency histogram " ) ) ;
for ( int key = 0 ; key < 500 ; key + + ) {
for ( int key = 0 ; key < key_index ; key + + ) {
Get ( Key ( key ) ) ;
Get ( Key ( key ) ) ;
}
}
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
ASSERT_TRUE ( dbfull ( ) - > GetProperty ( " rocksdb.dbstats " , & prop ) ) ;
@ -790,6 +702,7 @@ TEST_F(DBTest, AggregatedTablePropertiesAtLevel) {
}
}
}
}
}
}
# endif // ROCKSDB_LITE
class CoutingUserTblPropCollector : public TablePropertiesCollector {
class CoutingUserTblPropCollector : public TablePropertiesCollector {
public :
public :
@ -842,6 +755,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 +795,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 +858,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 +880,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 +1027,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 +1053,7 @@ TEST_F(DBTest, GetSnapshot) {
}
}
} while ( ChangeOptions ( ) ) ;
} while ( ChangeOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , GetLevel0Ordering ) {
TEST_F ( DBTest , GetLevel0Ordering ) {
do {
do {
@ -1162,6 +1081,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 +1153,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 +1286,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 +1351,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 +2256,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 +2366,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 +2412,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 +2718,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 +2778,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 +2819,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 +2867,7 @@ TEST_F(DBTest, IdentityAcrossRestarts) {
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , RecoverWithLargeLog ) {
TEST_F ( DBTest , RecoverWithLargeLog ) {
do {
do {
{
{
@ -2966,6 +2894,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 +2959,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 +3083,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 +3114,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 +3261,7 @@ TEST_F(DBTest, RepeatedWritesToSameKey) {
}
}
} while ( ChangeCompactOptions ( ) ) ;
} while ( ChangeCompactOptions ( ) ) ;
}
}
# endif // ROCKSDB_LITE
TEST_F ( DBTest , SparseMerge ) {
TEST_F ( DBTest , SparseMerge ) {
do {
do {
@ -3375,6 +3308,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 +3521,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 +3549,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 +3652,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 +3758,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 +3868,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 +4061,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 +4132,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 +4182,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 +4224,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 +4483,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 +4611,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 +4751,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 +4957,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 +5030,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 +5313,6 @@ TEST_F(DBTest, kSkipAnyCorruptedRecords) {
}
}
}
}
// Multi-threaded test:
// Multi-threaded test:
namespace {
namespace {
@ -5532,6 +5479,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 +5620,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 ,
@ -5691,6 +5640,13 @@ class ModelDB: public DB {
return Status ( ) ;
return Status ( ) ;
}
}
virtual Status GetPropertiesOfTablesInRange (
ColumnFamilyHandle * column_family , const Range * range , std : : size_t n ,
TablePropertiesCollection * props ) override {
return Status ( ) ;
}
# endif // ROCKSDB_LITE
using DB : : KeyMayExist ;
using DB : : KeyMayExist ;
virtual bool KeyMayExist ( const ReadOptions & options ,
virtual bool KeyMayExist ( const ReadOptions & options ,
ColumnFamilyHandle * column_family , const Slice & key ,
ColumnFamilyHandle * column_family , const Slice & key ,
@ -5834,7 +5790,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 +5807,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 +5814,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 +6088,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 +6191,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 +6253,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 +6293,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 +6304,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 +6397,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 +6643,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 +6785,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 {
@ -6926,6 +6894,10 @@ TEST_F(DBTest, ThreadStatusFlush) {
ASSERT_EQ ( " v1 " , Get ( 1 , " foo " ) ) ;
ASSERT_EQ ( " v1 " , Get ( 1 , " foo " ) ) ;
VerifyOperationCount ( env_ , ThreadStatus : : OP_FLUSH , 0 ) ;
VerifyOperationCount ( env_ , ThreadStatus : : OP_FLUSH , 0 ) ;
uint64_t num_running_flushes = 0 ;
db_ - > GetIntProperty ( DB : : Properties : : kNumRunningFlushes , & num_running_flushes ) ;
ASSERT_EQ ( num_running_flushes , 0 ) ;
Put ( 1 , " k1 " , std : : string ( 100000 , ' x ' ) ) ; // Fill memtable
Put ( 1 , " k1 " , std : : string ( 100000 , ' x ' ) ) ; // Fill memtable
Put ( 1 , " k2 " , std : : string ( 100000 , ' y ' ) ) ; // Trigger flush
Put ( 1 , " k2 " , std : : string ( 100000 , ' y ' ) ) ; // Trigger flush
@ -6933,10 +6905,11 @@ TEST_F(DBTest, ThreadStatusFlush) {
// running when we perform VerifyOperationCount().
// running when we perform VerifyOperationCount().
TEST_SYNC_POINT ( " DBTest::ThreadStatusFlush:1 " ) ;
TEST_SYNC_POINT ( " DBTest::ThreadStatusFlush:1 " ) ;
VerifyOperationCount ( env_ , ThreadStatus : : OP_FLUSH , 1 ) ;
VerifyOperationCount ( env_ , ThreadStatus : : OP_FLUSH , 1 ) ;
db_ - > GetIntProperty ( DB : : Properties : : kNumRunningFlushes , & num_running_flushes ) ;
ASSERT_EQ ( num_running_flushes , 1 ) ;
// This second sync point is to ensure the flush job will not
// This second sync point is to ensure the flush job will not
// be completed until we already perform VerifyOperationCount().
// be completed until we already perform VerifyOperationCount().
TEST_SYNC_POINT ( " DBTest::ThreadStatusFlush:2 " ) ;
TEST_SYNC_POINT ( " DBTest::ThreadStatusFlush:2 " ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
rocksdb : : SyncPoint : : GetInstance ( ) - > DisableProcessing ( ) ;
}
}
@ -6981,6 +6954,10 @@ TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
}
}
// This makes sure a compaction won't be scheduled until
// This makes sure a compaction won't be scheduled until
// we have done with the above Put Phase.
// we have done with the above Put Phase.
uint64_t num_running_compactions = 0 ;
db_ - > GetIntProperty ( DB : : Properties : : kNumRunningCompactions ,
& num_running_compactions ) ;
ASSERT_EQ ( num_running_compactions , 0 ) ;
TEST_SYNC_POINT ( " DBTest::ThreadStatusSingleCompaction:0 " ) ;
TEST_SYNC_POINT ( " DBTest::ThreadStatusSingleCompaction:0 " ) ;
ASSERT_GE ( NumTableFilesAtLevel ( 0 ) ,
ASSERT_GE ( NumTableFilesAtLevel ( 0 ) ,
options . level0_file_num_compaction_trigger ) ;
options . level0_file_num_compaction_trigger ) ;
@ -6995,6 +6972,9 @@ TEST_P(DBTestWithParam, ThreadStatusSingleCompaction) {
// If thread tracking is not enabled, compaction count should be 0.
// If thread tracking is not enabled, compaction count should be 0.
VerifyOperationCount ( env_ , ThreadStatus : : OP_COMPACTION , 0 ) ;
VerifyOperationCount ( env_ , ThreadStatus : : OP_COMPACTION , 0 ) ;
}
}
db_ - > GetIntProperty ( DB : : Properties : : kNumRunningCompactions ,
& num_running_compactions ) ;
ASSERT_EQ ( num_running_compactions , 1 ) ;
// TODO(yhchiang): adding assert to verify each compaction stage.
// TODO(yhchiang): adding assert to verify each compaction stage.
TEST_SYNC_POINT ( " DBTest::ThreadStatusSingleCompaction:2 " ) ;
TEST_SYNC_POINT ( " DBTest::ThreadStatusSingleCompaction:2 " ) ;
@ -7243,6 +7223,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 +7677,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 +7739,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 +7789,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 +7823,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 +7926,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 +8026,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 +8122,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 +8244,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 +8295,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 +8312,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 +8323,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 +8365,7 @@ class CountingDeleteTabPropCollectorFactory
}
}
} ;
} ;
# ifndef ROCKSDB_LITE
TEST_F ( DBTest , TablePropertiesNeedCompactTest ) {
TEST_F ( DBTest , TablePropertiesNeedCompactTest ) {
Random rnd ( 301 ) ;
Random rnd ( 301 ) ;
@ -8671,6 +8664,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 +8871,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 +8991,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 +9013,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 +9032,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 +9093,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 +9262,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 +9271,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 +9816,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
@ -10222,6 +10224,47 @@ TEST_F(DBTest, WalFilterTestWithChangeBatch) {
}
}
# endif // ROCKSDB_LITE
# endif // ROCKSDB_LITE
# 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
@ -10335,6 +10378,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