@@ -122,6 +122,28 @@ def wait_till_health_warn(self, health_warn, active_mds_id, sleep=3,
122122 if health_warn in health_report ['checks' ]:
123123 return
124124
125+ def gen_health_warn_mds_cache_oversized (self ):
126+ health_warn = 'MDS_CACHE_OVERSIZED'
127+
128+ self .config_set ('mds' , 'mds_cache_memory_limit' , '1K' )
129+ self .config_set ('mds' , 'mds_health_cache_threshold' , '1.00000' )
130+ self .mount_a .open_n_background ('.' , 400 )
131+
132+ self .wait_till_health_warn (health_warn , active_mds_id )
133+
134+ def gen_health_warn_mds_trim (self ):
135+ health_warn = 'MDS_TRIM'
136+
137+ # for generating health warning MDS_TRIM
138+ self .config_set ('mds' , 'mds_debug_subtrees' , 'true' )
139+ # this will really really slow the trimming, so that MDS_TRIM stays
140+ # for longer.
141+ self .config_set ('mds' , 'mds_log_trim_decay_rate' , '60' )
142+ self .config_set ('mds' , 'mds_log_trim_threshold' , '1' )
143+ self .mount_a .open_n_background ('.' , 400 )
144+
145+ self .wait_till_health_warn (health_warn , active_mds_id )
146+
125147
126148@classhook ('_add_valid_tell' )
127149class TestValidTell (TestAdminCommands ):
@@ -2305,17 +2327,11 @@ def test_with_health_warn_oversize_cache(self):
23052327 when confirmation flag is passed.
23062328 '''
23072329 health_warn = 'MDS_CACHE_OVERSIZED'
2308- self .config_set ('mds' , 'mds_cache_memory_limit' , '1K' )
2309- self .config_set ('mds' , 'mds_health_cache_threshold' , '1.00000' )
2310- active_mds_id = self .fs .get_active_names ()[0 ]
2311-
2312- self .mount_a .open_n_background ('.' , 400 )
2313- self .wait_till_health_warn (health_warn , active_mds_id )
2330+ self .gen_health_warn_mds_cache_oversized ()
23142331
23152332 # actual testing begins now.
2316- errmsg = 'mds_cache_oversized'
23172333 self .negtest_ceph_cmd (args = f'fs fail { self .fs .name } ' ,
2318- retval = 1 , errmsgs = errmsg )
2334+ retval = 1 , errmsgs = health_warn )
23192335 self .run_ceph_cmd (f'fs fail { self .fs .name } --yes-i-really-mean-it' )
23202336
23212337 # Bring and wait for MDS to be up since it is needed for unmounting
@@ -2330,21 +2346,11 @@ def test_with_health_warn_trim(self):
23302346 confirmation flag is passed.
23312347 '''
23322348 health_warn = 'MDS_TRIM'
2333- # for generating health warning MDS_TRIM
2334- self .config_set ('mds' , 'mds_debug_subtrees' , 'true' )
2335- # this will really really slow the trimming, so that MDS_TRIM stays
2336- # for longer.
2337- self .config_set ('mds' , 'mds_log_trim_decay_rate' , '60' )
2338- self .config_set ('mds' , 'mds_log_trim_threshold' , '1' )
2339- active_mds_id = self .fs .get_active_names ()[0 ]
2340-
2341- self .mount_a .open_n_background ('.' , 400 )
2342- self .wait_till_health_warn (health_warn , active_mds_id )
2349+ self .gen_health_warn_mds_trim ()
23432350
23442351 # actual testing begins now.
2345- errmsg = 'mds_trim'
23462352 self .negtest_ceph_cmd (args = f'fs fail { self .fs .name } ' ,
2347- retval = 1 , errmsgs = errmsg )
2353+ retval = 1 , errmsgs = health_warn )
23482354 self .run_ceph_cmd (f'fs fail { self .fs .name } --yes-i-really-mean-it' )
23492355
23502356 # Bring and wait for MDS to be up since it is needed for unmounting
@@ -2361,19 +2367,11 @@ def test_with_health_warn_with_2_active_MDSs(self):
23612367 '''
23622368 health_warn = 'MDS_CACHE_OVERSIZED'
23632369 self .fs .set_max_mds (2 )
2364- self .config_set ('mds' , 'mds_cache_memory_limit' , '1K' )
2365- self .config_set ('mds' , 'mds_health_cache_threshold' , '1.00000' )
2366- self .fs .wait_for_daemons ()
2367- mds1_id , mds2_id = self .fs .get_active_names ()
2368-
2369- self .mount_a .open_n_background ('.' , 400 )
2370- # MDS ID for which health warning has been generated.
2371- self .wait_till_health_warn (health_warn , mds1_id )
2370+ self .gen_health_warn_mds_cache_oversized ()
23722371
23732372 # actual testing begins now.
2374- errmsg = 'mds_cache_oversized'
23752373 self .negtest_ceph_cmd (args = f'fs fail { self .fs .name } ' ,
2376- retval = 1 , errmsgs = errmsg )
2374+ retval = 1 , errmsgs = health_warn )
23772375 self .run_ceph_cmd (f'fs fail { self .fs .name } --yes-i-really-mean-it' )
23782376
23792377 # Bring and wait for MDS to be up since it is needed for unmounting
@@ -2394,17 +2392,12 @@ def test_with_health_warn_oversize_cache(self):
23942392 passes when confirmation flag is passed.
23952393 '''
23962394 health_warn = 'MDS_CACHE_OVERSIZED'
2397- self .config_set ('mds' , 'mds_cache_memory_limit' , '1K' )
2398- self .config_set ('mds' , 'mds_health_cache_threshold' , '1.00000' )
2399- active_mds_id = self .fs .get_active_names ()[0 ]
2400-
2401- self .mount_a .open_n_background ('.' , 400 )
2402- self .wait_till_health_warn (health_warn , active_mds_id )
2395+ self .gen_health_warn_mds_cache_oversized ()
24032396
24042397 # actual testing begins now.
2405- errmsg = 'mds_cache_oversized'
2398+ active_mds_id = self . fs . get_active_names ()[ 0 ]
24062399 self .negtest_ceph_cmd (args = f'mds fail { active_mds_id } ' ,
2407- retval = 1 , errmsgs = errmsg )
2400+ retval = 1 , errmsgs = health_warn )
24082401 self .run_ceph_cmd (f'mds fail { active_mds_id } --yes-i-really-mean-it' )
24092402
24102403 def test_with_health_warn_trim (self ):
@@ -2414,21 +2407,12 @@ def test_with_health_warn_trim(self):
24142407 confirmation is passed.
24152408 '''
24162409 health_warn = 'MDS_TRIM'
2417- # for generating health warning MDS_TRIM
2418- self .config_set ('mds' , 'mds_debug_subtrees' , 'true' )
2419- # this will really really slow the trimming, so that MDS_TRIM stays
2420- # for longer.
2421- self .config_set ('mds' , 'mds_log_trim_decay_rate' , '60' )
2422- self .config_set ('mds' , 'mds_log_trim_threshold' , '1' )
2423- active_mds_id = self .fs .get_active_names ()[0 ]
2424-
2425- self .mount_a .open_n_background ('.' , 400 )
2426- self .wait_till_health_warn (health_warn , active_mds_id )
2410+ self .gen_health_warn_mds_trim ()
24272411
24282412 # actual testing begins now...
2429- errmsg = 'mds_trim'
2413+ active_mds_id = self . fs . get_active_names ()[ 0 ]
24302414 self .negtest_ceph_cmd (args = f'mds fail { active_mds_id } ' ,
2431- retval = 1 , errmsgs = errmsg )
2415+ retval = 1 , errmsgs = health_warn )
24322416 self .run_ceph_cmd (f'mds fail { active_mds_id } --yes-i-really-mean-it' )
24332417
24342418 def test_with_health_warn_with_2_active_MDSs (self ):
@@ -2440,14 +2424,9 @@ def test_with_health_warn_with_2_active_MDSs(self):
24402424 '''
24412425 health_warn = 'MDS_CACHE_OVERSIZED'
24422426 self .fs .set_max_mds (2 )
2443- self .config_set ('mds' , 'mds_cache_memory_limit' , '1K' )
2444- self .config_set ('mds' , 'mds_health_cache_threshold' , '1.00000' )
2445- self .fs .wait_for_daemons ()
2427+ self .gen_health_warn_mds_cache_oversized ()
24462428 mds1_id , mds2_id = self .fs .get_active_names ()
24472429
2448- self .mount_a .open_n_background ('.' , 400 )
2449- self .wait_till_health_warn (health_warn , mds1_id )
2450-
24512430 health_report = json .loads (self .get_ceph_cmd_stdout ('health detail '
24522431 '--format json' ))
24532432 # MDS ID for which health warning has been generated.
@@ -2462,10 +2441,9 @@ def test_with_health_warn_with_2_active_MDSs(self):
24622441 'than these two. This is definitely an error.' )
24632442
24642443 # actual testing begins now...
2465- errmsg = 'mds_cache_oversized'
24662444 self .negtest_ceph_cmd (args = f'mds fail { non_hw_mds_id } ' , retval = 1 ,
2467- errmsgs = errmsg )
2445+ errmsgs = health_warn )
24682446 self .negtest_ceph_cmd (args = f'mds fail { hw_mds_id } ' , retval = 1 ,
2469- errmsgs = errmsg )
2447+ errmsgs = health_warn )
24702448 self .run_ceph_cmd (f'mds fail { mds1_id } --yes-i-really-mean-it' )
24712449 self .run_ceph_cmd (f'mds fail { mds2_id } --yes-i-really-mean-it' )
0 commit comments