This is an automated email from the ASF dual-hosted git repository.
potiuk 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 af3e2cf6d4 Remove side-effect of Hybrid executor blocking test (#39615)
af3e2cf6d4 is described below
commit af3e2cf6d48b506133b220883a0e60f89aef9998
Author: Jarek Potiuk <[email protected]>
AuthorDate: Tue May 14 13:28:34 2024 +0200
Remove side-effect of Hybrid executor blocking test (#39615)
The tests introduced in #39531 introduced side effect of cleaning
the dictionary of executors - they started to fail main in tests
where bothn DB and NonDB tests were run together.
---
tests/executors/test_executor_loader.py | 42 ++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 14 deletions(-)
diff --git a/tests/executors/test_executor_loader.py
b/tests/executors/test_executor_loader.py
index bb7da133b6..25fb08b008 100644
--- a/tests/executors/test_executor_loader.py
+++ b/tests/executors/test_executor_loader.py
@@ -19,6 +19,7 @@ from __future__ import annotations
from contextlib import nullcontext
from importlib import reload
from unittest import mock
+from unittest.mock import patch
import pytest
@@ -55,6 +56,12 @@ class TestExecutorLoader:
global ExecutorLoader
ExecutorLoader = executor_loader.ExecutorLoader # type: ignore
+ def teardown_method(self) -> None:
+ from airflow.executors import executor_loader
+
+ reload(executor_loader)
+ ExecutorLoader.init_executors()
+
def test_no_executor_configured(self):
with conf_vars({("core", "executor"): None}):
with pytest.raises(AirflowConfigException, match=r".*not found in
config$"):
@@ -304,19 +311,26 @@ class TestExecutorLoader:
ExecutorLoader.validate_database_executor_compatibility(executor)
def test_load_executor(self):
- ExecutorLoader.block_use_of_hybrid_exec = mock.Mock()
- with conf_vars({("core", "executor"): "LocalExecutor"}):
- ExecutorLoader.init_executors()
- assert isinstance(ExecutorLoader.load_executor("LocalExecutor"),
LocalExecutor)
- assert
isinstance(ExecutorLoader.load_executor(executor_loader._executor_names[0]),
LocalExecutor)
- assert isinstance(ExecutorLoader.load_executor(None),
LocalExecutor)
+ with patch.object(ExecutorLoader, "block_use_of_hybrid_exec"):
+ with conf_vars({("core", "executor"): "LocalExecutor"}):
+ ExecutorLoader.init_executors()
+ assert
isinstance(ExecutorLoader.load_executor("LocalExecutor"), LocalExecutor)
+ assert isinstance(
+
ExecutorLoader.load_executor(executor_loader._executor_names[0]), LocalExecutor
+ )
+ assert isinstance(ExecutorLoader.load_executor(None),
LocalExecutor)
def test_load_executor_alias(self):
- ExecutorLoader.block_use_of_hybrid_exec = mock.Mock()
- with conf_vars({("core", "executor"):
"local_exec:airflow.executors.local_executor.LocalExecutor"}):
- ExecutorLoader.init_executors()
- assert isinstance(ExecutorLoader.load_executor("local_exec"),
LocalExecutor)
- assert isinstance(
-
ExecutorLoader.load_executor("airflow.executors.local_executor.LocalExecutor"),
LocalExecutor
- )
- assert
isinstance(ExecutorLoader.load_executor(executor_loader._executor_names[0]),
LocalExecutor)
+ with patch.object(ExecutorLoader, "block_use_of_hybrid_exec"):
+ with conf_vars(
+ {("core", "executor"):
"local_exec:airflow.executors.local_executor.LocalExecutor"}
+ ):
+ ExecutorLoader.init_executors()
+ assert isinstance(ExecutorLoader.load_executor("local_exec"),
LocalExecutor)
+ assert isinstance(
+
ExecutorLoader.load_executor("airflow.executors.local_executor.LocalExecutor"),
+ LocalExecutor,
+ )
+ assert isinstance(
+
ExecutorLoader.load_executor(executor_loader._executor_names[0]), LocalExecutor
+ )