@@ -1177,3 +1177,61 @@ def repeat_until_stop(self, stop_event: Event, func, delay=0.5):
1177
1177
while not stop_event .is_set ():
1178
1178
func ()
1179
1179
time .sleep (delay )
1180
+
1181
+
1182
+ @TestStep (Given )
1183
+ def allow_higher_cpu_wait_ratio (
1184
+ self , min_os_cpu_wait_time_ratio_to_throw = 10 , max_os_cpu_wait_time_ratio_to_throw = 20
1185
+ ):
1186
+ """
1187
+ Temporarily increase the threshold for OS CPU wait time ratio
1188
+ to reduce the chance of query rejection due to system overload.
1189
+
1190
+ This step updates the default query settings for the test context
1191
+ by increasing the min and max OS CPU wait-to-busy time ratios.
1192
+
1193
+ Useful for tests that are expected to put high load on the system
1194
+ and may otherwise be rejected due to CPU pressure.
1195
+
1196
+ Args:
1197
+ min_ratio (float): Minimum ratio at which query rejection starts (default=10).
1198
+ max_ratio (float): Maximum ratio at which rejection probability becomes 100% (default=20).
1199
+ """
1200
+ min_os_cpu_wait_time_ratio_to_throw_setting = (
1201
+ "min_os_cpu_wait_time_ratio_to_throw" ,
1202
+ min_os_cpu_wait_time_ratio_to_throw ,
1203
+ )
1204
+ max_os_cpu_wait_time_ratio_to_throw_setting = (
1205
+ "max_os_cpu_wait_time_ratio_to_throw" ,
1206
+ max_os_cpu_wait_time_ratio_to_throw ,
1207
+ )
1208
+ default_query_settings = None
1209
+
1210
+ try :
1211
+ with By (
1212
+ "adding relaxed OS CPU wait ratio thresholds to default query settings"
1213
+ ):
1214
+ default_query_settings = getsattr (
1215
+ current ().context , "default_query_settings" , []
1216
+ )
1217
+ default_query_settings .append (min_os_cpu_wait_time_ratio_to_throw_setting )
1218
+ default_query_settings .append (max_os_cpu_wait_time_ratio_to_throw_setting )
1219
+ yield
1220
+ finally :
1221
+ with Finally (
1222
+ "removing the relaxed OS CPU wait ratio settings from default query settings"
1223
+ ):
1224
+ if default_query_settings :
1225
+ try :
1226
+ default_query_settings .pop (
1227
+ default_query_settings .index (
1228
+ min_os_cpu_wait_time_ratio_to_throw_setting
1229
+ )
1230
+ )
1231
+ default_query_settings .pop (
1232
+ default_query_settings .index (
1233
+ max_os_cpu_wait_time_ratio_to_throw_setting
1234
+ )
1235
+ )
1236
+ except ValueError :
1237
+ pass
0 commit comments