Skip to content

Commit 5334ed5

Browse files
[add] Using strings to store the binaries produced by tooling (#50)
* [add] Using strings to store the binaries produced by tooling * Bumping version from 0.1.12 to 0.1.13
1 parent 464483f commit 5334ed5

File tree

12 files changed

+82
-46
lines changed

12 files changed

+82
-46
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 = "redis-benchmarks-specification"
3-
version = "0.1.12"
3+
version = "0.1.13"
44
description = "The Redis benchmarks specification describes the cross-language/tools requirements and expectations to foster performance and observability standards around redis related technologies. Members from both industry and academia, including organizations and individuals are encouraged to contribute."
55
authors = ["filipecosta90 <[email protected]>","Redis Performance Group <[email protected]>"]
66
readme = "Readme.md"

redis_benchmarks_specification/__api__/app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@ def base():
9797
event_type = "Git pushes to repo"
9898

9999
if use_event is True:
100-
fields = {"git_hash": sha, "ref_label": ref_label, "ref": ref}
100+
fields = {
101+
"git_hash": sha,
102+
"ref_label": ref_label,
103+
"ref": ref,
104+
"gh_repo": gh_repo,
105+
"gh_org": gh_org,
106+
}
101107
app.logger.info(
102108
"Using event {} to trigger benchmark. final fields: {}".format(
103109
event_type, fields

redis_benchmarks_specification/__builder__/builder.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,18 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
178178
if b"git_hash" in testDetails:
179179
git_hash = testDetails[b"git_hash"]
180180
logging.info("Received commit hash specifier {}.".format(git_hash))
181-
buffer = testDetails[b"zip_archive"]
181+
binary_zip_key = testDetails[b"zip_archive_key"]
182+
logging.info(
183+
"Retriving zipped source from key {}.".format(
184+
testDetails[b"zip_archive_key"]
185+
)
186+
)
187+
buffer = conn.get(binary_zip_key)
182188
git_branch = None
183189
if b"git_branch" in testDetails:
184190
git_branch = testDetails[b"git_branch"]
191+
if b"ref_label" in testDetails:
192+
git_branch = testDetails[b"ref_label"]
185193
git_timestamp_ms = None
186194
use_git_timestamp = False
187195
if b"use_git_timestamp" in testDetails:
@@ -274,10 +282,13 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
274282
if git_timestamp_ms is not None:
275283
build_stream_fields["git_timestamp_ms"] = git_timestamp_ms
276284
for artifact in build_artifacts:
285+
bin_key = "zipped:artifacts:{}:{}.zip".format(id, artifact)
277286
bin_artifact = open(
278287
"{}src/{}".format(redis_temporary_dir, artifact), "rb"
279288
).read()
280-
build_stream_fields[artifact] = bytes(bin_artifact)
289+
ttl = 24 * 7 * 60 * 60
290+
conn.set(bin_key, bytes(bin_artifact), ex=ttl)
291+
build_stream_fields[artifact] = bin_key
281292
build_stream_fields["{}_len_bytes".format(artifact)] = len(
282293
bytes(bin_artifact)
283294
)

redis_benchmarks_specification/__cli__/cli.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,20 @@ def main():
121121
)
122122
for rep in range(0, 1):
123123
for commit in Commits:
124-
result, error_msg, commit_dict, _ = get_commit_dict_from_sha(
124+
(
125+
result,
126+
error_msg,
127+
commit_dict,
128+
_,
129+
binary_key,
130+
binary_value,
131+
) = get_commit_dict_from_sha(
125132
commit.hexsha, "redis", "redis", {}, True, args.gh_token
126133
)
134+
binary_exp_secs = 24 * 7 * 60 * 60
127135
if result is True:
128136
result, reply_fields, error_msg = request_build_from_commit_info(
129-
conn, commit_dict, {}
137+
conn, commit_dict, {}, binary_key, binary_value, binary_exp_secs
130138
)
131139
logging.info(
132140
"Successfully requested a build for commit: {}. Request stream id: {}. Commit summary: {}".format(

redis_benchmarks_specification/__common__/builder_schema.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,25 @@ def commit_schema_to_stream(
3333
if "git_hash" not in fields:
3434
error_msg = "Missing required 'git_hash' field"
3535
else:
36-
result, error_msg, fields, _ = get_commit_dict_from_sha(
36+
(
37+
result,
38+
error_msg,
39+
fields,
40+
_,
41+
binary_key,
42+
binary_value,
43+
) = get_commit_dict_from_sha(
3744
fields["git_hash"], gh_org, gh_repo, fields, use_git_timestamp, gh_token
3845
)
3946
reply_fields["use_git_timestamp"] = fields["use_git_timestamp"]
4047
if "git_timestamp_ms" in fields:
4148
reply_fields["git_timestamp_ms"] = fields["git_timestamp_ms"]
4249
reply_fields["archived_zip"] = True
4350
if result is True:
51+
# 7 days expire
52+
binary_exp_secs = 24 * 60 * 60 * 7
4453
result, reply_fields, error_msg = request_build_from_commit_info(
45-
conn, fields, reply_fields
54+
conn, fields, reply_fields, binary_key, binary_value, binary_exp_secs
4655
)
4756

4857
return result, reply_fields, error_msg
@@ -51,22 +60,25 @@ def commit_schema_to_stream(
5160
def get_archive_zip_from_hash(gh_org, gh_repo, git_hash, fields):
5261
error_msg = None
5362
result = False
63+
binary_value = None
64+
bin_key = "zipped:source:{}/{}/archive/{}.zip".format(gh_org, gh_repo, git_hash)
5465
github_url = "https://github.com/{}/{}/archive/{}.zip".format(
5566
gh_org, gh_repo, git_hash
5667
)
5768
try:
5869
response = urlopen(github_url, timeout=5)
5970
content = response.read()
60-
fields["zip_archive"] = bytes(content)
71+
fields["zip_archive_key"] = bin_key
6172
fields["zip_archive_len"] = len(bytes(content))
73+
binary_value = bytes(content)
6274
result = True
6375
except URLError as e:
6476
error_msg = "Catched URLError while fetching {} content. Error {}".format(
6577
github_url, e.__str__()
6678
)
6779
logging.error(error_msg)
6880
result = False
69-
return result, error_msg
81+
return result, bin_key, binary_value, error_msg
7082

7183

7284
def get_commit_dict_from_sha(
@@ -91,13 +103,15 @@ def get_commit_dict_from_sha(
91103
commit_dict["use_git_timestamp"] = str(use_git_timestamp)
92104
commit_dict["git_hash"] = git_hash
93105

94-
result, error_msg = get_archive_zip_from_hash(
106+
result, binary_key, binary_value, error_msg = get_archive_zip_from_hash(
95107
gh_org, gh_repo, git_hash, commit_dict
96108
)
97-
return result, error_msg, commit_dict, commit
109+
return result, error_msg, commit_dict, commit, binary_key, binary_value
98110

99111

100-
def request_build_from_commit_info(conn, fields, reply_fields):
112+
def request_build_from_commit_info(
113+
conn, fields, reply_fields, binary_key, binary_value, binary_exp_secs
114+
):
101115
"""Generates a build event from the commit dictionary
102116
It expected the fields dictionary to contain at least the following keys:
103117
- "git_branch": reference to the branch that the commit refers to
@@ -118,6 +132,7 @@ def request_build_from_commit_info(conn, fields, reply_fields):
118132
"""
119133
result = True
120134
error_msg = None
135+
conn.set(binary_key, binary_value, ex=binary_exp_secs)
121136
for k, v in fields.items():
122137
if type(v) not in [str, int, float, bytes]:
123138
raise Exception(

redis_benchmarks_specification/__self_contained_coordinator__/self_contained_coordinator.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ def self_contained_coordinator_blocking_read(
233233
stream_id = ">"
234234
else:
235235
stream_id, overall_result = process_self_contained_coordinator_stream(
236+
conn,
236237
datasink_push_results_redistimeseries,
237238
docker_client,
238239
home,
@@ -267,6 +268,7 @@ def self_contained_coordinator_blocking_read(
267268

268269

269270
def process_self_contained_coordinator_stream(
271+
conn,
270272
datasink_push_results_redistimeseries,
271273
docker_client,
272274
home,
@@ -327,9 +329,15 @@ def process_self_contained_coordinator_stream(
327329

328330
benchmark_tool = "redis-benchmark"
329331
for build_artifact in build_artifacts:
330-
buffer = testDetails[
331-
bytes("{}".format(build_artifact).encode())
332+
buffer_key = testDetails[
333+
"{}".format(build_artifact).encode()
332334
]
335+
logging.info(
336+
"Reading artifact binary {} from key {}".format(
337+
build_artifact, buffer_key
338+
)
339+
)
340+
buffer = bytes(conn.get(buffer_key))
333341
artifact_fname = "{}/{}".format(
334342
temporary_dir, build_artifact
335343
)

utils/tests/test_api.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,14 @@ def test_commit_schema_to_stream():
5454

5555

5656
def test_get_commit_dict_from_sha():
57-
result, error_msg, commit_dict, _ = get_commit_dict_from_sha(
57+
(
58+
result,
59+
error_msg,
60+
commit_dict,
61+
_,
62+
binary_key,
63+
binary_value,
64+
) = get_commit_dict_from_sha(
5865
"492d8d09613cff88f15dcef98732392b8d509eb1", "redis", "redis", {}, True, GH_TOKEN
5966
)
6067
if GH_TOKEN is not None:

utils/tests/test_data/api_builder_common.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ def flow_1_and_2_api_builder_checks(conn):
1616
builder_consumer_group_create(conn)
1717
assert conn.xlen(STREAM_KEYNAME_GH_EVENTS_COMMIT) == 0
1818
result, reply_fields, error_msg = commit_schema_to_stream(
19-
'{"git_hash":"0cf2df84d4b27af4bffd2bf3543838f09e10f874", "git_branch":"unstable", "use_git_timestamp":true }',
19+
{
20+
"git_hash": "0cf2df84d4b27af4bffd2bf3543838f09e10f874",
21+
"git_branch": "unstable",
22+
"use_git_timestamp": True,
23+
},
2024
conn,
2125
"redis",
2226
"redis",

utils/tests/test_data/dump.rdb

278 Bytes
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
version: 0.1
2-
id: icc-2021.3.0-amd64-ubuntu18.04-monotonic-clock
2+
id: icc-2021.3.0-amd64-ubuntu18.04-libc
33
os: ubuntu18.04
44
arch: amd64
55
compiler: "icc"
@@ -16,5 +16,5 @@ metadata:
1616
arch: amd64
1717

1818
env:
19-
CFLAGS: "-DUSE_PROCESSOR_CLOCK"
19+
MALLOC: "libc"
2020

utils/tests/test_data/icc-2021.3.0-amd64-ubuntu18.04-monotonic-clock.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

utils/tests/test_schema.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
def test_get_build_config():
88
config_files = [
9-
"./utils/tests/test_data/icc-2021.3.0-amd64-ubuntu18.04-monotonic-clock.yml",
9+
"./utils/tests/test_data/icc-2021.3.0-amd64-ubuntu18.04-libc.yml",
1010
]
1111
for filename in config_files:
1212
build_config, id = get_build_config(filename)
13-
assert id == "icc-2021.3.0-amd64-ubuntu18.04-monotonic-clock"
14-
assert build_config["env"]["CC"] == "icc"
13+
assert id == "icc-2021.3.0-amd64-ubuntu18.04-libc"
14+
assert build_config["env"]["MALLOC"] == "libc"
1515

1616

1717
def test_get_build_config_metadata():
1818
build_config, _ = get_build_config(
19-
"./utils/tests/test_data/icc-2021.3.0-amd64-ubuntu18.04-monotonic-clock.yml"
19+
"./utils/tests/test_data/icc-2021.3.0-amd64-ubuntu18.04-libc.yml"
2020
)
2121
build_config_metadata = get_build_config_metadata(build_config)
2222
for k in ["arch", "compiler", "compiler_version", "os"]:

0 commit comments

Comments
 (0)