This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new aadd70a2667 [v3-1-test] Remove global from breeze testing commands
(#58854) (#58858)
aadd70a2667 is described below
commit aadd70a2667a8fd666aa57b496dc01caac9a9810
Author: Jens Scheffler <[email protected]>
AuthorDate: Sun Nov 30 01:37:15 2025 +0100
[v3-1-test] Remove global from breeze testing commands (#58854) (#58858)
* Remove global from breeze testing commands
* Make ShellParams hashable
* Make ShellParams hashable
* Make ShellParams hashable, fix
(cherry picked from commit 60bf28d687e6308fdb3c084278fb9e26515ca48d)
---
dev/breeze/src/airflow_breeze/commands/testing_commands.py | 10 +++++-----
dev/breeze/src/airflow_breeze/params/shell_params.py | 8 ++++++++
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/dev/breeze/src/airflow_breeze/commands/testing_commands.py
b/dev/breeze/src/airflow_breeze/commands/testing_commands.py
index 614f00fc653..4348e3bd556 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
@@ -243,8 +244,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:
@@ -279,8 +280,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,
@@ -306,7 +308,6 @@ def _dump_container_logs(output: Output | None,
shell_params: ShellParams):
check=False,
stdout=outfile,
)
- logs_already_dumped = True
def _run_tests_in_pool(
@@ -1371,7 +1372,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 08f4b565428..393f5ef9918 100644
--- a/dev/breeze/src/airflow_breeze/params/shell_params.py
+++ b/dev/breeze/src/airflow_breeze/params/shell_params.py
@@ -808,3 +808,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__))