💚(ci) also save Dimail logs from E2E test runs
To help debug with Dimail interop, save logs from the Dimail container. Also fix the tests' expectations…
This commit is contained in:
4
.github/workflows/people.yml
vendored
4
.github/workflows/people.yml
vendored
@@ -207,6 +207,10 @@ jobs:
|
|||||||
if: always()
|
if: always()
|
||||||
run: docker compose logs > src/frontend/apps/e2e/report/logs.txt
|
run: docker compose logs > src/frontend/apps/e2e/report/logs.txt
|
||||||
|
|
||||||
|
- name: Save Dimail logs
|
||||||
|
if: always()
|
||||||
|
run: docker compose logs dimail > src/frontend/apps/e2e/report/dimail-logs.txt
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
if: always()
|
if: always()
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -182,10 +182,9 @@ def test_api_mail_domains__no_creation_when_dimail_duplicate(caplog):
|
|||||||
assert response.json() == {"detail": dimail_error["detail"]}
|
assert response.json() == {"detail": dimail_error["detail"]}
|
||||||
|
|
||||||
# check logs
|
# check logs
|
||||||
assert len(caplog.records) == 2 # 1 + new empty info. To be investigated
|
|
||||||
record = caplog.records[0]
|
record = caplog.records[0]
|
||||||
assert record.levelname == "ERROR"
|
assert record.levelname == "ERROR"
|
||||||
assert (
|
assert (
|
||||||
record.message
|
record.message
|
||||||
== f"[DIMAIL] {dimail_error['status_code']}: {dimail_error['detail']}"
|
== "[DIMAIL] unexpected error : 409 {'detail': 'Domain already exists'}"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ from django.test.utils import override_settings
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import requests
|
|
||||||
import responses
|
import responses
|
||||||
from requests.exceptions import HTTPError
|
from requests.exceptions import HTTPError
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
@@ -545,9 +544,11 @@ def test_api_mailboxes__handling_dimail_unexpected_error(caplog):
|
|||||||
assert not models.Mailbox.objects.exists()
|
assert not models.Mailbox.objects.exists()
|
||||||
|
|
||||||
# Check error logger was called
|
# Check error logger was called
|
||||||
assert len(caplog.records) == 2 # 1 + new empty info. To be investigated
|
|
||||||
assert caplog.records[0].levelname == "ERROR"
|
assert caplog.records[0].levelname == "ERROR"
|
||||||
assert caplog.records[0].message == "[DIMAIL] 500: Internal server error"
|
assert (
|
||||||
|
caplog.records[0].message
|
||||||
|
== "[DIMAIL] unexpected error : 500 {'detail': 'Internal server error'}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch.object(Logger, "error")
|
@mock.patch.object(Logger, "error")
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ from django.template.loader import render_to_string
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from requests.exceptions import HTTPError
|
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
from urllib3.util import Retry
|
from urllib3.util import Retry
|
||||||
|
|
||||||
@@ -161,8 +160,10 @@ class DimailAPIClient:
|
|||||||
def pass_dimail_unexpected_response(self, response):
|
def pass_dimail_unexpected_response(self, response):
|
||||||
"""Raise error when encountering an unexpected error in dimail."""
|
"""Raise error when encountering an unexpected error in dimail."""
|
||||||
try:
|
try:
|
||||||
error_content = json.loads(response.content.decode(response.encoding).replace("'", '"'))
|
error_content = json.loads(
|
||||||
except:
|
response.content.decode(response.encoding).replace("'", '"')
|
||||||
|
)
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
error_content = response.content.decode(response.encoding)
|
error_content = response.content.decode(response.encoding)
|
||||||
|
|
||||||
logger.error(
|
logger.error(
|
||||||
|
|||||||
Reference in New Issue
Block a user