Skip to content

Commit 0c2149c

Browse files
Initial support for tsbs_run_queries_redistimeseries (#89)
* [add] Initial support for tsbs_run_queries_redistimeseries * Bumping version from 0.1.66 to 0.1.67
1 parent 43c4ae9 commit 0c2149c

File tree

9 files changed

+176
-26
lines changed

9 files changed

+176
-26
lines changed

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.66"
3+
version = "0.1.67"
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/run/common.py

+20
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
from redisbench_admin.run.redisgraph_benchmark_go.redisgraph_benchmark_go import (
1111
prepare_redisgraph_benchmark_go_command,
1212
)
13+
from redisbench_admin.run.tsbs_run_queries_redistimeseries.tsbs_run_queries_redistimeseries import (
14+
prepare_tsbs_run_queries_redistimeseries_benchmark_command,
15+
)
1316
from redisbench_admin.run.ycsb.ycsb import prepare_ycsb_benchmark_command
1417
from redisbench_admin.utils.benchmark_config import (
1518
parse_exporter_metrics_definition,
@@ -112,6 +115,23 @@ def prepare_benchmark_parameters(
112115
entry,
113116
current_workdir,
114117
)
118+
if "tsbs_run_queries_redistimeseries" in benchmark_tool:
119+
remote_queries_file = None
120+
if isremote is True:
121+
benchmark_tool = "/tmp/tsbs_run_queries_redistimeseries"
122+
remote_queries_file = "/tmp/queries-file.input"
123+
(
124+
command_arr,
125+
command_str,
126+
) = prepare_tsbs_run_queries_redistimeseries_benchmark_command(
127+
benchmark_tool,
128+
server_private_ip,
129+
server_plaintext_port,
130+
entry,
131+
current_workdir,
132+
remote_results_file,
133+
remote_queries_file,
134+
)
115135
printed_command_str = command_str
116136
printed_command_arr = command_arr
117137
if len(command_str) > 200:

redisbench_admin/run/tsbs_run_queries_redistimeseries/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import csv
2+
import re
3+
4+
from redisbench_admin.utils.local import check_if_needs_remote_fetch
5+
6+
7+
def prepare_tsbs_run_queries_redistimeseries_benchmark_command(
8+
executable_path: str,
9+
server_private_ip: object,
10+
server_plaintext_port: object,
11+
benchmark_config: object,
12+
current_workdir,
13+
result_file: str,
14+
remote_queries_file,
15+
):
16+
"""
17+
Prepares tsbs_run_queries_redistimeseries command parameters
18+
:param executable_path:
19+
:param server_private_ip:
20+
:param server_plaintext_port:
21+
:param benchmark_config:
22+
:param current_workdir:
23+
:return: [string] containing the required command to run the benchmark given the configurations
24+
"""
25+
command_arr = [executable_path]
26+
27+
command_arr.extend(
28+
["--host", "{}:{}".format(server_private_ip, server_plaintext_port)]
29+
)
30+
31+
for k in benchmark_config["parameters"]:
32+
if "workers" in k:
33+
command_arr.extend(["--workers", str(k["workers"])])
34+
if "file" in k:
35+
input_file = k["file"]
36+
input_file = check_if_needs_remote_fetch(
37+
input_file, "/tmp", None, remote_queries_file
38+
)
39+
command_arr.extend(["--file", input_file])
40+
41+
command_arr.extend(["--results-file", result_file])
42+
command_arr.extend(["--print-interval", "1000"])
43+
44+
command_str = " ".join(command_arr)
45+
return command_arr, command_str
46+
47+
48+
def post_process_ycsb_results(stdout, start_time_ms, start_time_str):
49+
results_dict = {
50+
"Tests": {},
51+
"StartTime": start_time_ms,
52+
"StartTimeHuman": start_time_str,
53+
}
54+
if type(stdout) == bytes:
55+
stdout = stdout.decode("ascii")
56+
csv_data = list(csv.reader(stdout.splitlines(), delimiter=","))
57+
start_row = 0
58+
for row in csv_data:
59+
if len(row) >= 1:
60+
if "[OVERALL]" in row[0]:
61+
break
62+
start_row = start_row + 1
63+
for row in csv_data[start_row:]:
64+
if len(row) >= 3:
65+
op_group = row[0].strip()[1:-1]
66+
metric_name = row[1].strip()
67+
metric_name = re.sub("[^0-9a-zA-Z]+", "_", metric_name)
68+
value = row[2].strip()
69+
if op_group not in results_dict["Tests"]:
70+
results_dict["Tests"][op_group] = {}
71+
results_dict["Tests"][op_group][metric_name] = value
72+
return results_dict

redisbench_admin/run_local/args.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def create_run_local_arguments(parser):
33
parser.add_argument(
44
"--allowed-tools",
55
type=str,
6-
default="redis-benchmark,redisgraph-benchmark-go,ycsb",
6+
default="redis-benchmark,redisgraph-benchmark-go,ycsb,tsbs_run_queries_redistimeseries",
77
help="comma separated list of allowed tools for this module. By default all the supported are allowed.",
88
)
99
parser.add_argument(

redisbench_admin/run_remote/args.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def create_run_remote_arguments(parser):
1313
parser.add_argument(
1414
"--allowed-tools",
1515
type=str,
16-
default="redis-benchmark,redisgraph-benchmark-go,ycsb",
16+
default="redis-benchmark,redisgraph-benchmark-go,ycsb,tsbs_run_queries_redistimeseries",
1717
help="comma separated list of allowed tools for this module. By default all the supported are allowed.",
1818
)
1919
parser.add_argument(

redisbench_admin/run_remote/run_remote.py

+38
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
check_and_fix_pem_str,
3939
get_run_full_filename,
4040
fetch_remote_setup_from_config,
41+
execute_remote_commands,
4142
)
4243

4344
# internal aux vars
@@ -64,6 +65,23 @@
6465

6566

6667
# noinspection PyBroadException
68+
def setup_remote_benchmark_tool_requirements_tsbs_run_queries_redistimeseries(
69+
client_public_ip,
70+
username,
71+
private_key,
72+
tool_link,
73+
queries_file_link,
74+
remote_tool_link="/tmp/tsbs_run_queries_redistimeseries",
75+
remote_queries_file="/tmp/queries-file.input",
76+
):
77+
commands = [
78+
"wget {} -q -O {}".format(tool_link, remote_tool_link),
79+
"wget {} -q -O {}".format(queries_file_link, remote_queries_file),
80+
"chmod 755 {}".format(remote_tool_link),
81+
]
82+
execute_remote_commands(client_public_ip, username, private_key, commands)
83+
84+
6785
def run_remote_command_logic(args):
6886
tf_bin_path = args.terraform_bin_path
6987
tf_github_org = args.github_org
@@ -345,6 +363,26 @@ def run_remote_command_logic(args):
345363
private_key,
346364
redisbenchmark_go_link,
347365
)
366+
if benchmark_tool == "tsbs_run_queries_redistimeseries":
367+
tool_link = (
368+
"https://s3.amazonaws.com/benchmarks.redislabs/"
369+
+ "redistimeseries/tools/tsbs/tsbs_run_queries_redistimeseries_linux_amd64"
370+
)
371+
372+
queries_file_link = None
373+
for entry in benchmark_config["clientconfig"]:
374+
if "parameters" in entry:
375+
for parameter in entry["parameters"]:
376+
if "file" in parameter:
377+
queries_file_link = parameter["file"]
378+
379+
setup_remote_benchmark_tool_requirements_tsbs_run_queries_redistimeseries(
380+
client_public_ip,
381+
username,
382+
private_key,
383+
tool_link,
384+
queries_file_link,
385+
)
348386

349387
if (
350388
benchmark_min_tool_version is not None

redisbench_admin/utils/local.py

+32-23
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,43 @@ def check_dataset_local_requirements(
2323
if "dataset" in k:
2424
dataset = k["dataset"]
2525
if dataset is not None:
26-
if dataset.startswith("http"):
27-
if not os.path.isdir(datasets_localtemp_dir):
28-
os.mkdir(datasets_localtemp_dir)
29-
filename = dataset.split("/")[-1]
30-
full_path = "{}/{}".format(datasets_localtemp_dir, filename)
31-
if not os.path.exists(full_path):
32-
logging.info(
33-
"Retrieving remote file from {} to {}. Using the dir {} as a cache for next time.".format(
34-
dataset, full_path, datasets_localtemp_dir
35-
)
36-
)
37-
wget.download(dataset, full_path)
38-
else:
39-
logging.info(
40-
"Reusing cached remote file (located at {} ).".format(full_path)
41-
)
42-
else:
43-
full_path = dataset
44-
if dirname is not None:
45-
full_path = "{}/{}".format(dirname, full_path)
46-
logging.info(
47-
"Copying rdb from {} to {}/dump.rdb".format(full_path, redis_dbdir)
48-
)
26+
full_path = check_if_needs_remote_fetch(
27+
dataset, datasets_localtemp_dir, dirname
28+
)
4929
tmp_path = "{}/dump.rdb".format(redis_dbdir)
30+
logging.info(
31+
"Copying rdb from {} to {}/dump.rdb".format(full_path, redis_dbdir)
32+
)
5033
copyfile(full_path, tmp_path)
5134
return dataset, full_path, tmp_path
5235

5336

37+
def check_if_needs_remote_fetch(property, localtemp_dir, dirname, full_path=None):
38+
if property.startswith("http"):
39+
if not os.path.isdir(localtemp_dir):
40+
os.mkdir(localtemp_dir)
41+
if full_path is None:
42+
filename = property.split("/")[-1]
43+
full_path = "{}/{}".format(localtemp_dir, filename)
44+
if not os.path.exists(full_path):
45+
logging.info(
46+
"Retrieving remote file from {} to {}. Using the dir {} as a cache for next time.".format(
47+
property, full_path, localtemp_dir
48+
)
49+
)
50+
wget.download(property, full_path)
51+
else:
52+
logging.info(
53+
"Reusing cached remote file (located at {} ).".format(full_path)
54+
)
55+
else:
56+
full_path = property
57+
if dirname is not None:
58+
full_path = "{}/{}".format(dirname, full_path)
59+
60+
return full_path
61+
62+
5463
def wait_for_conn(conn, retries=20, command="PING", should_be=True):
5564
"""Wait until a given Redis connection is ready"""
5665
result = False
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: "tsbs-scale100-cpu-max-all-1"
2+
remote:
3+
- type: oss-standalone
4+
- setup: redistimeseries-m5
5+
dbconfig:
6+
- dataset: "https://s3.amazonaws.com/benchmarks.redislabs/redistimeseries/tsbs/datasets/devops/scale100/devops-scale100-4days.rdb"
7+
clientconfig:
8+
- tool: tsbs_run_queries_redistimeseries
9+
- parameters:
10+
- workers: 64
11+
- file: "https://s3.amazonaws.com/benchmarks.redislabs/redistimeseries/tsbs/queries/devops/scale100/devops-scale100-4days/queries_cpu-only_redistimeseries_100_cpu-max-all-1_10000_123_2016-01-01T00%3A00%3A00Z_2016-01-04T00%3A00%3A00Z.dat"

0 commit comments

Comments
 (0)