jason810496 commented on code in PR #67104:
URL: https://github.com/apache/airflow/pull/67104#discussion_r3533728342
##########
airflow-core/tests/unit/logging/test_logging_config.py:
##########
@@ -200,3 +201,42 @@ def test_skips_reload_when_already_loaded(self):
mocked_conf.get.return_value = None
assert get_default_remote_conn_id() == "cached_conn"
mock_load.assert_not_called()
+
+
+class TestWarnIfMissingRemoteTaskLog:
+ @pytest.fixture(autouse=True)
+ def _reset_active_logging_config(self, monkeypatch):
+ monkeypatch.setattr(_ActiveLoggingConfig, "remote_task_log", None,
raising=False)
+ monkeypatch.setattr(_ActiveLoggingConfig, "logging_config_loaded",
True, raising=False)
+
+ def
test_warns_when_user_module_missing_remote_task_log_and_remote_logging_enabled(self,
monkeypatch):
+ monkeypatch.setenv("AIRFLOW__LOGGING__REMOTE_LOGGING", "True")
+ with mock.patch("airflow.logging_config.log") as mock_log:
+
_warn_if_missing_remote_task_log("my_pkg.custom_settings.LOGGING_CONFIG")
+ mock_log.warning.assert_called_once()
+ assert "my_pkg.custom_settings" in mock_log.warning.call_args.args
+
+ def test_no_warning_when_using_fallback_path(self, monkeypatch):
+ monkeypatch.setenv("AIRFLOW__LOGGING__REMOTE_LOGGING", "True")
+ with mock.patch("airflow.logging_config.log") as mock_log:
+ _warn_if_missing_remote_task_log(DEFAULT_LOGGING_CONFIG_PATH)
+ mock_log.warning.assert_not_called()
+
+ def test_no_warning_when_remote_logging_disabled(self, monkeypatch):
+ monkeypatch.setenv("AIRFLOW__LOGGING__REMOTE_LOGGING", "False")
+ with mock.patch("airflow.logging_config.log") as mock_log:
+
_warn_if_missing_remote_task_log("my_pkg.custom_settings.LOGGING_CONFIG")
+ mock_log.warning.assert_not_called()
+
+ def test_no_warning_when_remote_task_log_is_set(self, monkeypatch):
+ monkeypatch.setenv("AIRFLOW__LOGGING__REMOTE_LOGGING", "True")
+ monkeypatch.setattr(_ActiveLoggingConfig, "remote_task_log", object(),
raising=False)
+ with mock.patch("airflow.logging_config.log") as mock_log:
+
_warn_if_missing_remote_task_log("my_pkg.custom_settings.LOGGING_CONFIG")
+ mock_log.warning.assert_not_called()
+
+ def test_no_warning_when_empty_logging_class_path(self, monkeypatch):
+ monkeypatch.setenv("AIRFLOW__LOGGING__REMOTE_LOGGING", "True")
+ with mock.patch("airflow.logging_config.log") as mock_log:
+ _warn_if_missing_remote_task_log("")
+ mock_log.warning.assert_not_called()
Review Comment:
Thanks for the review. All the comments are addressed in
https://github.com/apache/airflow/pull/67104/changes/65a9d61cbbf4f8af7a259d8c3c4698c78a31a61c.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]