diff --git a/authentik/root/settings.py b/authentik/root/settings.py index 99d0b0f6f..df2e0dc33 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -265,6 +265,8 @@ DATABASES = { "USER": CONFIG.y("postgresql.user"), "PASSWORD": CONFIG.y("postgresql.password"), "PORT": int(CONFIG.y("postgresql.port")), + "CONN_MAX_AGE": 300, + "ATOMIC_REQUESTS": True, } } diff --git a/tests/e2e/test_provider_proxy.py b/tests/e2e/test_provider_proxy.py index 6a8ad3651..3f00ee88e 100644 --- a/tests/e2e/test_provider_proxy.py +++ b/tests/e2e/test_provider_proxy.py @@ -32,6 +32,7 @@ class TestProviderProxy(SeleniumTestCase): def tearDown(self) -> None: super().tearDown() + self.output_container_logs(self.proxy_container) self.proxy_container.kill() def get_container_specs(self) -> Optional[dict[str, Any]]: @@ -88,6 +89,16 @@ class TestProviderProxy(SeleniumTestCase): self.proxy_container = self.start_proxy(outpost) + # Wait until outpost healthcheck succeeds + healthcheck_retries = 0 + while healthcheck_retries < 50: + if len(outpost.state) > 0: + state = outpost.state[0] + if state.last_seen: + break + healthcheck_retries += 1 + sleep(0.5) + self.driver.get("http://localhost:4180") self.login() sleep(1) diff --git a/tests/e2e/utils.py b/tests/e2e/utils.py index 735dc4fde..20193d464 100644 --- a/tests/e2e/utils.py +++ b/tests/e2e/utils.py @@ -71,6 +71,14 @@ class SeleniumTestCase(StaticLiveServerTestCase): self.logger.info("Container failed healthcheck") sleep(1) + def output_container_logs(self, container: Optional[Container] = None): + """Output the container logs to our STDOUT""" + ct = container or self.container + self.logger.debug("--------container logs", container=ct.image.tags[0]) + for log in ct.logs().decode().split("\n"): + self.logger.debug(log, container=ct.image.tags[0]) + self.logger.debug("--------end container logs", container=ct.image.tags[0]) + def get_container_specs(self) -> Optional[dict[str, Any]]: """Optionally get container specs which will launched on setup, wait for the container to be healthy, and deleted again on tearDown""" @@ -97,6 +105,7 @@ class SeleniumTestCase(StaticLiveServerTestCase): ) self.logger.debug("--------end browser logs") if self.container: + self.output_container_logs() self.container.kill() self.driver.quit() super().tearDown()