Skip to content

Commit e91dde2

Browse files
[fix] Added platform runner info to datasink; [fix] Added metadata info to datasink; [fix] each build variant is now associated with the proper time-serie in datasink (#21)
1 parent 0aa9a53 commit e91dde2

File tree

15 files changed

+161
-34
lines changed

15 files changed

+161
-34
lines changed

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redis-benchmarks-specification"
3-
version = "0.1.3"
3+
version = "0.1.4"
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 <filipecosta.90@gmail.com>"]
66
readme = "Readme.md"
@@ -16,7 +16,7 @@ argparse = "^1.4.0"
1616
Flask-HTTPAuth = "^4.4.0"
1717
PyYAML = "^5.4.1"
1818
docker = "^4.4.4"
19-
redisbench-admin = "^0.4.11"
19+
redisbench-admin = "^0.4.14"
2020
psutil = "^5.8.0"
2121
tox-docker = "^3.0.0"
2222

redis_benchmarks_specification/__builder__/builder.py

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import argparse
22
import io
3+
import json
34
import logging
45
import tempfile
56
import shutil
6-
77
import docker
88
import redis
99
import os
1010
from zipfile import ZipFile, ZipInfo
1111

12-
from redis_benchmarks_specification.__builder__.schema import get_build_config
12+
from redis_benchmarks_specification.__builder__.schema import (
13+
get_build_config,
14+
get_build_config_metadata,
15+
)
1316
from redis_benchmarks_specification.__common__.env import (
1417
STREAM_KEYNAME_GH_EVENTS_COMMIT,
1518
GH_REDIS_SERVER_HOST,
@@ -170,6 +173,8 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
170173

171174
for build_spec in different_build_specs:
172175
build_config, id = get_build_config(builders_folder + "/" + build_spec)
176+
build_config_metadata = get_build_config_metadata(build_config)
177+
173178
build_image = build_config["build_image"]
174179
run_image = build_image
175180
if "run_image" in build_config:
@@ -242,6 +247,7 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
242247
"arch": build_arch,
243248
"build_vars": build_vars_str,
244249
"build_command": build_command,
250+
"metadata": json.dumps(build_config_metadata),
245251
"build_artifacts": ",".join(build_artifacts),
246252
}
247253
if git_branch is not None:
@@ -266,11 +272,25 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
266272
)
267273
shutil.rmtree(temporary_dir, ignore_errors=True)
268274
new_builds_count = new_builds_count + 1
269-
conn.xack(
270-
STREAM_GH_EVENTS_COMMIT_BUILDERS_CG,
275+
ack_reply = conn.xack(
271276
STREAM_KEYNAME_GH_EVENTS_COMMIT,
277+
STREAM_GH_EVENTS_COMMIT_BUILDERS_CG,
272278
streamId,
273279
)
280+
if type(ack_reply) == bytes:
281+
ack_reply = ack_reply.decode()
282+
if ack_reply == "1":
283+
logging.info(
284+
"Sucessfully acknowledge build variation stream with id {}.".format(
285+
streamId
286+
)
287+
)
288+
else:
289+
logging.error(
290+
"Unable to acknowledge build variation stream with id {}. XACK reply {}".format(
291+
streamId, ack_reply
292+
)
293+
)
274294
else:
275295
logging.error("Missing commit information within received message.")
276296
return previous_id, new_builds_count
@@ -279,6 +299,7 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
279299
def build_spec_image_prefetch(builders_folder, different_build_specs):
280300
logging.info("checking build spec requirements")
281301
already_checked_images = []
302+
client = docker.from_env()
282303
for build_spec in different_build_specs:
283304
build_config, id = get_build_config(builders_folder + "/" + build_spec)
284305
if build_config["kind"] == "docker":
@@ -289,19 +310,24 @@ def build_spec_image_prefetch(builders_folder, different_build_specs):
289310
id, build_image
290311
)
291312
)
292-
import docker
293-
294-
client = docker.from_env()
295-
image = client.images.pull(build_image)
296-
logging.info(
297-
"Build {} requirement: build image {} is available with id: {}.".format(
298-
id, build_image, image.id
313+
if build_image not in client.images.list():
314+
logging.info(
315+
"Build {} requirement: build image {} is not available locally. Fetching it from hub".format(
316+
id, build_image
317+
)
318+
)
319+
client.images.pull(build_image)
320+
else:
321+
logging.info(
322+
"Build {} requirement: build image {} is available locally.".format(
323+
id, build_image
324+
)
299325
)
300-
)
301326
already_checked_images.append(build_image)
302327
else:
303328
logging.info(
304329
"Build {} requirement: build image {} availability was already checked.".format(
305330
id, build_image
306331
)
307332
)
333+
return already_checked_images

redis_benchmarks_specification/__builder__/schema.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ def get_build_config(usecase_filename):
1414
# print(build_config)
1515
id = build_config["id"]
1616
return build_config, id
17+
18+
19+
def get_build_config_metadata(build_config):
20+
build_config_metadata = {}
21+
if "metadata" in build_config:
22+
build_config_metadata = build_config["metadata"]
23+
return build_config_metadata

redis_benchmarks_specification/__common__/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@
6262
LOG_LEVEL = logging.WARN
6363

6464
MACHINE_CPU_COUNT = psutil.cpu_count()
65+
MACHINE_NAME = os.uname()[1]

redis_benchmarks_specification/__self_contained_coordinator__/args.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
DATASINK_RTS_AUTH,
1010
DATASINK_RTS_USER,
1111
DATASINK_RTS_PUSH,
12+
MACHINE_NAME,
1213
)
1314

1415

@@ -23,6 +24,12 @@ def create_self_contained_coordinator_args():
2324
default=MACHINE_CPU_COUNT,
2425
help="Specify how much of the available CPU resources the coordinator can use.",
2526
)
27+
parser.add_argument(
28+
"--platform-name",
29+
type=str,
30+
default=MACHINE_NAME,
31+
help="Specify the running platform name. By default it will use the machine name.",
32+
)
2633
parser.add_argument(
2734
"--logname", type=str, default=None, help="logname to write the logs to"
2835
)

redis_benchmarks_specification/__self_contained_coordinator__/self_contained_coordinator.py

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def main():
110110
)
111111
logging.error("Error message {}".format(e.__str__()))
112112
exit(1)
113+
rts = None
113114
if args.datasink_push_results_redistimeseries:
114115
logging.info(
115116
"Checking redistimeseries datasink connection is available at: {}:{} to push the timeseries data".format(
@@ -124,7 +125,7 @@ def main():
124125
password=args.datasink_redistimeseries_pass,
125126
username=args.datasink_redistimeseries_user,
126127
)
127-
rts.ping()
128+
rts.redis.ping()
128129
except redis.exceptions.ConnectionError as e:
129130
logging.error(
130131
"Unable to connect to redis available at: {}:{}".format(
@@ -156,6 +157,7 @@ def main():
156157
rts,
157158
testsuite_spec_files,
158159
topologies_map,
160+
args.platform_name,
159161
)
160162

161163

@@ -189,6 +191,7 @@ def self_contained_coordinator_blocking_read(
189191
rts,
190192
testsuite_spec_files,
191193
topologies_map,
194+
platform_name,
192195
):
193196
num_process_streams = 0
194197
overall_result = False
@@ -213,8 +216,29 @@ def self_contained_coordinator_blocking_read(
213216
rts,
214217
testsuite_spec_files,
215218
topologies_map,
219+
platform_name,
216220
)
217221
num_process_streams = num_process_streams + 1
222+
if overall_result is True:
223+
ack_reply = conn.xack(
224+
STREAM_KEYNAME_NEW_BUILD_EVENTS,
225+
STREAM_GH_NEW_BUILD_RUNNERS_CG,
226+
stream_id,
227+
)
228+
if type(ack_reply) == bytes:
229+
ack_reply = ack_reply.decode()
230+
if ack_reply == "1":
231+
logging.info(
232+
"Sucessfully acknowledge build variation stream with id {}.".format(
233+
stream_id
234+
)
235+
)
236+
else:
237+
logging.error(
238+
"Unable to acknowledge build variation stream with id {}. XACK reply {}".format(
239+
stream_id, ack_reply
240+
)
241+
)
218242
return overall_result, stream_id, num_process_streams
219243

220244

@@ -226,6 +250,7 @@ def process_self_contained_coordinator_stream(
226250
rts,
227251
testsuite_spec_files,
228252
topologies_map,
253+
running_platform,
229254
):
230255
stream_id, testDetails = newTestInfo[0][1][0]
231256
stream_id = stream_id.decode()
@@ -234,6 +259,8 @@ def process_self_contained_coordinator_stream(
234259

235260
if b"git_hash" in testDetails:
236261
(
262+
build_variant_name,
263+
metadata,
237264
build_artifacts,
238265
git_hash,
239266
git_branch,
@@ -276,8 +303,14 @@ def process_self_contained_coordinator_stream(
276303
testcases_setname,
277304
tsname_project_total_failures,
278305
tsname_project_total_success,
306+
running_platforms_setname,
307+
testcases_build_variant_setname,
279308
) = get_overall_dashboard_keynames(
280-
tf_github_org, tf_github_repo, tf_triggering_env
309+
tf_github_org,
310+
tf_github_repo,
311+
tf_triggering_env,
312+
build_variant_name,
313+
running_platform,
281314
)
282315

283316
benchmark_tool = "redis-benchmark"
@@ -447,6 +480,9 @@ def process_self_contained_coordinator_stream(
447480
tf_github_repo,
448481
tf_triggering_env,
449482
tsname_project_total_success,
483+
metadata,
484+
build_variant_name,
485+
running_platform,
450486
)
451487
test_result = True
452488

@@ -505,7 +541,13 @@ def get_benchmark_specs(testsuites_folder):
505541
def extract_build_info_from_streamdata(testDetails):
506542
git_version = None
507543
git_branch = None
544+
metadata = None
545+
build_variant_name = None
508546
git_hash = testDetails[b"git_hash"]
547+
if b"id" in testDetails:
548+
build_variant_name = testDetails[b"id"]
549+
if type(build_variant_name) == bytes:
550+
build_variant_name = build_variant_name.decode()
509551
if b"git_branch" in testDetails:
510552
git_branch = testDetails[b"git_branch"]
511553
if type(git_branch) == bytes:
@@ -525,7 +567,17 @@ def extract_build_info_from_streamdata(testDetails):
525567
if b"build_artifacts" in testDetails:
526568
build_artifacts_str = testDetails[b"build_artifacts"].decode()
527569
build_artifacts = build_artifacts_str.split(",")
528-
return build_artifacts, git_hash, git_branch, git_version, run_image
570+
if b"metadata" in testDetails:
571+
metadata = json.loads(testDetails[b"metadata"].decode())
572+
return (
573+
build_variant_name,
574+
metadata,
575+
build_artifacts,
576+
git_hash,
577+
git_branch,
578+
git_version,
579+
run_image,
580+
)
529581

530582

531583
def generate_cpuset_cpus(ceil_db_cpu_limit, current_cpu_pos):

redis_benchmarks_specification/test-suites/redis-benchmark-full-suite-1Mkeys-100B.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: 0.4
22
name: "redis-benchmark-full-suite-1Mkeys-100B"
33
description: "Runs the default redis-benchmark test suite, for a keyspace length of 1M keys
44
with a data size of 100 Bytes for each key. On total 50 concurrent connections
5-
will be used, sending 5M requests."
5+
will be used, sending 1M requests."
66
dbconfig:
77
- configuration-parameters:
88
- save: '""'
@@ -29,13 +29,13 @@ clientconfig:
2929
min-tool-version: "6.2.0"
3030
parameters:
3131
- clients: 50
32-
- requests: 100000
33-
- threads: 2
32+
- requests: 1000000
33+
- threads: 3
3434
- pipeline: 1
3535
- r: 1000000
3636
resources:
3737
requests:
38-
cpus: "2"
38+
cpus: "3"
3939
memory: "2g"
4040
exporter:
4141
redistimeseries:

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[testenv:integration-tests]
22
deps = -r{toxinidir}/utils/test-requirements.txt
3-
passenv = TST_BUILDER_X TST_RUNNER_X
3+
passenv = TST_BUILDER_X TST_RUNNER_X TST_RUNNER_USE_RDB
44

55
commands =
66
black --check redis_benchmarks_specification

utils/tests/test_builder.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,23 @@
1111
from redis_benchmarks_specification.__builder__.builder import (
1212
builder_consumer_group_create,
1313
builder_process_stream,
14+
build_spec_image_prefetch,
1415
)
1516
from redis_benchmarks_specification.__common__.env import (
1617
STREAM_KEYNAME_GH_EVENTS_COMMIT,
1718
STREAM_KEYNAME_NEW_BUILD_EVENTS,
1819
)
1920

2021

22+
def test_build_spec_image_prefetch():
23+
builders_folder = "./redis_benchmarks_specification/setups/builders"
24+
different_build_specs = ["gcc:8.5.0-amd64-debian-buster-default.yml"]
25+
prefetched_images = build_spec_image_prefetch(
26+
builders_folder, different_build_specs
27+
)
28+
assert "gcc:8.5.0-buster" in prefetched_images
29+
30+
2131
def test_commit_schema_to_stream_then_build():
2232
try:
2333
run_builder = True

0 commit comments

Comments
 (0)