summaryrefslogtreecommitdiff
path: root/db/db_test.cc
diff options
context:
space:
mode:
authorAndrew Kryczka <andrewkr@fb.com>2017-04-26 14:18:58 -0700
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2017-04-26 14:47:23 -0700
commitf6a27d0bce465cabff8c355932004db04077296b (patch)
tree1d5593e9cb3254dc88a40b63315cfd0a745bd875 /db/db_test.cc
parent7eddecce125af3e4ff1fd55d66e5760cb12b6bb7 (diff)
Extract statistics tests into separate file
Summary: I'm going to add more DB tests for statistics as currently we have very few. I started a file dedicated to this purpose and moved the existing stats-specific tests there. Closes https://github.com/facebook/rocksdb/pull/2211 Differential Revision: D4951558 Pulled By: ajkr fbshipit-source-id: 05d11c35079c40ecabdfd2cf5556ccb761f694a4
Diffstat (limited to 'db/db_test.cc')
-rw-r--r--db/db_test.cc98
1 files changed, 0 insertions, 98 deletions
diff --git a/db/db_test.cc b/db/db_test.cc
index dfe552e3c..e3b93280d 100644
--- a/db/db_test.cc
+++ b/db/db_test.cc
@@ -4193,104 +4193,6 @@ TEST_F(DBTest, EncodeDecompressedBlockSizeTest) {
}
}
-TEST_F(DBTest, CompressionStatsTest) {
- CompressionType type;
-
- if (Snappy_Supported()) {
- type = kSnappyCompression;
- fprintf(stderr, "using snappy\n");
- } else if (Zlib_Supported()) {
- type = kZlibCompression;
- fprintf(stderr, "using zlib\n");
- } else if (BZip2_Supported()) {
- type = kBZip2Compression;
- fprintf(stderr, "using bzip2\n");
- } else if (LZ4_Supported()) {
- type = kLZ4Compression;
- fprintf(stderr, "using lz4\n");
- } else if (XPRESS_Supported()) {
- type = kXpressCompression;
- fprintf(stderr, "using xpress\n");
- } else if (ZSTD_Supported()) {
- type = kZSTD;
- fprintf(stderr, "using ZSTD\n");
- } else {
- fprintf(stderr, "skipping test, compression disabled\n");
- return;
- }
-
- Options options = CurrentOptions();
- options.compression = type;
- options.statistics = rocksdb::CreateDBStatistics();
- options.statistics->stats_level_ = StatsLevel::kExceptTimeForMutex;
- DestroyAndReopen(options);
-
- int kNumKeysWritten = 100000;
-
- // Check that compressions occur and are counted when compression is turned on
- Random rnd(301);
- for (int i = 0; i < kNumKeysWritten; ++i) {
- // compressible string
- ASSERT_OK(Put(Key(i), RandomString(&rnd, 128) + std::string(128, 'a')));
- }
- ASSERT_OK(Flush());
- ASSERT_GT(options.statistics->getTickerCount(NUMBER_BLOCK_COMPRESSED), 0);
-
- for (int i = 0; i < kNumKeysWritten; ++i) {
- auto r = Get(Key(i));
- }
- ASSERT_GT(options.statistics->getTickerCount(NUMBER_BLOCK_DECOMPRESSED), 0);
-
- options.compression = kNoCompression;
- DestroyAndReopen(options);
- uint64_t currentCompressions =
- options.statistics->getTickerCount(NUMBER_BLOCK_COMPRESSED);
- uint64_t currentDecompressions =
- options.statistics->getTickerCount(NUMBER_BLOCK_DECOMPRESSED);
-
- // Check that compressions do not occur when turned off
- for (int i = 0; i < kNumKeysWritten; ++i) {
- // compressible string
- ASSERT_OK(Put(Key(i), RandomString(&rnd, 128) + std::string(128, 'a')));
- }
- ASSERT_OK(Flush());
- ASSERT_EQ(options.statistics->getTickerCount(NUMBER_BLOCK_COMPRESSED)
- - currentCompressions, 0);
-
- for (int i = 0; i < kNumKeysWritten; ++i) {
- auto r = Get(Key(i));
- }
- ASSERT_EQ(options.statistics->getTickerCount(NUMBER_BLOCK_DECOMPRESSED)
- - currentDecompressions, 0);
-}
-
-TEST_F(DBTest, MutexWaitStatsDisabledByDefault) {
- Options options = CurrentOptions();
- options.create_if_missing = true;
- options.statistics = rocksdb::CreateDBStatistics();
- CreateAndReopenWithCF({"pikachu"}, options);
- const uint64_t kMutexWaitDelay = 100;
- ThreadStatusUtil::TEST_SetStateDelay(ThreadStatus::STATE_MUTEX_WAIT,
- kMutexWaitDelay);
- ASSERT_OK(Put("hello", "rocksdb"));
- ASSERT_EQ(TestGetTickerCount(options, DB_MUTEX_WAIT_MICROS), 0);
- ThreadStatusUtil::TEST_SetStateDelay(ThreadStatus::STATE_MUTEX_WAIT, 0);
-}
-
-TEST_F(DBTest, MutexWaitStats) {
- Options options = CurrentOptions();
- options.create_if_missing = true;
- options.statistics = rocksdb::CreateDBStatistics();
- options.statistics->stats_level_ = StatsLevel::kAll;
- CreateAndReopenWithCF({"pikachu"}, options);
- const uint64_t kMutexWaitDelay = 100;
- ThreadStatusUtil::TEST_SetStateDelay(ThreadStatus::STATE_MUTEX_WAIT,
- kMutexWaitDelay);
- ASSERT_OK(Put("hello", "rocksdb"));
- ASSERT_GE(TestGetTickerCount(options, DB_MUTEX_WAIT_MICROS), kMutexWaitDelay);
- ThreadStatusUtil::TEST_SetStateDelay(ThreadStatus::STATE_MUTEX_WAIT, 0);
-}
-
TEST_F(DBTest, CloseSpeedup) {
Options options = CurrentOptions();
options.compaction_style = kCompactionStyleLevel;