Skip to content

Increased API and builder spec implementation testing #15

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 3 commits into from
Aug 18, 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
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish Pypi
on:
release:
types: [ published, edited ]
types: [ published ]

jobs:
pytest:
Expand Down
2 changes: 1 addition & 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.1"
version = "0.1.2"
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>"]

Expand Down
4 changes: 3 additions & 1 deletion redis_benchmarks_specification/__api__/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ def verify_password(username, password):
result = True
except redis.exceptions.ResponseError:
result = False
except redis.exceptions.AuthenticationError:
result = False
return result


Expand Down Expand Up @@ -79,7 +81,7 @@ def commit_schema_to_stream(json_str: str, conn: redis.StrictRedis):
result = False

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

return result, reply_fields, error_msg
Expand Down
21 changes: 17 additions & 4 deletions redis_benchmarks_specification/__builder__/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def main():

previous_id = args.consumer_start_id
while True:
previous_id = builder_process_stream(
previous_id, new_builds_count = builder_process_stream(
builders_folder, conn, different_build_specs, previous_id
)

Expand All @@ -138,14 +138,16 @@ def builder_consumer_group_create(conn):


def builder_process_stream(builders_folder, conn, different_build_specs, previous_id):
new_builds_count = 0
logging.info("Entering blocking read waiting for work.")
consumer_name = "{}-proc#{}".format(STREAM_GH_EVENTS_COMMIT_BUILDERS_CG, "1")
newTestInfo = conn.xreadgroup(
STREAM_GH_EVENTS_COMMIT_BUILDERS_CG,
"{}-proc#{}".format(STREAM_GH_EVENTS_COMMIT_BUILDERS_CG, "1"),
consumer_name,
{STREAM_KEYNAME_GH_EVENTS_COMMIT: previous_id},
count=1,
block=0,
)

if len(newTestInfo[0]) < 2 or len(newTestInfo[0][1]) < 1:
previous_id = ">"
else:
Expand All @@ -162,6 +164,9 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
git_hash = testDetails[b"git_hash"]
logging.info("Received commit hash specifier {}.".format(git_hash))
buffer = testDetails[b"zip_archive"]
git_branch = None
if b"git_branch" in testDetails:
git_branch = testDetails[b"git_branch"]

for build_spec in different_build_specs:
build_config, id = get_build_config(builders_folder + "/" + build_spec)
Expand Down Expand Up @@ -239,6 +244,8 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
"build_command": build_command,
"build_artifacts": ",".join(build_artifacts),
}
if git_branch is not None:
build_stream_fields["git_branch"] = git_branch
for artifact in build_artifacts:
bin_artifact = open(
"{}src/{}".format(redis_temporary_dir, artifact), "rb"
Expand All @@ -258,9 +265,15 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
)
)
shutil.rmtree(temporary_dir, ignore_errors=True)
new_builds_count = new_builds_count + 1
conn.xack(
STREAM_GH_EVENTS_COMMIT_BUILDERS_CG,
STREAM_KEYNAME_GH_EVENTS_COMMIT,
streamId,
)
else:
logging.error("Missing commit information within received message.")
return previous_id
return previous_id, new_builds_count


def build_spec_image_prefetch(builders_folder, different_build_specs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,12 @@ def extract_build_info_from_streamdata(testDetails):
git_hash = testDetails[b"git_hash"]
if b"git_branch" in testDetails:
git_branch = testDetails[b"git_branch"]
if type(git_branch) == bytes:
git_branch = git_branch.decode()
if b"git_version" in testDetails:
git_version = testDetails[b"git_version"]
if type(git_version) == bytes:
git_version = git_version.decode()
if type(git_hash) == bytes:
git_hash = git_hash.decode()
logging.info("Received commit hash specifier {}.".format(git_hash))
Expand Down
4 changes: 4 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[testenv:integration-tests]
passenv = *

deps =
pytest
pytest-cov
Expand All @@ -21,3 +23,5 @@ docker =
image = redislabs/redistimeseries:1.4.7
ports =
6379:6379/tcp
volumes =
bind:rw:{toxinidir}/utils/tests/test_data/:/data
53 changes: 34 additions & 19 deletions utils/tests/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,49 @@
# Copyright (c) 2021., Redis Labs
# All rights reserved.
#
import os

from redis_benchmarks_specification.__api__.api import commit_schema_to_stream
import redis

from redis_benchmarks_specification.__builder__.builder import (
builder_consumer_group_create,
builder_process_stream,
)
from redis_benchmarks_specification.__common__.env import (
STREAM_KEYNAME_GH_EVENTS_COMMIT,
STREAM_KEYNAME_NEW_BUILD_EVENTS,
STREAM_GH_EVENTS_COMMIT_BUILDERS_CG,
)


def test_commit_schema_to_stream():
result, reply_fields, error_msg = commit_schema_to_stream(
'{"git_hashss":"0cf2df84d4b27af4bffd2bf3543838f09e10f874"}', None
)
assert result == False
assert error_msg is not None
def test_commit_schema_to_stream_then_build():
try:
conn = redis.StrictRedis()
conn.ping()
conn.flushall()
result, reply_fields, error_msg = commit_schema_to_stream(
'{"git_hash":"0cf2df84d4b27af4bffd2bf3543838f09e10f874"}', conn
)
assert result == True
assert error_msg == None
reply = conn.xread({STREAM_KEYNAME_GH_EVENTS_COMMIT: 0}, 1)
assert (
reply[0][1][0][1][b"git_hash"]
== b"0cf2df84d4b27af4bffd2bf3543838f09e10f874"
)
skip_builder = False
if skip_builder is not True:
conn = redis.StrictRedis()
conn.ping()
conn.flushall()
builder_consumer_group_create(conn)
assert conn.xlen(STREAM_KEYNAME_GH_EVENTS_COMMIT) == 0

result, reply_fields, error_msg = commit_schema_to_stream(
'{"git_hash":"0cf2df84d4b27af4bffd2bf3543838f09e10f874"}', conn
)
assert result == True
assert error_msg == None
assert STREAM_KEYNAME_GH_EVENTS_COMMIT.encode() in conn.keys()
assert conn.xlen(STREAM_KEYNAME_GH_EVENTS_COMMIT) == 1
assert "id" in reply_fields
builders_folder = "./redis_benchmarks_specification/setups/builders"
different_build_specs = ["gcc:8.5.0-amd64-debian-buster-default.yml"]
previous_id = ">"
previous_id, new_builds_count = builder_process_stream(
builders_folder, conn, different_build_specs, previous_id
)
assert new_builds_count == 1
assert conn.exists(STREAM_KEYNAME_NEW_BUILD_EVENTS)
conn.save()

except redis.exceptions.ConnectionError:
pass
Binary file added utils/tests/test_data/dump.rdb
Binary file not shown.
2 changes: 1 addition & 1 deletion utils/tests/test_redis_benchmarks_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


def test_version():
assert __version__ == "0.1.0"
assert __version__ == "0.1.2"