|
| 1 | +# Apache License Version 2.0 |
| 2 | +# |
| 3 | +# Copyright (c) 2021., Redis Labs Modules |
| 4 | +# All rights reserved. |
| 5 | +# |
| 6 | + |
| 7 | +from redisbench_admin.utils.local import check_if_needs_remote_fetch |
| 8 | + |
| 9 | + |
| 10 | +def prepare_ftsb_benchmark_command( |
| 11 | + executable_path: str, |
| 12 | + server_private_ip: object, |
| 13 | + server_plaintext_port: object, |
| 14 | + benchmark_config: object, |
| 15 | + current_workdir, |
| 16 | + result_file: str, |
| 17 | + remote_queries_file, |
| 18 | + is_remote: bool, |
| 19 | + cluster_api_enabled: bool = False, |
| 20 | +): |
| 21 | + """ |
| 22 | + Prepares prepare_ftsb_benchmark_command command parameters |
| 23 | + :param executable_path: |
| 24 | + :param server_private_ip: |
| 25 | + :param server_plaintext_port: |
| 26 | + :param benchmark_config: |
| 27 | + :param current_workdir: |
| 28 | + :return: [string] containing the required command to run the benchmark given the configurations |
| 29 | + """ |
| 30 | + command_arr = [executable_path] |
| 31 | + |
| 32 | + command_arr.extend( |
| 33 | + ["--host", "{}:{}".format(server_private_ip, server_plaintext_port)] |
| 34 | + ) |
| 35 | + if cluster_api_enabled is True: |
| 36 | + command_arr.extend(["--cluster"]) |
| 37 | + if "parameters" in benchmark_config: |
| 38 | + for k in benchmark_config["parameters"]: |
| 39 | + if "input" in k: |
| 40 | + input_file = k["input"] |
| 41 | + input_file = check_if_needs_remote_fetch( |
| 42 | + input_file, "/tmp", None, remote_queries_file, is_remote |
| 43 | + ) |
| 44 | + command_arr.extend(["--input", input_file]) |
| 45 | + else: |
| 46 | + for kk in k.keys(): |
| 47 | + command_arr.extend(["--{}".format(kk), str(k[kk])]) |
| 48 | + |
| 49 | + command_arr.extend(["--json-out-file", result_file]) |
| 50 | + |
| 51 | + command_str = " ".join(command_arr) |
| 52 | + return command_arr, command_str |
| 53 | + |
| 54 | + |
| 55 | +def extract_ftsb_extra_links(benchmark_config, benchmark_tool): |
| 56 | + remote_tool_link = "/tmp/{}".format(benchmark_tool) |
| 57 | + tool_link = ( |
| 58 | + "https://s3.amazonaws.com/benchmarks.redislabs/" |
| 59 | + + "redisearch/tools/ftsb/{}_linux_amd64".format(benchmark_tool) |
| 60 | + ) |
| 61 | + queries_file_link = None |
| 62 | + for entry in benchmark_config["clientconfig"]: |
| 63 | + if "parameters" in entry: |
| 64 | + for parameter in entry["parameters"]: |
| 65 | + if "input" in parameter: |
| 66 | + queries_file_link = parameter["input"] |
| 67 | + return queries_file_link, remote_tool_link, tool_link |
0 commit comments