Skip to content

Commit ebf84b6

Browse files
[fix] checking if we're in a git repo prior filling the git vars (#162)
1 parent 11ca257 commit ebf84b6

File tree

7 files changed

+71
-30
lines changed

7 files changed

+71
-30
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.3.3"
3+
version = "0.3.4"
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_local/local_helpers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def check_benchmark_binaries_local_requirements(
3939
benchmark_tool,
4040
tool_source,
4141
tool_source_bin_path,
42+
_,
4243
) = extract_benchmark_tool_settings(benchmark_config)
4344
which_benchmark_tool = None
4445
if benchmark_tool is not None:

redisbench_admin/run_remote/run_remote.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ def run_remote_command_logic(args, project_name, project_version):
331331
benchmark_tool,
332332
benchmark_tool_source,
333333
_,
334+
_,
334335
) = extract_benchmark_tool_settings(benchmark_config)
335336
benchmark_tools_sanity_check(args, benchmark_tool)
336337
# setup the benchmark tool

redisbench_admin/utils/benchmark_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def extract_benchmark_tool_settings(benchmark_config):
235235
benchmark_min_tool_version_major = None
236236
benchmark_min_tool_version_minor = None
237237
benchmark_min_tool_version_patch = None
238-
238+
benchmark_tool_property_map = benchmark_config["clientconfig"]
239239
for entry in benchmark_config["clientconfig"]:
240240
if "tool" in entry:
241241
benchmark_tool = entry["tool"]
@@ -268,6 +268,7 @@ def extract_benchmark_tool_settings(benchmark_config):
268268
benchmark_tool,
269269
benchmark_tool_source,
270270
benchmark_tool_source_inner_path,
271+
benchmark_tool_property_map,
271272
)
272273

273274

redisbench_admin/utils/remote.py

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -239,39 +239,53 @@ def tf_output_or_none(tf_output, output_prop):
239239

240240

241241
def extract_git_vars(path=None, github_url=None):
242-
if path is None:
243-
path = get_git_root(".")
244-
github_repo = Repo(path)
245-
if github_url is None:
246-
github_url = github_repo.remotes[0].config_reader.get("url")
247-
if "/" in github_url[-1:]:
248-
github_url = github_url[:-1]
249-
if "http" in github_url:
250-
github_org_name = github_url.split("/")[-2]
251-
github_repo_name = github_url.split("/")[-1].split(".")[0]
252-
else:
253-
github_url = github_url.replace(".git", "")
254-
github_org_name = github_url.split(":")[1].split("/")[0]
255-
github_repo_name = github_url.split(":")[1].split("/")[1]
256-
github_sha = github_repo.head.object.hexsha
242+
github_org_name = None
243+
github_repo_name = None
244+
github_sha = None
245+
github_actor = None
257246
github_branch = None
258-
github_branch_detached = False
247+
github_branch_detached = None
259248
try:
260-
github_branch = github_repo.active_branch
261-
except TypeError as e:
262-
logging.warning(
263-
"Unable to detected github_branch. caught the following error: {}".format(
264-
e.__str__()
249+
if path is None:
250+
path = get_git_root(".")
251+
github_repo = Repo(path)
252+
if github_url is None:
253+
github_url = github_repo.remotes[0].config_reader.get("url")
254+
if "/" in github_url[-1:]:
255+
github_url = github_url[:-1]
256+
if "http" in github_url:
257+
github_org_name = github_url.split("/")[-2]
258+
github_repo_name = github_url.split("/")[-1].split(".")[0]
259+
else:
260+
github_url = github_url.replace(".git", "")
261+
github_org_name = github_url.split(":")[1].split("/")[0]
262+
github_repo_name = github_url.split(":")[1].split("/")[1]
263+
github_sha = github_repo.head.object.hexsha
264+
github_branch = None
265+
github_branch_detached = False
266+
try:
267+
github_branch = github_repo.active_branch
268+
except TypeError as e:
269+
logging.warning(
270+
"Unable to detected github_branch. caught the following error: {}".format(
271+
e.__str__()
272+
)
265273
)
266-
)
267-
github_branch_detached = True
274+
github_branch_detached = True
268275

269-
github_actor = None
270-
try:
271-
github_actor = github_repo.config_reader().get_value("user", "name")
272-
except configparser.NoSectionError as e:
276+
github_actor = None
277+
try:
278+
github_actor = github_repo.config_reader().get_value("user", "name")
279+
except configparser.NoSectionError as e:
280+
logging.warning(
281+
"Unable to detected github_actor. caught the following error: {}".format(
282+
e.__str__()
283+
)
284+
)
285+
github_branch_detached = True
286+
except git.exc.InvalidGitRepositoryError as e:
273287
logging.warning(
274-
"Unable to detected github_actor. caught the following error: {}".format(
288+
"Unable to fill git vars. caught the following error: {}".format(
275289
e.__str__()
276290
)
277291
)

tests/test_common.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def test_extract_benchmark_tool_settings():
9999
benchmark_tool,
100100
benchmark_tool_source,
101101
benchmark_tool_source_bin_path,
102+
_,
102103
) = extract_benchmark_tool_settings(benchmark_config)
103104
assert benchmark_tool is not None
104105
prepare_benchmark_parameters(
@@ -117,6 +118,25 @@ def test_extract_benchmark_tool_settings_with_remote():
117118
benchmark_tool,
118119
benchmark_tool_source,
119120
benchmark_tool_source_bin_path,
121+
_,
122+
) = extract_benchmark_tool_settings(benchmark_config)
123+
assert benchmark_tool is not None
124+
assert benchmark_tool_source is not None
125+
assert benchmark_tool_source_bin_path is not None
126+
127+
128+
def test_extract_benchmark_tool_settings_with_resource():
129+
with open("./tests/test_data/ycsb-config.yml", "r") as yml_file:
130+
benchmark_config = yaml.safe_load(yml_file)
131+
(
132+
benchmark_min_tool_version,
133+
benchmark_min_tool_version_major,
134+
benchmark_min_tool_version_minor,
135+
benchmark_min_tool_version_patch,
136+
benchmark_tool,
137+
benchmark_tool_source,
138+
benchmark_tool_source_bin_path,
139+
benchmark_tool_property_map,
120140
) = extract_benchmark_tool_settings(benchmark_config)
121141
assert benchmark_tool is not None
122142
assert benchmark_tool_source is not None

tests/test_data/redis-benchmark.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ clientconfig:
1313
- threads: 1
1414
- pipeline: 1
1515
- command: '"TS.MRANGE" "1609613705646" "1609617305646" "WITHLABELS" "AGGREGATION" "MAX" "60000" "FILTER" "measurement=cpu" "fieldname=usage_user" "hostname=(host_49,host_3,host_35,host_39,host_75,host_15,host_21,host_11)" "GROUPBY" "hostname" "REDUCE" "max"'
16+
- resources:
17+
requests:
18+
cpus: "2"
19+
memory: "2g"

0 commit comments

Comments
 (0)