Skip to content

Commit d0143b4

Browse files
authored
Merge pull request #13 from actinia-org/fix-tests
Fix tests
2 parents a954277 + 113d5e4 commit d0143b4

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ RUN pip3 install --no-cache-dir -e /src/actinia-cloudevent-plugin/ && \
2222
WORKDIR /src/actinia-cloudevent-plugin
2323
# RUN make test
2424

25-
CMD ["gunicorn", "-b", "0.0.0.0:8088", "-w", "8", "--access-logfile=-", "-k", "gthread", "actinia_cloudevent_plugin.main:flask_app"]
25+
CMD ["gunicorn", "-b", "0.0.0.0:3003", "-w", "8", "--access-logfile=-", "-k", "gthread", "actinia_cloudevent_plugin.main:flask_app"]

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
cap_add:
1111
- SYS_PTRACE
1212
ports:
13-
- "5000:5000"
13+
- "3003:3003"
1414
# network_mode: "host"
1515

1616
actinia-core:

src/actinia_cloudevent_plugin/api/cloudevents.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def post(self) -> SimpleStatusCodeResponseModel:
8888
url = EVENTRECEIVER.url
8989
new_event = send_binary_cloud_event(
9090
event_received,
91-
actinia_resp,
91+
actinia_resp["queue"],
9292
url,
9393
)
9494
return SimpleStatusCodeResponseModel(
@@ -99,5 +99,3 @@ def post(self) -> SimpleStatusCodeResponseModel:
9999
)
100100
except ConnectionError as e:
101101
return f"Connection ERROR when returning cloudevent: {e}"
102-
except Exception() as e:
103-
return f"ERROR when returning cloudevent: {e}"

src/actinia_cloudevent_plugin/resources/logging.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from logging import FileHandler
2929

3030
from colorlog import ColoredFormatter
31-
from pythonjsonlogger import jsonlogger
31+
from pythonjsonlogger import json
3232

3333
from actinia_cloudevent_plugin.resources.config import LOGCONFIG
3434

@@ -69,7 +69,7 @@ def set_log_handler(logger, logtype, logformat) -> None:
6969
logger.addHandler(handler)
7070

7171

72-
class CustomJsonFormatter(jsonlogger.JsonFormatter):
72+
class CustomJsonFormatter(json.JsonFormatter):
7373
"""Customized formatting of logs as json."""
7474

7575
def add_fields(self, log_record, record, message_dict) -> None:

tests/integrationtests/test_cloudevent.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,20 @@ def test_post_cloudevent(self) -> None:
5858
# Expected outcome
5959
# (Note: returned cloudevent id, changes for each request)
6060
# Lenght of response
61-
resp_length = 152
61+
resp_length_local_queue = 131
62+
# resp_length of queue with kvdb differs: "local" vs e.g.
63+
# "job_queue_resource_id-4263d323-829e-4a09-b3f3-6fbbfbd72a67"
64+
# In this test setup currently only local queue is configured.
65+
# resp_length_kvdb_queue = 152
6266
# Start of response (and according string index)
6367
resp_start = (
6468
"Received event e3525c6d-bbd8-404d-9fa3-1e421dc99c11"
6569
" and returned event "
6670
)
6771
resp_start_ind = 71
6872
# End of response (and according string index)
69-
resp_end = "with actinia-job <queue_name>_<resource_id>."
73+
resp_end = "with actinia-job local."
74+
# resp_end = "with actinia-job <queue_name>_<resource_id>."
7075
resp_end_ind = 108
7176

7277
# Test post method
@@ -84,9 +89,10 @@ def test_post_cloudevent(self) -> None:
8489
assert (
8590
"message" in resp.json
8691
), "There is no 'message' inside the response"
87-
assert len(resp.json["message"]) == resp_length, (
92+
assert len(resp.json["message"]) == resp_length_local_queue, (
8893
"The length of response message is wrong. "
89-
f"{len(resp.json['message'])}, instead of {resp_length}."
94+
f"{len(resp.json['message'])}, "
95+
f"instead of {resp_length_local_queue}."
9096
)
9197
assert resp.json["message"][:resp_start_ind] == resp_start, (
9298
"The start of response message is wrong. "

0 commit comments

Comments
 (0)