Skip to content

Commit e2ff50f

Browse files
committed
[add] Enabled enterprise cluster setup steps
1 parent 5c5d0c2 commit e2ff50f

File tree

3 files changed

+48
-12
lines changed

3 files changed

+48
-12
lines changed

poetry.lock

Lines changed: 25 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redisbench-admin"
3-
version = "0.1.15"
3+
version = "0.1.16"
44
description = "Redis benchmark run helper. A wrapper around Redis and Redis Modules benchmark tools ( ftsb_redisearch, memtier_benchmark, redis-benchmark, aibench, etc... )."
55
authors = ["filipecosta90 <[email protected]>"]
66
readme = "README.md"
@@ -21,6 +21,7 @@ toml = "^0.10.1"
2121
seaborn = "^0.10.1"
2222
matplotlib = "^3.2.1"
2323
redistimeseries = "^0.8.0"
24+
redis-py-cluster = "^2.1.0"
2425

2526
[tool.poetry.dev-dependencies]
2627
pytest = "^4.6"

redisbench_admin/run/run.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import redis
1010
import requests
1111
from cpuinfo import cpuinfo
12+
from rediscluster import RedisCluster
1213
from tqdm import tqdm
1314

1415
from redisbench_admin.compare.compare import generate_comparison_dataframe_configs
@@ -119,7 +120,7 @@ def run_command_logic(args):
119120
progress = tqdm(unit="bench steps", total=total_steps)
120121
for repetition in range(1, args.repetitions + 1):
121122
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)
123124
if "setup" in run_stages_inputs:
124125
setup_run_key = "setup-run-{}.json".format(repetition)
125126
setup_run_json_output_fullpath = "{}/{}".format(local_path, setup_run_key)
@@ -197,16 +198,27 @@ def run_command_logic(args):
197198
upload_artifacts_to_s3(artifacts, s3_bucket_name, s3_bucket_path)
198199

199200

200-
def run_setup_commands(args, aux_client, benchmark_config):
201+
def run_setup_commands(args, aux_client, benchmark_config, cluster_enabled):
201202
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:
204215
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)
210222
return aux_client
211223

212224

0 commit comments

Comments
 (0)