11import logging
22import re
33
4+ import yaml
5+
46from redisbench_admin .run .redis_benchmark .redis_benchmark import prepareRedisBenchmarkCommand
57from redisbench_admin .run .redisgraph_benchmark_go .redisgraph_benchmark_go import prepareRedisGraphBenchmarkGoCommand
6- from redisbench_admin .utils .remote import executeRemoteCommands , getFileFromRemoteSetup
8+ from redisbench_admin .utils .benchmark_config import parseExporterMetricsDefinition , parseExporterTimeMetricDefinition , \
9+ parseExporterTimeMetric
10+ from redisbench_admin .utils .remote import executeRemoteCommands , getFileFromRemoteSetup , extractRedisGraphVersion , \
11+ extractPerVersionTimeSeriesFromResults , pushDataToRedisTimeSeries , extractPerBranchTimeSeriesFromResults
712
813
914def extract_benchmark_tool_settings (benchmark_config ):
@@ -35,9 +40,9 @@ def prepare_benchmark_parameters(benchmark_config, benchmark_tool, server_plaint
3540 remote_results_file , isremote = False ):
3641 for entry in benchmark_config ["clientconfig" ]:
3742 if 'parameters' in entry :
38- if benchmark_tool == 'redis-benchmark' :
43+ if 'redis-benchmark' in benchmark_tool :
3944 command_arr , command_str = prepareRedisBenchmarkCommand (
40- "redis-benchmark" ,
45+ benchmark_tool ,
4146 server_private_ip ,
4247 server_plaintext_port ,
4348 entry
@@ -46,13 +51,16 @@ def prepare_benchmark_parameters(benchmark_config, benchmark_tool, server_plaint
4651 command_arr .append (redirect_file )
4752 command_str = command_str + " " + redirect_file
4853
49- if benchmark_tool == 'redisgraph-benchmark-go' :
54+ if 'redisgraph-benchmark-go' in benchmark_tool :
55+ if isremote is True :
56+ benchmark_tool = "/tmp/redisgraph-benchmark-go"
5057 command_arr = prepareRedisGraphBenchmarkGoCommand (
51- "/tmp/redisgraph-benchmark-go" ,
58+ benchmark_tool ,
5259 server_private_ip ,
5360 server_plaintext_port ,
5461 entry ,
5562 remote_results_file ,
63+ isremote
5664 )
5765 command_str = " " .join (command_arr )
5866 return command_arr , command_str
@@ -87,3 +95,125 @@ def runRemoteBenchmark(
8795 remote_results_file ,
8896 )
8997 return remote_run_result
98+
99+
100+ def merge_default_and_specific_properties_dictType (benchmark_config , default_properties , propertygroup_keyname ,
101+ usecase_filename ):
102+ if propertygroup_keyname not in benchmark_config :
103+ benchmark_config [propertygroup_keyname ] = default_properties
104+ logging .info (
105+ "Using exclusively default '{}' properties (total={}) given the file {} had no '{}' property group" .format (
106+ propertygroup_keyname , len (benchmark_config [propertygroup_keyname ].keys ()), usecase_filename ,
107+ propertygroup_keyname )
108+ )
109+ else :
110+ use_case_specific_properties = benchmark_config [propertygroup_keyname ]
111+ for default_property in default_properties :
112+ default_rule , default_details = list (default_property .items ())[0 ]
113+ default_condition = list (default_details .values ())[0 ]
114+ comparison_key = "{}{}" .format (default_rule , default_condition )
115+ found = False
116+ found_details = None
117+ for usecase_kpi in use_case_specific_properties :
118+ usecase_rule , usecase_details = list (usecase_kpi .items ())[0 ]
119+ usecase_condition = list (usecase_details .values ())[0 ]
120+ usecase_comparison_key = "{}{}" .format (usecase_rule , usecase_condition )
121+ if comparison_key == usecase_comparison_key :
122+ found = True
123+ found_details = usecase_details
124+ if found :
125+ logging .info (
126+ "Skipping to add default '{}' property ({}) given the file {} had the same specific property ({})" .format (
127+ propertygroup_keyname ,
128+ default_property , usecase_filename , usecase_kpi )
129+ )
130+ else :
131+ use_case_specific_properties .append (default_property )
132+ logging .info (
133+ "Adding a default '{}' property ({}) given the file {} did not had the specific property" .format (
134+ propertygroup_keyname , default_property , usecase_filename )
135+ )
136+
137+
138+ def process_default_yaml_properties_file (default_kpis , default_metrics , defaults_filename , exporter_timemetric_path ,
139+ stream ):
140+ default_config = yaml .safe_load (stream )
141+ if "exporter" in default_config :
142+ default_metrics = parseExporterMetricsDefinition (default_config ["exporter" ])
143+ if len (default_metrics ) > 0 :
144+ logging .info (
145+ "Found RedisTimeSeries default metrics specification. Will include the following metrics on all benchmarks {}" .format (
146+ " " .join (default_metrics )
147+ )
148+ )
149+ exporter_timemetric_path = parseExporterTimeMetricDefinition (
150+ default_config ["exporter" ]
151+ )
152+ if exporter_timemetric_path is not None :
153+ logging .info (
154+ "Found RedisTimeSeries default time metric specification. Will use the following JSON path to retrieve the test time {}" .format (
155+ exporter_timemetric_path
156+ )
157+ )
158+ if "kpis" in default_config :
159+ logging .info (
160+ "Loading default KPIs specifications from file: {}" .format (defaults_filename )
161+ )
162+ default_kpis = default_config ["kpis" ]
163+ return default_kpis , default_metrics , exporter_timemetric_path
164+
165+
166+ def common_exporter_logic (deployment_type , exporter_timemetric_path , metrics , results_dict , rts , test_name ,
167+ tf_github_branch , tf_github_org , tf_github_repo , tf_triggering_env ):
168+ if exporter_timemetric_path is not None and len (metrics ) > 0 :
169+ # extract timestamp
170+ datapoints_timestamp = parseExporterTimeMetric (
171+ exporter_timemetric_path , results_dict
172+ )
173+
174+ rg_version = extractRedisGraphVersion (results_dict )
175+ if rg_version is None :
176+ rg_version = "N/A"
177+
178+ # extract per branch datapoints
179+ (
180+ ok ,
181+ per_version_time_series_dict ,
182+ ) = extractPerVersionTimeSeriesFromResults (
183+ datapoints_timestamp ,
184+ metrics ,
185+ results_dict ,
186+ rg_version ,
187+ tf_github_org ,
188+ tf_github_repo ,
189+ deployment_type ,
190+ test_name ,
191+ tf_triggering_env ,
192+ )
193+
194+ # push per-branch data
195+ pushDataToRedisTimeSeries (rts , per_version_time_series_dict )
196+ if tf_github_branch != None and tf_github_branch != '' :
197+ # extract per branch datapoints
198+ ok , branch_time_series_dict = extractPerBranchTimeSeriesFromResults (
199+ datapoints_timestamp ,
200+ metrics ,
201+ results_dict ,
202+ str (tf_github_branch ),
203+ tf_github_org ,
204+ tf_github_repo ,
205+ deployment_type ,
206+ test_name ,
207+ tf_triggering_env ,
208+ )
209+ # push per-branch data
210+ pushDataToRedisTimeSeries (rts , branch_time_series_dict )
211+ else :
212+ logging .warning (
213+ "Requested to push data to RedisTimeSeries but no git branch definition was found. git branch value {}" .format (
214+ tf_github_branch )
215+ )
216+ else :
217+ logging .error (
218+ "Requested to push data to RedisTimeSeries but no exporter definition was found. Missing \" exporter\" config."
219+ )
0 commit comments