|
9 | 9 | import redis |
10 | 10 | import requests |
11 | 11 | from cpuinfo import cpuinfo |
| 12 | +from rediscluster import RedisCluster |
12 | 13 | from tqdm import tqdm |
13 | 14 |
|
14 | 15 | from redisbench_admin.compare.compare import generate_comparison_dataframe_configs |
@@ -119,7 +120,7 @@ def run_command_logic(args): |
119 | 120 | progress = tqdm(unit="bench steps", total=total_steps) |
120 | 121 | for repetition in range(1, args.repetitions + 1): |
121 | 122 | if benchmark_repetitions_require_teardown is True or repetition == 1: |
122 | | - aux_client = run_setup_commands(args, aux_client, benchmark_config) |
| 123 | + aux_client = run_setup_commands(args, aux_client, benchmark_config, oss_cluster_mode) |
123 | 124 | if "setup" in run_stages_inputs: |
124 | 125 | setup_run_key = "setup-run-{}.json".format(repetition) |
125 | 126 | setup_run_json_output_fullpath = "{}/{}".format(local_path, setup_run_key) |
@@ -197,16 +198,27 @@ def run_command_logic(args): |
197 | 198 | upload_artifacts_to_s3(artifacts, s3_bucket_name, s3_bucket_path) |
198 | 199 |
|
199 | 200 |
|
200 | | -def run_setup_commands(args, aux_client, benchmark_config): |
| 201 | +def run_setup_commands(args, aux_client, benchmark_config, cluster_enabled): |
201 | 202 | print("Running setup steps...") |
202 | | - for command in benchmark_config["setup"]["commands"]: |
203 | | - try: |
| 203 | + try: |
| 204 | + if cluster_enabled: |
| 205 | + host_port_arr = args.redis_url.split(":") |
| 206 | + host = host_port_arr[0] |
| 207 | + port = host_port_arr[1] |
| 208 | + startup_nodes = [{"host": host, "port": port}] |
| 209 | + aux_client = RedisCluster(startup_nodes=startup_nodes, decode_responses=True) |
| 210 | + cluster_nodes = aux_client.cluster_nodes() |
| 211 | + for command in benchmark_config["setup"]["commands"]: |
| 212 | + for master_node in aux_client.connection_pool.nodes.all_masters(): |
| 213 | + redis.from_url("redis://"+master_node["name"]).execute_command(" ".join(command)) |
| 214 | + else: |
204 | 215 | aux_client = redis.from_url(args.redis_url) |
205 | | - aux_client.execute_command(" ".join(command)) |
206 | | - except redis.connection.ConnectionError as e: |
207 | | - print('Error while issuing setup command to Redis.Command {}! Error message: {} Exiting..'.format(command, |
208 | | - e.__str__())) |
209 | | - sys.exit(1) |
| 216 | + for command in benchmark_config["setup"]["commands"]: |
| 217 | + aux_client.execute_command(" ".join(command)) |
| 218 | + except redis.connection.ConnectionError as e: |
| 219 | + print('Error while issuing setup command to Redis.Command {}! Error message: {} Exiting..'.format(command, |
| 220 | + e.__str__())) |
| 221 | + sys.exit(1) |
210 | 222 | return aux_client |
211 | 223 |
|
212 | 224 |
|
|
0 commit comments