1717)
1818from redisbench_admin .utils .benchmark_config import extract_benchmark_tool_settings
1919from redisbench_admin .utils .redisgraph_benchmark_go import (
20- setup_remote_benchmark_ann ,
2120 get_redisbench_admin_remote_path ,
2221)
2322from redisbench_admin .utils .remote import (
@@ -59,6 +58,8 @@ def run_remote_client_tool(
5958 _ ,
6059 ) = extract_benchmark_tool_settings (benchmark_config , config_key )
6160 benchmark_tools_sanity_check (allowed_tools , benchmark_tool )
61+ local_output_artifacts = []
62+ remote_output_artifacts = []
6263 # setup the benchmark tool
6364 remote_tool_pre_bench_step (
6465 benchmark_config ,
@@ -104,18 +105,20 @@ def run_remote_client_tool(
104105 tmp = local_bench_fname
105106 local_bench_fname = "result.csv"
106107 commands = [command_str ]
107- local_output_artifacts = []
108- remote_output_artifacts = []
109108 if "ann" in benchmark_tool :
110- [recv_exit_status , stdout , stderr ] = get_redisbench_admin_remote_path (
111- client_public_ip , username , private_key , client_ssh_port
112- )[0 ]
113- pkg_path = stdout [0 ].strip ()
109+ pkg_path = get_ann_remote_pkg_path (
110+ client_public_ip , client_ssh_port , private_key , username
111+ )
114112 benchmark_suffix = local_bench_fname [: len (local_bench_fname ) - 5 ]
115113 create_website_path = pkg_path + "/run/ann/pkg/"
116114 logging .info ("Remote create website path: {}" .format (create_website_path ))
117115 website_outputdir = "/tmp/website-{}" .format (benchmark_suffix )
118116 website_outputdir_zip = "/tmp/website-{}.zip" .format (benchmark_suffix )
117+ website_outputdir_zip_local = "website-{}.zip" .format (benchmark_suffix )
118+ results_outputdir = pkg_path + "/run/ann/pkg/results"
119+ results_outputdir_zip = "/tmp/results-{}.zip" .format (benchmark_suffix )
120+ results_outputdir_zip_local = "results-{}.zip" .format (benchmark_suffix )
121+
119122 mkdir_command = "mkdir -p {}" .format (website_outputdir )
120123 create_website_command = (
121124 "cd {} && sudo python3 create_website.py --outputdir {}" .format (
@@ -125,11 +128,19 @@ def run_remote_client_tool(
125128 zip_website_command = "zip -r {} {}" .format (
126129 website_outputdir_zip , website_outputdir
127130 )
131+
132+ zip_results_command = "zip -r {} {}" .format (
133+ results_outputdir_zip , results_outputdir
134+ )
128135 commands .append (mkdir_command )
129136 commands .append (create_website_command )
130137 commands .append (zip_website_command )
131- local_output_artifacts .append (website_outputdir_zip )
138+ commands .append (zip_results_command )
139+
140+ local_output_artifacts .append (website_outputdir_zip_local )
141+ local_output_artifacts .append (results_outputdir_zip_local )
132142 remote_output_artifacts .append (website_outputdir_zip )
143+ remote_output_artifacts .append (results_outputdir_zip )
133144
134145 benchmark_start_time = datetime .datetime .now ()
135146 # run the benchmark
@@ -176,16 +187,72 @@ def run_remote_client_tool(
176187 )[0 ]
177188 logging .warning ("Remote results file content: {}" .format (stdout ))
178189
190+ final_local_output_artifacts = []
191+ if len (remote_output_artifacts ) > 0 :
192+ logging .info (
193+ "Retrieving a total of {} remote client artifacts" .format (
194+ len (remote_output_artifacts )
195+ )
196+ )
197+ for client_artifact_n , client_remote_artifact in enumerate (remote_output_artifacts ):
198+ client_local_artifact = local_output_artifacts [client_artifact_n ]
199+ logging .info (
200+ "Retrieving remote client artifact: {} into local file {}" .format (
201+ client_remote_artifact , client_local_artifact
202+ )
203+ )
204+ fetch_file_from_remote_setup (
205+ client_public_ip ,
206+ username ,
207+ private_key ,
208+ client_local_artifact ,
209+ client_remote_artifact ,
210+ )
211+ final_local_output_artifacts .append (client_local_artifact )
212+
179213 return (
180214 artifact_version ,
181215 benchmark_duration_seconds ,
182216 local_bench_fname ,
183217 remote_run_result ,
184218 results_dict ,
185219 return_code ,
220+ final_local_output_artifacts ,
186221 )
187222
188223
224+ def setup_remote_benchmark_ann (
225+ client_public_ip , username , private_key , client_ssh_port
226+ ):
227+ commands = [
228+ "sudo apt install python3-pip -y" ,
229+ "sudo pip3 install redisbench-admin>=0.7.0" ,
230+ ]
231+ # last argument (get_pty) needs to be set to true
232+ # check: https://stackoverflow.com/questions/5785353/paramiko-and-sudo
233+ execute_remote_commands (
234+ client_public_ip , username , private_key , commands , client_ssh_port , True
235+ )
236+ pkg_path = get_ann_remote_pkg_path (
237+ client_public_ip , client_ssh_port , private_key , username
238+ )
239+ logging .info ("ensuring there is a clean results folder on ann-benchmarks pkg" )
240+ commands = [
241+ "sudo rm -rf {}/results/*" .format (pkg_path ),
242+ ]
243+ execute_remote_commands (
244+ client_public_ip , username , private_key , commands , client_ssh_port , True
245+ )
246+
247+
248+ def get_ann_remote_pkg_path (client_public_ip , client_ssh_port , private_key , username ):
249+ [recv_exit_status , stdout , stderr ] = get_redisbench_admin_remote_path (
250+ client_public_ip , username , private_key , client_ssh_port
251+ )[0 ]
252+ pkg_path = stdout [0 ].strip ()
253+ return pkg_path
254+
255+
189256def run_remote_benchmark (
190257 client_public_ip ,
191258 username ,
0 commit comments