Skip to content

Commit 08c6460

Browse files
[add] Added target tables grafana logic (#247)
* [add] Added target tables grafana logic * [fix] Fixes based on beelit94/python-terraform#108 * Bumping version from 0.5.21 to 0.5.22
1 parent 8390622 commit 08c6460

File tree

6 files changed

+240
-130
lines changed

6 files changed

+240
-130
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redisbench-admin"
3-
version = "0.5.21"
3+
version = "0.5.22"
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]>","Redis Performance Group <[email protected]>"]
66
readme = "README.md"

redisbench_admin/run/grafana.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# BSD 3-Clause License
2+
#
3+
# Copyright (c) 2021., Redis Labs Modules
4+
# All rights reserved.
5+
#
6+
import logging
7+
8+
import pytablewriter
9+
from pytablewriter import MarkdownTableWriter
10+
11+
12+
def generate_artifacts_table_grafana_redis(
13+
args,
14+
grafana_profile_dashboard,
15+
profile_artifacts,
16+
rts,
17+
setup_name,
18+
start_time_ms,
19+
start_time_str,
20+
test_name,
21+
tf_github_org,
22+
tf_github_repo,
23+
tf_github_sha,
24+
tf_github_branch,
25+
):
26+
logging.info("Printing profiler generated artifacts")
27+
table_name = "Profiler artifacts for test case {}".format(test_name)
28+
headers = ["artifact_name", "s3_link"]
29+
profilers_final_matrix = []
30+
profilers_final_matrix_html = []
31+
for artifact in profile_artifacts:
32+
profilers_final_matrix.append(
33+
[
34+
artifact["artifact_name"],
35+
artifact["s3_link"],
36+
]
37+
)
38+
profilers_final_matrix_html.append(
39+
[
40+
artifact["artifact_name"],
41+
' <a href="{}">{}</a>'.format(
42+
artifact["s3_link"],
43+
artifact["s3_link"],
44+
),
45+
]
46+
)
47+
writer = MarkdownTableWriter(
48+
table_name=table_name,
49+
headers=headers,
50+
value_matrix=profilers_final_matrix,
51+
)
52+
writer.write_table()
53+
htmlwriter = pytablewriter.HtmlTableWriter(
54+
table_name=table_name,
55+
headers=headers,
56+
value_matrix=profilers_final_matrix_html,
57+
)
58+
profile_markdown_str = htmlwriter.dumps()
59+
profile_markdown_str = profile_markdown_str.replace("\n", "")
60+
profile_id = "{}_{}_hash_{}".format(start_time_str, setup_name, tf_github_sha)
61+
profile_string_testcase_markdown_key = "profile:{}:{}".format(profile_id, test_name)
62+
zset_profiles = "profiles:{}_{}_{}".format(
63+
tf_github_org, tf_github_repo, setup_name
64+
)
65+
zset_profiles_setup = "profiles:setups:{}_{}".format(
66+
tf_github_org,
67+
tf_github_repo,
68+
)
69+
profile_set_redis_key = "profile:{}:testcases".format(profile_id)
70+
zset_profiles_setups_testcases = "profiles:testcases:{}_{}_{}".format(
71+
tf_github_org,
72+
tf_github_repo,
73+
setup_name,
74+
)
75+
zset_profiles_setups_testcases_profileid = "profiles:ids:{}_{}_{}_{}_{}".format(
76+
tf_github_org,
77+
tf_github_repo,
78+
setup_name,
79+
test_name,
80+
tf_github_branch,
81+
)
82+
zset_profiles_setups_testcases_branches = "profiles:branches:{}_{}_{}_{}".format(
83+
tf_github_org, tf_github_repo, setup_name, test_name
84+
)
85+
zset_profiles_setups_testcases_branches_latest_link = (
86+
"latest_profiles:by.branch:{}_{}_{}_{}".format(
87+
tf_github_org, tf_github_repo, setup_name, test_name
88+
)
89+
)
90+
https_link = "{}?var-org={}&var-repo={}&var-setup={}&var-branch={}".format(
91+
grafana_profile_dashboard,
92+
tf_github_org,
93+
tf_github_repo,
94+
setup_name,
95+
tf_github_branch,
96+
) + "&var-test_case={}&var-profile_id={}".format(
97+
test_name,
98+
profile_id,
99+
)
100+
if args.push_results_redistimeseries:
101+
rts.redis.zadd(
102+
zset_profiles_setups_testcases_branches,
103+
{tf_github_branch: start_time_ms},
104+
)
105+
rts.redis.zadd(
106+
zset_profiles_setups_testcases_branches_latest_link,
107+
{https_link: start_time_ms},
108+
)
109+
rts.redis.zadd(
110+
zset_profiles_setup,
111+
{setup_name: start_time_ms},
112+
)
113+
rts.redis.zadd(
114+
zset_profiles_setups_testcases,
115+
{test_name: start_time_ms},
116+
)
117+
rts.redis.zadd(
118+
zset_profiles_setups_testcases_profileid,
119+
{profile_id: start_time_ms},
120+
)
121+
rts.redis.zadd(
122+
zset_profiles,
123+
{profile_id: start_time_ms},
124+
)
125+
rts.redis.sadd(profile_set_redis_key, test_name)
126+
rts.redis.set(
127+
profile_string_testcase_markdown_key,
128+
profile_markdown_str,
129+
)
130+
logging.info(
131+
"Store html table with artifacts in: {}".format(
132+
profile_string_testcase_markdown_key
133+
)
134+
)
135+
return https_link

redisbench_admin/run/redistimeseries.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ def timeseries_test_sucess_flow(
240240
timeseries_dict=None,
241241
):
242242
testcase_metric_context_paths = []
243+
version_target_tables = None
244+
branch_target_tables = None
245+
243246
if timeseries_dict is None:
244247
(
245248
timeseries_dict,
@@ -286,6 +289,8 @@ def timeseries_test_sucess_flow(
286289
version_target_table_keyname
287290
)
288291
)
292+
if "contains-target" in version_target_table_dict:
293+
del version_target_table_dict["contains-target"]
289294
rts.redis.hset(
290295
version_target_table_keyname, None, None, version_target_table_dict
291296
)
@@ -305,6 +310,8 @@ def timeseries_test_sucess_flow(
305310
version_target_table_keyname
306311
)
307312
)
313+
if "contains-target" in branch_target_table_dict:
314+
del branch_target_table_dict["contains-target"]
308315
rts.redis.hset(
309316
branch_target_table_keyname, None, None, branch_target_table_dict
310317
)
@@ -327,6 +334,7 @@ def timeseries_test_sucess_flow(
327334
tf_github_repo,
328335
tf_triggering_env,
329336
)
337+
return version_target_tables, branch_target_tables
330338

331339

332340
def update_secondary_result_keys(

0 commit comments

Comments
 (0)