Skip to content

Commit 21dd4ee

Browse files
Improved run-local and run-remote logic. Checking for errors in intermediate steps (#45)
* [add] Improved run-local and run-remote logic. Checking for errors in intermediate steps * [add] Changed Readme to point towards redismodules dir
1 parent db11b9c commit 21dd4ee

File tree

15 files changed

+242
-180
lines changed

15 files changed

+242
-180
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
[![codecov](https://codecov.io/gh/filipecosta90/redisbench-admin/branch/master/graph/badge.svg)](https://codecov.io/gh/filipecosta90/redisbench-admin)
2-
![Actions](https://github.com/filipecosta90/redisbench-admin/workflows/Run%20Tests/badge.svg?branch=master)
1+
[![codecov](https://codecov.io/gh/RedisLabsModules/redisbench-admin/branch/master/graph/badge.svg)](https://codecov.io/gh/RedisLabsModules/redisbench-admin)
2+
![Actions](https://github.com/RedisLabsModules/redisbench-admin/workflows/Run%20Tests/badge.svg?branch=master)
33
![Actions](https://badge.fury.io/py/redisbench-admin.svg)
44

5-
# redisbench-admin
5+
# [redisbench-admin](https://github.com/RedisLabsModules/redisbench-admin)
66

77
Redis benchmark run helper can help you with the following tasks:
88
- Setup abd teardown of benchmarking infrastructure specified on [RedisLabsModules/testing-infrastructure](https://github.com/RedisLabsModules/testing-infrastructure)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redisbench-admin"
3-
version = "0.1.44"
3+
version = "0.1.45"
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"

redisbench_admin/cli.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from redisbench_admin.export.export import export_command_logic
1313
from redisbench_admin.extract.args import create_extract_arguments
1414
from redisbench_admin.extract.extract import extract_command_logic
15-
from redisbench_admin.run.args import create_run_arguments
16-
from redisbench_admin.run.run import run_command_logic
1715
from redisbench_admin.run_local.args import create_run_local_arguments
1816
from redisbench_admin.run_local.run_local import run_local_command_logic
1917
from redisbench_admin.run_remote.args import create_run_remote_arguments
@@ -34,13 +32,15 @@ def populate_with_poetry_data():
3432

3533
return project_name, project_description, project_version
3634

35+
3736
# logging settings
3837
logging.basicConfig(
3938
format="%(asctime)s %(levelname)-4s %(message)s",
4039
level=logging.INFO,
4140
datefmt="%Y-%m-%d %H:%M:%S",
4241
)
4342

43+
4444
def main():
4545
tool = None
4646
if len(sys.argv) < 2:

redisbench_admin/export/common/common.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def prepare_tags(k):
2222

2323

2424
def add_datapoint(
25-
time_series_dict, broader_ts_name, start_time_ms, metric_value, tags_array
25+
time_series_dict, broader_ts_name, start_time_ms, metric_value, tags_array
2626
):
2727
if broader_ts_name not in time_series_dict:
2828
tags_dict = {}
@@ -74,14 +74,14 @@ def get_or_None(dict, property):
7474

7575

7676
def get_kv_tags(
77-
deployment_type,
78-
extra_tags_array,
79-
git_sha,
80-
project,
81-
project_version,
82-
results_type,
83-
step,
84-
testcase_name,
77+
deployment_type,
78+
extra_tags_array,
79+
git_sha,
80+
project,
81+
project_version,
82+
results_type,
83+
step,
84+
testcase_name,
8585
):
8686
common_broader_kv_tags = [
8787
{"project": project},

redisbench_admin/export/export.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import json
22
import os
3+
34
import redis
5+
from redistimeseries.client import Client
6+
47
from redisbench_admin.export.common.common import split_tags_string
58
from redisbench_admin.export.ftsb_redisearch.ftsb_redisearch_json_format import (
69
ftsb_export_logic,
@@ -10,8 +13,6 @@
1013
)
1114
from redisbench_admin.utils.utils import retrieve_local_or_remote_input_json
1215

13-
from redistimeseries.client import Client
14-
1516

1617
def export_command_logic(args):
1718
benchmark_files = args.benchmark_result_files

redisbench_admin/export/ftsb_redisearch/ftsb_redisearch_json_format.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ def extract_key_configs(benchmark_result):
6060

6161

6262
def ftsb_export_logic(
63-
benchmark_result,
64-
extra_tags_array,
65-
filename,
66-
included_steps,
67-
results_type,
68-
time_series_dict,
69-
use_result,
63+
benchmark_result,
64+
extra_tags_array,
65+
filename,
66+
included_steps,
67+
results_type,
68+
time_series_dict,
69+
use_result,
7070
):
7171
key_result_steps = benchmark_result[results_type].keys()
7272
(

redisbench_admin/export/redis_benchmark/redis_benchmark_csv_format.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def fill_tags_from_passed_array(extra_tags_array):
5252

5353

5454
def redis_benchmark_export_logic(
55-
benchmark_result, extra_tags_array, results_type, time_series_dict, use_result
55+
benchmark_result, extra_tags_array, results_type, time_series_dict, use_result
5656
):
5757
ok = True
5858
start_time_ms = get_tag_fromextra_tags_array(extra_tags_array, "start_time_ms")

redisbench_admin/extract/extract.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import time
21
import json
2+
import time
33

44
import redis
55

redisbench_admin/run_remote/run_remote.py

+73-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,22 @@
33
import logging
44
import os
55
import pathlib
6+
import re
67
import sys
8+
import traceback
79

810
import yaml
911
from python_terraform import Terraform
1012
from redistimeseries.client import Client
1113

14+
from redisbench_admin.run.redis_benchmark.redis_benchmark import prepareRedisBenchmarkCommand
15+
from redisbench_admin.run.run import redis_benchmark_ensure_min_version
1216
from redisbench_admin.utils.benchmark_config import (
1317
parseExporterMetricsDefinition,
1418
parseExporterTimeMetricDefinition,
1519
parseExporterTimeMetric,
1620
)
21+
from redisbench_admin.utils.local import prepareRedisGraphBenchmarkGoCommand
1722
from redisbench_admin.utils.redisgraph_benchmark_go import (
1823
spinUpRemoteRedis,
1924
setupRemoteBenchmark,
@@ -261,16 +266,59 @@ def run_remote_command_logic(args):
261266
local_benchmark_output_filename
262267
)
263268
)
269+
270+
benchmark_tool = None
271+
benchmark_min_tool_version = None
272+
benchmark_min_tool_version_major = None
273+
benchmark_min_tool_version_minor = None
274+
benchmark_min_tool_version_patch = None
275+
for entry in benchmark_config["clientconfig"]:
276+
benchmark_min_tool_version, benchmark_min_tool_version_major, benchmark_min_tool_version_minor, benchmark_min_tool_version_patch, benchmark_tool = extract_tool_info(
277+
benchmark_min_tool_version, benchmark_min_tool_version_major,
278+
benchmark_min_tool_version_minor, benchmark_min_tool_version_patch, benchmark_tool, entry)
279+
if benchmark_tool is not None:
280+
logging.info("Detected benchmark config tool {}".format(benchmark_tool))
281+
else:
282+
raise Exception("Unable to detect benchmark tool within 'clientconfig' section. Aborting...")
283+
284+
if benchmark_tool not in args.allowed_tools.split(","):
285+
raise Exception(
286+
"Benchmark tool {} not in the allowed tools list [{}]. Aborting...".format(benchmark_tool,
287+
args.allowed_tools))
288+
289+
if benchmark_min_tool_version is not None and benchmark_tool == "redis-benchmark":
290+
redis_benchmark_ensure_min_version(benchmark_tool, benchmark_min_tool_version,
291+
benchmark_min_tool_version_major,
292+
benchmark_min_tool_version_minor,
293+
benchmark_min_tool_version_patch)
294+
295+
for entry in benchmark_config["clientconfig"]:
296+
if 'parameters' in entry:
297+
if benchmark_tool == 'redis-benchmark':
298+
command = prepareRedisBenchmarkCommand(
299+
"redis-benchmark",
300+
server_private_ip,
301+
server_plaintext_port,
302+
entry
303+
)
304+
if benchmark_tool == 'redisgraph-benchmark-go':
305+
print(entry)
306+
command = prepareRedisGraphBenchmarkGoCommand(
307+
"/tmp/redisgraph-benchmark-go",
308+
server_private_ip,
309+
server_plaintext_port,
310+
entry,
311+
remote_results_file,
312+
)
313+
264314
# run the benchmark
265315
runRemoteBenchmark(
266316
client_public_ip,
267317
username,
268318
private_key,
269-
server_private_ip,
270-
server_plaintext_port,
271-
benchmark_config,
272319
remote_results_file,
273320
local_benchmark_output_filename,
321+
command
274322
)
275323

276324
# check KPIs
@@ -362,10 +410,32 @@ def run_remote_command_logic(args):
362410
"Some unexpected exception was caught during remote work. Failing test...."
363411
)
364412
logging.critical(sys.exc_info()[0])
413+
print("-" * 60)
414+
traceback.print_exc(file=sys.stdout)
415+
print("-" * 60)
365416
finally:
366417
# tear-down
367418
logging.info("Tearing down setup")
368419
tf_output = tf.destroy()
369420
logging.info("Tear-down completed")
370421

371422
exit(return_code)
423+
424+
425+
def extract_tool_info(benchmark_min_tool_version, benchmark_min_tool_version_major, benchmark_min_tool_version_minor,
426+
benchmark_min_tool_version_patch, benchmark_tool, entry):
427+
if 'tool' in entry:
428+
benchmark_tool = entry['tool']
429+
if 'min-tool-version' in entry:
430+
benchmark_min_tool_version = entry['min-tool-version']
431+
p = re.compile("(\d+)\.(\d+)\.(\d+)")
432+
m = p.match(benchmark_min_tool_version)
433+
if m is None:
434+
logging.error(
435+
"Unable to extract semversion from 'min-tool-version'. Will not enforce version")
436+
benchmark_min_tool_version = None
437+
else:
438+
benchmark_min_tool_version_major = m.group(1)
439+
benchmark_min_tool_version_minor = m.group(2)
440+
benchmark_min_tool_version_patch = m.group(3)
441+
return benchmark_min_tool_version, benchmark_min_tool_version_major, benchmark_min_tool_version_minor, benchmark_min_tool_version_patch, benchmark_tool

redisbench_admin/utils/benchmark_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
def parseExporterMetricsDefinition(
5-
benchmark_config: dict, configkey: str = "redistimeseries"
5+
benchmark_config: dict, configkey: str = "redistimeseries"
66
):
77
metrics = []
88
if configkey in benchmark_config:
@@ -13,7 +13,7 @@ def parseExporterMetricsDefinition(
1313

1414

1515
def parseExporterTimeMetricDefinition(
16-
benchmark_config: dict, configkey: str = "redistimeseries"
16+
benchmark_config: dict, configkey: str = "redistimeseries"
1717
):
1818
metricPath = None
1919
if "timemetric" in benchmark_config[configkey]:

redisbench_admin/utils/local.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import redis
99

1010

11-
def checkDatasetLocalRequirements(benchmark_config, redis_tmp_dir, dirname = "."):
11+
def checkDatasetLocalRequirements(benchmark_config, redis_tmp_dir, dirname="."):
1212
for k in benchmark_config["dbconfig"]:
1313
if "dataset" in k:
1414
dataset = k["dataset"]
1515
if dataset is not None:
16-
logging.info("Copying rdb {}/{} to {}/dump.rdb".format(dirname,dataset, redis_tmp_dir))
17-
copyfile("{}/{}".format(dirname,dataset), "{}/dump.rdb".format(redis_tmp_dir))
16+
logging.info("Copying rdb {}/{} to {}/dump.rdb".format(dirname, dataset, redis_tmp_dir))
17+
copyfile("{}/{}".format(dirname, dataset), "{}/dump.rdb".format(redis_tmp_dir))
1818

1919

2020
def waitForConn(conn, retries=20, command="PING", shouldBe=True):
@@ -40,9 +40,9 @@ def waitForConn(conn, retries=20, command="PING", shouldBe=True):
4040

4141

4242
def spinUpLocalRedis(
43-
benchmark_config,
44-
port,
45-
local_module_file,
43+
benchmark_config,
44+
port,
45+
local_module_file,
4646
dirname=".",
4747
):
4848
# copy the rdb to DB machine
@@ -53,7 +53,7 @@ def spinUpLocalRedis(
5353
temporary_dir
5454
)
5555
)
56-
checkDatasetLocalRequirements(benchmark_config, temporary_dir,dirname)
56+
checkDatasetLocalRequirements(benchmark_config, temporary_dir, dirname)
5757

5858
# start redis-server
5959
command = [
@@ -90,9 +90,9 @@ def isProcessAlive(process):
9090

9191

9292
def getLocalRunFullFilename(
93-
start_time_str,
94-
github_branch,
95-
test_name,
93+
start_time_str,
94+
github_branch,
95+
test_name,
9696
):
9797
benchmark_output_filename = (
9898
"{start_time_str}-{github_branch}-{test_name}.json".format(
@@ -105,12 +105,12 @@ def getLocalRunFullFilename(
105105

106106

107107
def prepareRedisGraphBenchmarkGoCommand(
108-
executable_path: str,
109-
server_private_ip: object,
110-
server_plaintext_port: object,
111-
benchmark_config: object,
112-
results_file: object,
113-
) -> str:
108+
executable_path: str,
109+
server_private_ip: object,
110+
server_plaintext_port: object,
111+
benchmark_config: object,
112+
results_file: object,
113+
):
114114
"""
115115
Prepares redisgraph-benchmark-go command parameters
116116
:param server_private_ip:
@@ -122,7 +122,7 @@ def prepareRedisGraphBenchmarkGoCommand(
122122
queries_str = [executable_path]
123123
for k in benchmark_config["parameters"]:
124124
if "graph" in k:
125-
queries_str.extend(["-graph-key", "{}".format(k["graph"])])
125+
queries_str.extend(["-graph-key", "'{}'".format(k["graph"])])
126126
if "clients" in k:
127127
queries_str.extend(["-c", "{}".format(k["clients"])])
128128
if "requests" in k:
@@ -132,7 +132,7 @@ def prepareRedisGraphBenchmarkGoCommand(
132132
if "queries" in k:
133133
for kk in k["queries"]:
134134
query = kk["q"]
135-
queries_str.extend(["-query", "{}".format(query)])
135+
queries_str.extend(["-query", "'{}'".format(query)])
136136
if "ratio" in kk:
137137
queries_str.extend(["-query-ratio", "{}".format(kk["ratio"])])
138138
queries_str.extend(["-h", "{}".format(server_private_ip)])

0 commit comments

Comments
 (0)