3
3
import os
4
4
import pathlib
5
5
import shutil
6
- import stat
7
6
import subprocess
8
7
import sys
9
8
import tempfile
22
21
redis_benchmark_from_stdout_csv_to_json ,
23
22
redis_benchmark_ensure_min_version_local ,
24
23
)
24
+ from redisbench_admin .run .ycsb .ycsb import post_process_ycsb_results
25
25
from redisbench_admin .utils .local import (
26
26
spin_up_local_redis ,
27
27
get_local_run_full_filename ,
@@ -230,6 +230,19 @@ def post_process_benchmark_results(
230
230
)
231
231
with open (local_benchmark_output_filename , "w" ) as json_file :
232
232
json .dump (results_dict , json_file , indent = True )
233
+ if benchmark_tool == "ycsb" :
234
+ logging .info (
235
+ "Converting ycsb output to json. Storing it in: {}" .format (
236
+ local_benchmark_output_filename
237
+ )
238
+ )
239
+ results_dict = post_process_ycsb_results (
240
+ stdout .decode ("ascii" ),
241
+ start_time_ms ,
242
+ start_time_str ,
243
+ )
244
+ with open (local_benchmark_output_filename , "w" ) as json_file :
245
+ json .dump (results_dict , json_file , indent = True )
233
246
234
247
235
248
def check_benchmark_binaries_local_requirements (
@@ -242,6 +255,7 @@ def check_benchmark_binaries_local_requirements(
242
255
benchmark_min_tool_version_patch ,
243
256
benchmark_tool ,
244
257
tool_source ,
258
+ tool_source_bin_path ,
245
259
) = extract_benchmark_tool_settings (benchmark_config )
246
260
which_benchmark_tool = None
247
261
if benchmark_tool is not None :
@@ -255,57 +269,17 @@ def check_benchmark_binaries_local_requirements(
255
269
logging .info ("Checking benchmark tool {} is accessible" .format (benchmark_tool ))
256
270
which_benchmark_tool = shutil .which (benchmark_tool )
257
271
if which_benchmark_tool is None :
258
- if tool_source is not None :
259
- logging .info (
260
- "Tool {} was not detected on path. Using remote source to retrieve it: {}" .format (
261
- benchmark_tool , tool_source
262
- )
263
- )
264
- if tool_source .startswith ("http" ):
265
- if not os .path .isdir (binaries_localtemp_dir ):
266
- os .mkdir (binaries_localtemp_dir )
267
- filename = tool_source .split ("/" )[- 1 ]
268
- full_path = "{}/{}" .format (binaries_localtemp_dir , filename )
269
- if not os .path .exists (full_path ):
270
- logging .info (
271
- "Retrieving remote file from {} to {}. Using the dir {} as a cache for next time." .format (
272
- tool_source , full_path , binaries_localtemp_dir
273
- )
274
- )
275
- wget .download (tool_source , full_path )
276
- logging .info (
277
- "Decompressing {} into {}." .format (
278
- full_path , binaries_localtemp_dir
279
- )
280
- )
281
- if not os .path .exists (get_decompressed_filename (full_path )):
282
- full_path = decompress_file (full_path , binaries_localtemp_dir )
283
- else :
284
- full_path = get_decompressed_filename (full_path )
285
- benchmark_tool_workdir = os .path .abspath (full_path )
286
- executable = stat .S_IEXEC | stat .S_IXGRP | stat .S_IXOTH
287
- which_benchmark_tool = which_local (
288
- benchmark_tool , executable , full_path , which_benchmark_tool
289
- )
290
- if which_benchmark_tool is None :
291
- raise Exception (
292
- "Benchmark tool {} was not acessible at {}. Aborting..." .format (
293
- benchmark_tool , full_path
294
- )
295
- )
296
- else :
297
- logging .info (
298
- "Reusing cached remote file (located at {} )." .format (
299
- full_path
300
- )
301
- )
302
-
303
- else :
304
- raise Exception (
305
- "Benchmark tool {} was not acessible. Aborting..." .format (
306
- benchmark_tool
307
- )
308
- )
272
+ (
273
+ benchmark_tool_workdir ,
274
+ which_benchmark_tool ,
275
+ ) = fetch_benchmark_tool_from_source_to_local (
276
+ benchmark_tool ,
277
+ benchmark_tool_workdir ,
278
+ binaries_localtemp_dir ,
279
+ tool_source ,
280
+ tool_source_bin_path ,
281
+ which_benchmark_tool ,
282
+ )
309
283
else :
310
284
logging .info (
311
285
"Tool {} was detected at {}" .format (
@@ -332,6 +306,61 @@ def check_benchmark_binaries_local_requirements(
332
306
return benchmark_tool , which_benchmark_tool , benchmark_tool_workdir
333
307
334
308
309
+ def fetch_benchmark_tool_from_source_to_local (
310
+ benchmark_tool ,
311
+ benchmark_tool_workdir ,
312
+ binaries_localtemp_dir ,
313
+ tool_source ,
314
+ bin_path ,
315
+ which_benchmark_tool ,
316
+ ):
317
+ if tool_source is not None and bin_path is not None :
318
+ logging .info (
319
+ "Tool {} was not detected on path. Using remote source to retrieve it: {}" .format (
320
+ benchmark_tool , tool_source
321
+ )
322
+ )
323
+ if tool_source .startswith ("http" ):
324
+ if not os .path .isdir (binaries_localtemp_dir ):
325
+ os .mkdir (binaries_localtemp_dir )
326
+ filename = tool_source .split ("/" )[- 1 ]
327
+ full_path = "{}/{}" .format (binaries_localtemp_dir , filename )
328
+ if not os .path .exists (full_path ):
329
+ logging .info (
330
+ "Retrieving remote file from {} to {}. Using the dir {} as a cache for next time." .format (
331
+ tool_source , full_path , binaries_localtemp_dir
332
+ )
333
+ )
334
+ wget .download (tool_source , full_path )
335
+ logging .info (
336
+ "Decompressing {} into {}." .format (full_path , binaries_localtemp_dir )
337
+ )
338
+ if not os .path .exists (get_decompressed_filename (full_path )):
339
+ full_path = decompress_file (full_path , binaries_localtemp_dir )
340
+ else :
341
+ full_path = get_decompressed_filename (full_path )
342
+ benchmark_tool_workdir = os .path .abspath (full_path )
343
+ which_benchmark_tool = os .path .abspath (
344
+ "{}/{}" .format (benchmark_tool_workdir , bin_path )
345
+ )
346
+ if which_benchmark_tool is None :
347
+ raise Exception (
348
+ "Benchmark tool {} was not acessible at {}. Aborting..." .format (
349
+ benchmark_tool , full_path
350
+ )
351
+ )
352
+ else :
353
+ logging .info (
354
+ "Reusing cached remote file (located at {} )." .format (full_path )
355
+ )
356
+
357
+ else :
358
+ raise Exception (
359
+ "Benchmark tool {} was not acessible. Aborting..." .format (benchmark_tool )
360
+ )
361
+ return benchmark_tool_workdir , which_benchmark_tool
362
+
363
+
335
364
def which_local (benchmark_tool , executable , full_path , which_benchmark_tool ):
336
365
if which_benchmark_tool :
337
366
return which_benchmark_tool
0 commit comments