This is an automated email from the ASF dual-hosted git repository.
jscheffl pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 60bf28d687e Remove global from breeze testing commands (#58854)
60bf28d687e is described below
commit 60bf28d687e6308fdb3c084278fb9e26515ca48d
Author: Jens Scheffler <[email protected]>
AuthorDate: Sat Nov 29 22:37:57 2025 +0100
Remove global from breeze testing commands (#58854)
* Remove global from breeze testing commands
* Make ShellParams hashable
* Make ShellParams hashable
* Make ShellParams hashable, fix
---
dev/breeze/src/airflow_breeze/commands/testing_commands.py | 12 +++++-------
dev/breeze/src/airflow_breeze/params/shell_params.py | 8 ++++++++
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/dev/breeze/src/airflow_breeze/commands/testing_commands.py
b/dev/breeze/src/airflow_breeze/commands/testing_commands.py
index ec672cd2a02..60d18417b8c 100644
--- a/dev/breeze/src/airflow_breeze/commands/testing_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/testing_commands.py
@@ -22,6 +22,7 @@ import signal
import sys
from collections.abc import Generator
from datetime import datetime
+from functools import cache
from multiprocessing.pool import Pool
from time import sleep
@@ -123,8 +124,6 @@ GRACE_CONTAINER_STOP_TIMEOUT = 10 # Timeout in seconds to
wait for containers t
LOW_MEMORY_CONDITION = 8 * 1024 * 1024 * 1024 # 8 GB
DEFAULT_TOTAL_TEST_TIMEOUT = 60 * 60 # 60 minutes
-logs_already_dumped = False
-
option_skip_docker_compose_deletion = click.option(
"--skip-docker-compose-deletion",
help="Skip deletion of docker-compose instance after the test",
@@ -267,8 +266,8 @@ def _run_test(
notify_on_unhealthy_backend_container(
project_name=project_name, backend=shell_params.backend,
output=output
)
- if os.environ.get("CI") == "true" and result.returncode != 0 and not
logs_already_dumped:
- get_console(output=output).print(f"[error]Test failed with
{result.returncode}. Dumping logs[/]")
+ if os.environ.get("CI") == "true" and result.returncode != 0:
+ get_console(output=output).print(f"[error]Test failed with
{result.returncode}.[/]")
_dump_container_logs(output=output, shell_params=shell_params)
finally:
if not skip_docker_compose_down:
@@ -303,8 +302,9 @@ def _get_project_names(shell_params: ShellParams) ->
tuple[str, str]:
return compose_project_name, project_name
+@cache # Note: using functools.cache to avoid multiple dumps in the same run
def _dump_container_logs(output: Output | None, shell_params: ShellParams):
- global logs_already_dumped
+ get_console().print("[warning]Dumping container logs[/]")
ps_result = run_command(
["docker", "ps", "--all", "--format", "{{.Names}}"],
check=True,
@@ -330,7 +330,6 @@ def _dump_container_logs(output: Output | None,
shell_params: ShellParams):
check=False,
stdout=outfile,
)
- logs_already_dumped = True
def _run_tests_in_pool(
@@ -1599,7 +1598,6 @@ class TimeoutHandler:
get_console().print("[warning]Stopping all running containers[/]:")
self._print_all_containers()
if os.environ.get("CI") == "true":
- get_console().print("[warning]Dumping container logs first[/]")
_dump_container_logs(output=None, shell_params=self.shell_params)
list_of_containers = self._get_running_containers().stdout.splitlines()
get_console().print("[warning]Attempting to send TERM signal to all
remaining containers:")
diff --git a/dev/breeze/src/airflow_breeze/params/shell_params.py
b/dev/breeze/src/airflow_breeze/params/shell_params.py
index 54be20f35e8..f9ea31559df 100644
--- a/dev/breeze/src/airflow_breeze/params/shell_params.py
+++ b/dev/breeze/src/airflow_breeze/params/shell_params.py
@@ -812,3 +812,11 @@ class ShellParams:
"[error]When using the Keycloak integration the backend must
be Postgres![/]\n"
)
sys.exit(2)
+
+ def __eq__(self, other) -> bool:
+ if not isinstance(other, ShellParams):
+ return False
+ return self.__dict__ == other.__dict__
+
+ def __hash__(self) -> int:
+ return hash(str(self.__dict__))