@@ -51,6 +51,10 @@ SISL_OPTION_GROUP(
5151 ::cxxopts::value< bool >()->default_value(" 1" ), ""),
5252 (max_merge_level, " " , " max_merge_level" , " max merge level" , ::cxxopts::value< uint8_t >()->default_value(" 127" ),
5353 ""),
54+ (cache_pct, " " , " cache_pct" , " cache percentage" , ::cxxopts::value< uint32_t >()->default_value(" 10" ),
55+ ""),
56+ (app_mem_size_mb, " " , " app_mem_size_mb" , " application memory size" , ::cxxopts::value< uint64_t >()->default_value(" 900" ),
57+ ""),
5458 (seed, " " , " seed" , " random engine seed, use random if not defined" ,
5559 ::cxxopts::value< uint64_t >()->default_value(" 0" ), "number"))
5660
@@ -108,13 +112,18 @@ struct BtreeTest : public BtreeTestHelper< TestType >, public ::testing::Test {
108112 this ->m_bt = std::make_shared< typename T::BtreeType >(uuid, parent_uuid, 0 , this ->m_cfg );
109113 hs ()->index_service ().add_index_table (this ->m_bt );
110114 LOGINFO (" Added index table to index service" );
115+
116+ // start http server
117+ m_helper.get_http_server ()->start ();
118+ LOGINFO (" Started http server" );
111119 }
112120
113121 void TearDown () override {
114122 BtreeTestHelper< TestType >::TearDown ();
115123 auto [interior, leaf] = this ->m_bt ->compute_node_count ();
116124 LOGINFO (" Teardown with Root bnode_id {} tree size: {} btree node count (interior = {} leaf= {})" ,
117125 this ->m_bt ->root_node_id (), this ->m_bt ->count_keys (this ->m_bt ->root_node_id ()), interior, leaf);
126+ m_helper.get_http_server ()->stop ();
118127 m_helper.shutdown_homestore (false );
119128 this ->m_bt .reset ();
120129 log_obj_life_counter ();
@@ -479,6 +488,11 @@ struct BtreeConcurrentTest : public BtreeTestHelper< TestType >, public ::testin
479488 void restart_homestore () {
480489 m_helper.params (HS_SERVICE::INDEX).index_svc_cbs = new TestIndexServiceCallbacks (this );
481490 m_helper.restart_homestore ();
491+ BtreeTestHelper< TestType >::SetUp ();
492+ }
493+
494+ void set_app_mem_size (uint64_t app_mem_size) {
495+ m_helper.set_app_mem_size (app_mem_size);
482496 }
483497
484498 void SetUp () override {
@@ -558,6 +572,34 @@ TYPED_TEST(BtreeConcurrentTest, ConcurrentAllOps) {
558572 this ->multi_op_execute (ops, !SISL_OPTIONS[" init_device" ].as < bool >());
559573}
560574
575+ TYPED_TEST (BtreeConcurrentTest, ConcurrentAllOpsCacheEviction) {
576+ // restart homestore with smaller cache %
577+ HS_SETTINGS_FACTORY ().modifiable_settings ([](auto & s) {
578+ s.resource_limits .cache_size_percent = SISL_OPTIONS[" cache_pct" ].as < uint32_t >();
579+ HS_SETTINGS_FACTORY ().save ();
580+ });
581+ this ->set_app_mem_size (SISL_OPTIONS[" app_mem_size_mb" ].as < uint64_t >() * 1024 * 1024 );
582+
583+ this ->restart_homestore ();
584+
585+ // range put is not supported for non-extent keys
586+ std::vector< std::string > input_ops = {" put:80" , " remove:10" , " query:10" };
587+ if (SISL_OPTIONS.count (" operation_list" )) {
588+ input_ops = SISL_OPTIONS[" operation_list" ].as < std::vector< std::string > >();
589+ }
590+ auto ops = this ->build_op_list (input_ops);
591+
592+ this ->multi_op_execute (ops, !SISL_OPTIONS[" init_device" ].as < bool >());
593+
594+ LOGINFO (" Metrics dump {}" , sisl::MetricsFarm::getInstance ().report (sisl::ReportFormat::kTextFormat ));
595+ // reset cache pct
596+ HS_SETTINGS_FACTORY ().modifiable_settings ([](auto & s) {
597+ s.resource_limits .cache_size_percent = 65u ;
598+ HS_SETTINGS_FACTORY ().save ();
599+ });
600+ this ->set_app_mem_size (0 );
601+ }
602+
561603int main (int argc, char * argv[]) {
562604 int parsed_argc{argc};
563605 ::testing::InitGoogleTest (&parsed_argc, argv);
0 commit comments