ci: add log grouping (#5342)
* ci: add log grouping Signed-off-by: Jens Langhammer <jens@goauthentik.io> * try to group structlog output Signed-off-by: Jens Langhammer <jens@goauthentik.io> * format Signed-off-by: Jens Langhammer <jens@goauthentik.io> * earlier hooks Signed-off-by: Jens Langhammer <jens@goauthentik.io> * hmm Signed-off-by: Jens Langhammer <jens@goauthentik.io> * disable beats integration for now Signed-off-by: Jens Langhammer <jens@goauthentik.io> * test container logs Signed-off-by: Jens Langhammer <jens@goauthentik.io> * remove testing Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
parent
d4e502fdf5
commit
480f5c2aac
|
@ -67,7 +67,7 @@ def sentry_init(**sentry_init_kwargs):
|
||||||
ArgvIntegration(),
|
ArgvIntegration(),
|
||||||
StdlibIntegration(),
|
StdlibIntegration(),
|
||||||
DjangoIntegration(transaction_style="function_name"),
|
DjangoIntegration(transaction_style="function_name"),
|
||||||
CeleryIntegration(monitor_beat_tasks=True),
|
CeleryIntegration(),
|
||||||
RedisIntegration(),
|
RedisIntegration(),
|
||||||
ThreadingIntegration(propagate_hub=True),
|
ThreadingIntegration(propagate_hub=True),
|
||||||
SocketIntegration(),
|
SocketIntegration(),
|
||||||
|
|
|
@ -3,6 +3,7 @@ import json
|
||||||
import os
|
import os
|
||||||
from functools import lru_cache, wraps
|
from functools import lru_cache, wraps
|
||||||
from os import environ
|
from os import environ
|
||||||
|
from sys import stderr
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from typing import Any, Callable, Optional
|
from typing import Any, Callable, Optional
|
||||||
|
|
||||||
|
@ -28,6 +29,7 @@ from authentik.core.models import User
|
||||||
from authentik.core.tests.utils import create_test_admin_user
|
from authentik.core.tests.utils import create_test_admin_user
|
||||||
|
|
||||||
RETRIES = int(environ.get("RETRIES", "3"))
|
RETRIES = int(environ.get("RETRIES", "3"))
|
||||||
|
IS_CI = "CI" in environ
|
||||||
|
|
||||||
|
|
||||||
def get_docker_tag() -> str:
|
def get_docker_tag() -> str:
|
||||||
|
@ -49,6 +51,8 @@ class SeleniumTestCase(StaticLiveServerTestCase):
|
||||||
user: User
|
user: User
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
if IS_CI:
|
||||||
|
print("::group::authentik Logs", file=stderr)
|
||||||
super().setUp()
|
super().setUp()
|
||||||
# pylint: disable=invalid-name
|
# pylint: disable=invalid-name
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
@ -91,8 +95,12 @@ class SeleniumTestCase(StaticLiveServerTestCase):
|
||||||
def output_container_logs(self, container: Optional[Container] = None):
|
def output_container_logs(self, container: Optional[Container] = None):
|
||||||
"""Output the container logs to our STDOUT"""
|
"""Output the container logs to our STDOUT"""
|
||||||
_container = container or self.container
|
_container = container or self.container
|
||||||
|
if IS_CI:
|
||||||
|
print(f"::group::Container logs - {_container.image.tags[0]}")
|
||||||
for log in _container.logs().decode().split("\n"):
|
for log in _container.logs().decode().split("\n"):
|
||||||
self.logger.info(log, source="container", container=_container.image.tags[0])
|
print(log)
|
||||||
|
if IS_CI:
|
||||||
|
print("::endgroup::")
|
||||||
|
|
||||||
def get_container_specs(self) -> Optional[dict[str, Any]]:
|
def get_container_specs(self) -> Optional[dict[str, Any]]:
|
||||||
"""Optionally get container specs which will launched on setup, wait for the container to
|
"""Optionally get container specs which will launched on setup, wait for the container to
|
||||||
|
@ -118,15 +126,19 @@ class SeleniumTestCase(StaticLiveServerTestCase):
|
||||||
raise ValueError(f"Webdriver failed after {RETRIES}.")
|
raise ValueError(f"Webdriver failed after {RETRIES}.")
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.logger.debug("--------browser logs")
|
super().tearDown()
|
||||||
|
if IS_CI:
|
||||||
|
print("::endgroup::", file=stderr)
|
||||||
|
if IS_CI:
|
||||||
|
print("::group::Browser logs")
|
||||||
for line in self.driver.get_log("browser"):
|
for line in self.driver.get_log("browser"):
|
||||||
self.logger.debug(line["message"], source=line["source"], level=line["level"])
|
print(line["message"])
|
||||||
self.logger.debug("--------end browser logs")
|
if IS_CI:
|
||||||
|
print("::endgroup::")
|
||||||
if self.container:
|
if self.container:
|
||||||
self.output_container_logs()
|
self.output_container_logs()
|
||||||
self.container.kill()
|
self.container.kill()
|
||||||
self.driver.quit()
|
self.driver.quit()
|
||||||
super().tearDown()
|
|
||||||
|
|
||||||
def wait_for_url(self, desired_url):
|
def wait_for_url(self, desired_url):
|
||||||
"""Wait until URL is `desired_url`."""
|
"""Wait until URL is `desired_url`."""
|
||||||
|
|
Reference in New Issue