]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/utilities/simulator_cache/sim_cache_test.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / utilities / simulator_cache / sim_cache_test.cc
index 6cb495813944a1193a01cd5a78e85dbac77a9634..2c21c66b6e252fc4a2d7d509e903df8605e716ba 100644 (file)
@@ -21,7 +21,7 @@ class SimCacheTest : public DBTestBase {
   const size_t kNumBlocks = 5;
   const size_t kValueSize = 1000;
 
-  SimCacheTest() : DBTestBase("/sim_cache_test") {}
+  SimCacheTest() : DBTestBase("/sim_cache_test", /*env_do_fsync=*/true) {}
 
   BlockBasedTableOptions GetTableOptions() {
     BlockBasedTableOptions table_options;
@@ -35,7 +35,7 @@ class SimCacheTest : public DBTestBase {
     options.create_if_missing = true;
     // options.compression = kNoCompression;
     options.statistics = ROCKSDB_NAMESPACE::CreateDBStatistics();
-    options.table_factory.reset(new BlockBasedTableFactory(table_options));
+    options.table_factory.reset(NewBlockBasedTableFactory(table_options));
     return options;
   }
 
@@ -84,7 +84,7 @@ TEST_F(SimCacheTest, SimCache) {
   co.metadata_charge_policy = kDontChargeCacheMetadata;
   std::shared_ptr<SimCache> simCache = NewSimCache(NewLRUCache(co), 20000, 0);
   table_options.block_cache = simCache;
-  options.table_factory.reset(new BlockBasedTableFactory(table_options));
+  options.table_factory.reset(NewBlockBasedTableFactory(table_options));
   Reopen(options);
   RecordCacheCounters(options);
 
@@ -151,13 +151,13 @@ TEST_F(SimCacheTest, SimCacheLogging) {
   co.metadata_charge_policy = kDontChargeCacheMetadata;
   std::shared_ptr<SimCache> sim_cache = NewSimCache(NewLRUCache(co), 20000, 0);
   table_options.block_cache = sim_cache;
-  options.table_factory.reset(new BlockBasedTableFactory(table_options));
+  options.table_factory.reset(NewBlockBasedTableFactory(table_options));
   Reopen(options);
 
   int num_block_entries = 20;
   for (int i = 0; i < num_block_entries; i++) {
-    Put(Key(i), "val");
-    Flush();
+    ASSERT_OK(Put(Key(i), "val"));
+    ASSERT_OK(Flush());
   }
 
   std::string log_file = test::PerThreadDBPath(env_, "cache_log.txt");
@@ -172,7 +172,7 @@ TEST_F(SimCacheTest, SimCacheLogging) {
   ASSERT_OK(sim_cache->GetActivityLoggingStatus());
 
   std::string file_contents = "";
-  ReadFileToString(env_, log_file, &file_contents);
+  ASSERT_OK(ReadFileToString(env_, log_file, &file_contents));
 
   int lookup_num = 0;
   int add_num = 0;
@@ -199,8 +199,7 @@ TEST_F(SimCacheTest, SimCacheLogging) {
   ASSERT_EQ(add_num, num_block_entries);
 
   // Log things again but stop logging automatically after reaching 512 bytes
- // @lint-ignore TXT2 T25377293 Grandfathered in
-       int max_size = 512;
+  int max_size = 512;
   ASSERT_OK(sim_cache->StartActivityLogging(log_file, env_, max_size));
   for (int it = 0; it < 10; it++) {
     for (int i = 0; i < num_block_entries; i++) {
@@ -211,9 +210,9 @@ TEST_F(SimCacheTest, SimCacheLogging) {
 
   uint64_t fsize = 0;
   ASSERT_OK(env_->GetFileSize(log_file, &fsize));
-       // error margin of 100 bytes
+  // error margin of 100 bytes
   ASSERT_LT(fsize, max_size + 100);
-       ASSERT_GT(fsize, max_size - 100);
+  ASSERT_GT(fsize, max_size - 100);
 }
 
 }  // namespace ROCKSDB_NAMESPACE