Skip to content
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 docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ RUN pip3 install --no-cache-dir -e /src/actinia-cloudevent-plugin/ && \
WORKDIR /src/actinia-cloudevent-plugin
# RUN make test

CMD ["gunicorn", "-b", "0.0.0.0:8088", "-w", "8", "--access-logfile=-", "-k", "gthread", "actinia_cloudevent_plugin.main:flask_app"]
CMD ["gunicorn", "-b", "0.0.0.0:3003", "-w", "8", "--access-logfile=-", "-k", "gthread", "actinia_cloudevent_plugin.main:flask_app"]
2 changes: 1 addition & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
cap_add:
- SYS_PTRACE
ports:
- "5000:5000"
- "3003:3003"
# network_mode: "host"

actinia-core:
Expand Down
4 changes: 1 addition & 3 deletions src/actinia_cloudevent_plugin/api/cloudevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def post(self) -> SimpleStatusCodeResponseModel:
url = EVENTRECEIVER.url
new_event = send_binary_cloud_event(
event_received,
actinia_resp,
actinia_resp["queue"],
url,
)
return SimpleStatusCodeResponseModel(
Expand All @@ -99,5 +99,3 @@ def post(self) -> SimpleStatusCodeResponseModel:
)
except ConnectionError as e:
return f"Connection ERROR when returning cloudevent: {e}"
except Exception() as e:
return f"ERROR when returning cloudevent: {e}"
4 changes: 2 additions & 2 deletions src/actinia_cloudevent_plugin/resources/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from logging import FileHandler

from colorlog import ColoredFormatter
from pythonjsonlogger import jsonlogger
from pythonjsonlogger import json

from actinia_cloudevent_plugin.resources.config import LOGCONFIG

Expand Down Expand Up @@ -69,7 +69,7 @@ def set_log_handler(logger, logtype, logformat) -> None:
logger.addHandler(handler)


class CustomJsonFormatter(jsonlogger.JsonFormatter):
class CustomJsonFormatter(json.JsonFormatter):
"""Customized formatting of logs as json."""

def add_fields(self, log_record, record, message_dict) -> None:
Expand Down
14 changes: 10 additions & 4 deletions tests/integrationtests/test_cloudevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ def test_post_cloudevent(self) -> None:
# Expected outcome
# (Note: returned cloudevent id, changes for each request)
# Lenght of response
resp_length = 152
resp_length_local_queue = 131
# resp_length of queue with kvdb differs: "local" vs e.g.
# "job_queue_resource_id-4263d323-829e-4a09-b3f3-6fbbfbd72a67"
# In this test setup currently only local queue is configured.
# resp_length_kvdb_queue = 152
# Start of response (and according string index)
resp_start = (
"Received event e3525c6d-bbd8-404d-9fa3-1e421dc99c11"
" and returned event "
)
resp_start_ind = 71
# End of response (and according string index)
resp_end = "with actinia-job <queue_name>_<resource_id>."
resp_end = "with actinia-job local."
# resp_end = "with actinia-job <queue_name>_<resource_id>."
resp_end_ind = 108

# Test post method
Expand All @@ -84,9 +89,10 @@ def test_post_cloudevent(self) -> None:
assert (
"message" in resp.json
), "There is no 'message' inside the response"
assert len(resp.json["message"]) == resp_length, (
assert len(resp.json["message"]) == resp_length_local_queue, (
"The length of response message is wrong. "
f"{len(resp.json['message'])}, instead of {resp_length}."
f"{len(resp.json['message'])}, "
f"instead of {resp_length_local_queue}."
)
assert resp.json["message"][:resp_start_ind] == resp_start, (
"The start of response message is wrong. "
Expand Down