From abc7f5fdb266745493d89b09719d9dd091e2b3b8 Mon Sep 17 00:00:00 2001 From: sdong Date: Thu, 10 Sep 2015 11:22:57 -0700 Subject: [PATCH] Make DBTest.ReadLatencyHistogramByLevel more robust Summary: DBTest.ReadLatencyHistogramByLevel was not written as expected. After writes, reads aren't guaranteed to hit data written. It was not expected. Fix it. Test Plan: Run the test multiple times Reviewers: IslamAbdelRahman, rven, anthony, kradhakrishnan, yhchiang, igor Reviewed By: igor Subscribers: leveldb, dhruba Differential Revision: https://reviews.facebook.net/D46587 --- db/db_test.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/db/db_test.cc b/db/db_test.cc index 780245b8f..4e4ab2426 100644 --- a/db/db_test.cc +++ b/db/db_test.cc @@ -614,17 +614,18 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) { table_options.no_block_cache = true; DestroyAndReopen(options); + int key_index = 0; Random rnd(301); for (int num = 0; num < 5; num++) { Put("foo", "bar"); - GenerateNewRandomFile(&rnd); + GenerateNewFile(&rnd, &key_index); } std::string prop; ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop)); // Get() after flushes, See latency histogram tracked. - for (int key = 0; key < 50; key++) { + for (int key = 0; key < 500; key++) { Get(Key(key)); } ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop)); @@ -634,7 +635,7 @@ TEST_F(DBTest, ReadLatencyHistogramByLevel) { // Reopen and issue Get(). See thee latency tracked Reopen(options); - for (int key = 0; key < 50; key++) { + for (int key = 0; key < 500; key++) { Get(Key(key)); } ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop)); @@ -665,7 +666,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 1 read latency histogram")); ASSERT_EQ(std::string::npos, prop.find("** Level 2 read latency histogram")); - for (int key = 0; key < 50; key++) { + for (int key = 0; key < 500; key++) { Get(Key(key)); } ASSERT_TRUE(dbfull()->GetProperty("rocksdb.dbstats", &prop));