44# All rights reserved.
55#
66import csv
7+ import datetime
78import datetime as dt
89import logging
910import os
2324 prepare_tsbs_benchmark_command ,
2425)
2526from redisbench_admin .run .ycsb .ycsb import prepare_ycsb_benchmark_command
27+ from redisbench_admin .run_remote .remote_helpers import (
28+ extract_module_semver_from_info_modules_cmd ,
29+ )
2630from redisbench_admin .utils .benchmark_config import (
2731 parse_exporter_timemetric ,
32+ parse_exporter_metrics_definition ,
33+ parse_exporter_timemetric_definition ,
34+ check_required_modules ,
2835)
2936from redisbench_admin .utils .remote import (
3037 execute_remote_commands ,
@@ -285,7 +292,9 @@ def execute_init_commands(benchmark_config, r, dbconfig_keyname="dbconfig"):
285292 )
286293
287294
288- def extract_test_feasible_setups (benchmark_config , param , default_specs ):
295+ def extract_test_feasible_setups (
296+ benchmark_config , param , default_specs , backwards_compatible = True
297+ ):
289298 feasible_setups_map = {}
290299 if param in benchmark_config :
291300 feasible_setups_list = benchmark_config [param ]
@@ -295,10 +304,82 @@ def extract_test_feasible_setups(benchmark_config, param, default_specs):
295304 for setup in default_specs ["setups" ]:
296305 if setup_name == setup ["name" ]:
297306 feasible_setups_map [setup_name ] = setup
307+ if len (feasible_setups_map .keys ()) == 0 and backwards_compatible :
308+ feasible_setups_map ["oss-standalone" ] = {
309+ "name" : "oss-standalone" ,
310+ "type" : "oss-standalone" ,
311+ "redis_topology" : {"primaries" : 1 , "replicas" : 0 },
312+ "resources" : {"requests" : {"cpu" : "1000m" }, "limits" : {"cpu" : "2000m" }},
313+ }
314+ logging .info (
315+ "Using a backwards compatible 'oss-standalone' setup, with settings: {}" .format (
316+ feasible_setups_map ["oss-standalone" ]
317+ )
318+ )
319+
298320 return feasible_setups_map
299321
300322
301323def get_setup_type_and_primaries_count (setup_settings ):
302324 setup_type = setup_settings ["type" ]
303325 shard_count = setup_settings ["redis_topology" ]["primaries" ]
304326 return setup_type , shard_count
327+
328+
329+ def merge_default_and_config_metrics (
330+ benchmark_config , default_metrics , exporter_timemetric_path
331+ ):
332+ metrics = default_metrics
333+ if "exporter" in benchmark_config :
334+ extra_metrics = parse_exporter_metrics_definition (benchmark_config ["exporter" ])
335+ metrics .extend (extra_metrics )
336+ extra_timemetric_path = parse_exporter_timemetric_definition (
337+ benchmark_config ["exporter" ]
338+ )
339+ if extra_timemetric_path is not None :
340+ exporter_timemetric_path = extra_timemetric_path
341+ return exporter_timemetric_path , metrics
342+
343+
344+ def run_redis_pre_steps (benchmark_config , r , required_modules ):
345+ stdout = r .execute_command ("info modules" )
346+ (
347+ module_names ,
348+ artifact_versions ,
349+ ) = extract_module_semver_from_info_modules_cmd (stdout )
350+ check_required_modules (module_names , required_modules )
351+ # run initialization commands before benchmark starts
352+ logging .info ("Running initialization commands before benchmark starts." )
353+ execute_init_commands_start_time = datetime .datetime .now ()
354+ execute_init_commands (benchmark_config , r )
355+ execute_init_commands_duration_seconds = (
356+ datetime .datetime .now () - execute_init_commands_start_time
357+ ).seconds
358+ logging .info (
359+ "Running initialization commands took {} secs." .format (
360+ execute_init_commands_duration_seconds
361+ )
362+ )
363+ return artifact_versions [0 ]
364+
365+
366+ def dso_check (dso , local_module_file ):
367+ if dso is None :
368+ logging .warning ("No dso specified for perf analysis {}" .format (dso ))
369+ if local_module_file is not None :
370+
371+ if type (local_module_file ) == str :
372+ dso = local_module_file
373+ logging .warning (
374+ "Using provided module = {} to specify dso" .format (
375+ local_module_file
376+ )
377+ )
378+ if type (local_module_file ) == list :
379+ dso = local_module_file [0 ]
380+ logging .warning (
381+ "Using first module = {} to specify dso" .format (
382+ local_module_file [0 ]
383+ )
384+ )
385+ return dso
0 commit comments