tests: show logs for containers on failed e2e tests
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
0eaabbc0f3
commit
e9621bae06
|
@ -265,6 +265,8 @@ DATABASES = {
|
||||||
"USER": CONFIG.y("postgresql.user"),
|
"USER": CONFIG.y("postgresql.user"),
|
||||||
"PASSWORD": CONFIG.y("postgresql.password"),
|
"PASSWORD": CONFIG.y("postgresql.password"),
|
||||||
"PORT": int(CONFIG.y("postgresql.port")),
|
"PORT": int(CONFIG.y("postgresql.port")),
|
||||||
|
"CONN_MAX_AGE": 300,
|
||||||
|
"ATOMIC_REQUESTS": True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ class TestProviderProxy(SeleniumTestCase):
|
||||||
|
|
||||||
def tearDown(self) -> None:
|
def tearDown(self) -> None:
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
self.output_container_logs(self.proxy_container)
|
||||||
self.proxy_container.kill()
|
self.proxy_container.kill()
|
||||||
|
|
||||||
def get_container_specs(self) -> Optional[dict[str, Any]]:
|
def get_container_specs(self) -> Optional[dict[str, Any]]:
|
||||||
|
@ -88,6 +89,16 @@ class TestProviderProxy(SeleniumTestCase):
|
||||||
|
|
||||||
self.proxy_container = self.start_proxy(outpost)
|
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.driver.get("http://localhost:4180")
|
||||||
self.login()
|
self.login()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
|
@ -71,6 +71,14 @@ class SeleniumTestCase(StaticLiveServerTestCase):
|
||||||
self.logger.info("Container failed healthcheck")
|
self.logger.info("Container failed healthcheck")
|
||||||
sleep(1)
|
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]]:
|
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
|
||||||
be healthy, and deleted again on tearDown"""
|
be healthy, and deleted again on tearDown"""
|
||||||
|
@ -97,6 +105,7 @@ class SeleniumTestCase(StaticLiveServerTestCase):
|
||||||
)
|
)
|
||||||
self.logger.debug("--------end browser logs")
|
self.logger.debug("--------end browser logs")
|
||||||
if self.container:
|
if self.container:
|
||||||
|
self.output_container_logs()
|
||||||
self.container.kill()
|
self.container.kill()
|
||||||
self.driver.quit()
|
self.driver.quit()
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
|
|
Reference in New Issue