3939 get_run_full_filename ,
4040 fetch_remote_setup_from_config ,
4141 execute_remote_commands ,
42+ extract_redisgraph_version_from_resultdict ,
43+ retrieve_tf_connection_vars ,
4244)
4345
4446# internal aux vars
@@ -82,6 +84,39 @@ def setup_remote_benchmark_tool_requirements_tsbs_run_queries_redistimeseries(
8284 execute_remote_commands (client_public_ip , username , private_key , commands )
8385
8486
87+ def extract_artifact_version_remote (
88+ server_public_ip , server_public_port , username , private_key
89+ ):
90+ commands = [
91+ "redis-cli -h {} -p {} info modules" .format (
92+ server_public_ip , server_public_port
93+ ),
94+ ]
95+ res = execute_remote_commands (server_public_ip , username , private_key , commands )
96+ recv_exit_status , stdout , stderr = res [0 ]
97+ print (stdout )
98+ version = extract_module_semver_from_info_modules_cmd (stdout )
99+ return version
100+
101+
102+ def extract_module_semver_from_info_modules_cmd (stdout ):
103+ version = None
104+ if type (stdout ) == str :
105+ info_modules_output = stdout .split ("\n " )[1 :]
106+ else :
107+ info_modules_output = stdout [1 :]
108+ for module_detail_line in info_modules_output :
109+ detail_arr = module_detail_line .split ("," )
110+ if len (detail_arr ) > 1 :
111+ module_name = detail_arr [0 ].split ("=" )
112+ module_name = module_name [1 ]
113+ version = detail_arr [1 ].split ("=" )[1 ]
114+ logging .info (
115+ "Detected artifact={}, semver={}." .format (module_name , version )
116+ )
117+ return version
118+
119+
85120def run_remote_command_logic (args ):
86121 tf_bin_path = args .terraform_bin_path
87122 tf_github_org = args .github_org
@@ -263,7 +298,7 @@ def run_remote_command_logic(args):
263298 exporter_timemetric_path ,
264299 stream ,
265300 )
266-
301+ remote_envs = {}
267302 for usecase_filename in files :
268303 with open (usecase_filename , "r" ) as stream :
269304 dirname = os .path .dirname (os .path .abspath (usecase_filename ))
@@ -284,38 +319,62 @@ def run_remote_command_logic(args):
284319 )
285320
286321 if "remote" in benchmark_config :
287- remote_setup , deployment_type = fetch_remote_setup_from_config (
288- benchmark_config ["remote" ]
289- )
322+ (
323+ remote_setup ,
324+ deployment_type ,
325+ remote_id ,
326+ ) = fetch_remote_setup_from_config (benchmark_config ["remote" ])
290327 logging .info (
291328 "Deploying test defined in {} on AWS using {}" .format (
292329 usecase_filename , remote_setup
293330 )
294331 )
295332 tf_setup_name = "{}{}" .format (remote_setup , tf_setup_name_sufix )
296333 logging .info ("Using full setup name: {}" .format (tf_setup_name ))
297- # check if terraform is present
298- tf = Terraform (
299- working_dir = remote_setup ,
300- terraform_bin_path = tf_bin_path ,
301- )
302- (
303- return_code ,
304- username ,
305- server_private_ip ,
306- server_public_ip ,
307- server_plaintext_port ,
308- client_private_ip ,
309- client_public_ip ,
310- ) = setup_remote_environment (
311- tf ,
312- tf_github_sha ,
313- tf_github_actor ,
314- tf_setup_name ,
315- tf_github_org ,
316- tf_github_repo ,
317- tf_triggering_env ,
318- )
334+ if remote_id not in remote_envs :
335+ # check if terraform is present
336+ tf = Terraform (
337+ working_dir = remote_setup ,
338+ terraform_bin_path = tf_bin_path ,
339+ )
340+ (
341+ tf_return_code ,
342+ username ,
343+ server_private_ip ,
344+ server_public_ip ,
345+ server_plaintext_port ,
346+ client_private_ip ,
347+ client_public_ip ,
348+ ) = setup_remote_environment (
349+ tf ,
350+ tf_github_sha ,
351+ tf_github_actor ,
352+ tf_setup_name ,
353+ tf_github_org ,
354+ tf_github_repo ,
355+ tf_triggering_env ,
356+ )
357+ remote_envs [remote_id ] = tf
358+ else :
359+ logging .info ("Reusing remote setup {}" .format (remote_id ))
360+ tf = remote_envs [remote_id ]
361+ (
362+ tf_return_code ,
363+ username ,
364+ server_private_ip ,
365+ server_public_ip ,
366+ server_plaintext_port ,
367+ client_private_ip ,
368+ client_public_ip ,
369+ ) = retrieve_tf_connection_vars (None , tf )
370+ commands = [
371+ "redis-cli -h {} -p {} shutdown" .format (
372+ server_private_ip , server_plaintext_port
373+ )
374+ ]
375+ execute_remote_commands (
376+ server_public_ip , username , private_key , commands
377+ )
319378 # after we've created the env, even on error we should always teardown
320379 # in case of some unexpected error we fail the test
321380 try :
@@ -330,7 +389,9 @@ def run_remote_command_logic(args):
330389 remote_dataset_file ,
331390 dirname ,
332391 )
333-
392+ artifact_version = extract_artifact_version_remote (
393+ server_public_ip , server_plaintext_port , username , private_key
394+ )
334395 (
335396 benchmark_min_tool_version ,
336397 benchmark_min_tool_version_major ,
@@ -460,6 +521,19 @@ def run_remote_command_logic(args):
460521 with open (local_benchmark_output_filename , "r" ) as json_file :
461522 results_dict = json .load (json_file )
462523
524+ # if the benchmark tool is redisgraph-benchmark-go and
525+ # we still dont have the artifact semver we can extract it from the results dict
526+ if (
527+ benchmark_tool == "redisgraph-benchmark-go"
528+ and artifact_version is None
529+ ):
530+ artifact_version = extract_redisgraph_version_from_resultdict (
531+ results_dict
532+ )
533+
534+ if artifact_version is None :
535+ artifact_version = "N/A"
536+
463537 if "kpis" in benchmark_config :
464538 result = validate_result_expectations (
465539 benchmark_config ,
@@ -514,6 +588,7 @@ def run_remote_command_logic(args):
514588 tf_github_org ,
515589 tf_github_repo ,
516590 tf_triggering_env ,
591+ artifact_version ,
517592 )
518593 except :
519594 return_code |= 1
@@ -525,11 +600,12 @@ def run_remote_command_logic(args):
525600 print ("-" * 60 )
526601 traceback .print_exc (file = sys .stdout )
527602 print ("-" * 60 )
528- finally :
529- # tear-down
530- logging .info ("Tearing down setup" )
531- tf .destroy ()
532- logging .info ("Tear-down completed" )
603+
604+ for remote_setup_name , tf in remote_envs .items ():
605+ # tear-down
606+ logging .info ("Tearing down setup {}" .format (remote_setup_name ))
607+ tf .destroy ()
608+ logging .info ("Tear-down completed" )
533609
534610 exit (return_code )
535611
0 commit comments