Skip to content

[add] Added redis-benchmarks-spec-cli trigger tool; Enabling historical data benchmarks triggering #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 71 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "redis-benchmarks-specification"
version = "0.1.8"
version = "0.1.9"
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."
authors = ["filipecosta90 <filipecosta.90@gmail.com>"]
readme = "Readme.md"
Expand All @@ -19,6 +19,8 @@ docker = "^4.4.4"
redisbench-admin = "^0.4.16"
psutil = "^5.8.0"
tox-docker = "^3.0.0"
PyGithub = "^1.55"
GitPython = "^3.1.20"

[tool.poetry.dev-dependencies]
black = "20.8b1"
Expand All @@ -37,3 +39,4 @@ build-backend = "poetry.core.masonry.api"
redis-benchmarks-spec-api = "redis_benchmarks_specification.__api__.api:main"
redis-benchmarks-spec-builder = "redis_benchmarks_specification.__builder__.builder:main"
redis-benchmarks-spec-sc-coordinator = "redis_benchmarks_specification.__self_contained_coordinator__.self_contained_coordinator:main"
redis-benchmarks-spec-cli = "redis_benchmarks_specification.__cli__.cli:main"
21 changes: 12 additions & 9 deletions redis_benchmarks_specification/__api__/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from flask_httpauth import HTTPBasicAuth

from redis_benchmarks_specification.__api__.schema import (
commit_schema_to_stream,
CommitSchema,
)
from redis_benchmarks_specification.__common__.builder_schema import (
commit_schema_to_stream,
)
from redis_benchmarks_specification.__common__.env import (
REDIS_AUTH_SERVER_HOST,
REDIS_AUTH_SERVER_PORT,
Expand Down Expand Up @@ -43,20 +45,21 @@ def verify_password(username, password):
def base():
# Get Request body from JSON
request_data = request.json
gh_org = "redis"
gh_repo = "redis"
schema = CommitSchema()
try:
# Validate request body against schema data types
result = schema.load(request_data)
except ValidationError as err:
# Return a nice message if validation fails
return jsonify(err.messages), 400
err_message = err.messages
if result is True:
# Convert request body back to JSON str
data_now_json_str = dumps(result)

# Convert request body back to JSON str
data_now_json_str = dumps(result)

result, response_data, err_message = commit_schema_to_stream(
data_now_json_str, conn
)
result, response_data, err_message = commit_schema_to_stream(
data_now_json_str, conn, gh_org, gh_repo
)
if result is False:
return jsonify(err_message), 400

Expand Down
43 changes: 0 additions & 43 deletions redis_benchmarks_specification/__api__/schema.py
Original file line number Diff line number Diff line change
@@ -1,48 +1,5 @@
import logging
from json import loads
from urllib.error import URLError
from urllib.request import urlopen

import redis
from marshmallow import Schema, fields

from redis_benchmarks_specification.__common__.env import (
STREAM_KEYNAME_GH_EVENTS_COMMIT,
)


def commit_schema_to_stream(json_str: str, conn: redis.StrictRedis):
""" uses to the provided JSON dict of fields and pushes that info to the corresponding stream """
fields = loads(json_str)
reply_fields = loads(json_str)
result = False
error_msg = None
if "git_hash" not in fields:
error_msg = "Missing required 'git_hash' field"
else:
github_url = "https://github.com/redis/redis/archive/{}.zip".format(
fields["git_hash"]
)
try:
response = urlopen(github_url, timeout=5)
content = response.read()
fields["zip_archive"] = bytes(content)
fields["zip_archive_len"] = len(bytes(content))
reply_fields["archived_zip"] = True
result = True
except URLError as e:
error_msg = "Catched URLError while fetching {} content. Error {}".format(
github_url, e.__str__()
)
logging.error(error_msg)
result = False

if result is True:
id = conn.xadd(STREAM_KEYNAME_GH_EVENTS_COMMIT.encode(), fields)
reply_fields["id"] = id

return result, reply_fields, error_msg


class CommitSchema(Schema):
git_branch = fields.String(required=False)
Expand Down
9 changes: 9 additions & 0 deletions redis_benchmarks_specification/__builder__/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
git_branch = None
if b"git_branch" in testDetails:
git_branch = testDetails[b"git_branch"]
git_timestamp_ms = None
use_git_timestamp = False
if b"use_git_timestamp" in testDetails:
use_git_timestamp = bool(testDetails[b"use_git_timestamp"])
if b"git_timestamp_ms" in testDetails:
git_timestamp_ms = int(testDetails[b"git_timestamp_ms"].decode())

for build_spec in different_build_specs:
build_config, id = get_build_config(builders_folder + "/" + build_spec)
Expand Down Expand Up @@ -246,6 +252,7 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
build_stream_fields = {
"id": id,
"git_hash": git_hash,
"use_git_timestamp": str(use_git_timestamp),
"build_image": build_image,
"run_image": run_image,
"compiler": compiler,
Expand All @@ -259,6 +266,8 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
}
if git_branch is not None:
build_stream_fields["git_branch"] = git_branch
if git_timestamp_ms is not None:
build_stream_fields["git_timestamp_ms"] = git_timestamp_ms
for artifact in build_artifacts:
bin_artifact = open(
"{}src/{}".format(redis_temporary_dir, artifact), "rb"
Expand Down
5 changes: 5 additions & 0 deletions redis_benchmarks_specification/__cli__/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Apache 2 License
#
# Copyright (c) 2021., Redis Labs
# All rights reserved.
#
Loading