@@ -295,6 +295,36 @@ def test_log_group_arns_remote_logging_with_cloudwatch_handler(
295
295
assert isinstance (remote_io , CloudWatchRemoteLogIO )
296
296
assert remote_io .log_group_arn == log_group_arn
297
297
298
+ def test_loading_remote_logging_with_gcs_handler (self ):
299
+ """Test if logging can be configured successfully for GCS"""
300
+ import airflow .logging_config
301
+ from airflow .config_templates import airflow_local_settings
302
+ from airflow .providers .google .cloud .log .gcs_task_handler import GCSRemoteLogIO
303
+
304
+ with conf_vars (
305
+ {
306
+ ("logging" , "remote_logging" ): "True" ,
307
+ ("logging" , "remote_log_conn_id" ): "some_gcs" ,
308
+ ("logging" , "remote_base_log_folder" ): "gs://some-folder" ,
309
+ ("logging" , "google_key_path" ): "/gcs-key.json" ,
310
+ (
311
+ "logging" ,
312
+ "remote_task_handler_kwargs" ,
313
+ ): '{"delete_local_copy": true, "project_id": "test-project", "gcp_keyfile_dict": {},"scopes": ["https://www.googleapis.com/auth/devstorage.read_write"]}' ,
314
+ }
315
+ ):
316
+ importlib .reload (airflow_local_settings )
317
+ airflow .logging_config .configure_logging ()
318
+
319
+ assert isinstance (airflow .logging_config .REMOTE_TASK_LOG , GCSRemoteLogIO )
320
+ assert getattr (airflow .logging_config .REMOTE_TASK_LOG , "delete_local_copy" ) is True
321
+ assert getattr (airflow .logging_config .REMOTE_TASK_LOG , "project_id" ) == "test-project"
322
+ assert getattr (airflow .logging_config .REMOTE_TASK_LOG , "gcp_keyfile_dict" ) == {}
323
+ assert getattr (airflow .logging_config .REMOTE_TASK_LOG , "scopes" ) == [
324
+ "https://www.googleapis.com/auth/devstorage.read_write"
325
+ ]
326
+ assert getattr (airflow .logging_config .REMOTE_TASK_LOG , "gcp_key_path" ) == "/gcs-key.json"
327
+
298
328
def test_loading_remote_logging_with_kwargs (self ):
299
329
"""Test if logging can be configured successfully with kwargs"""
300
330
pytest .importorskip ("airflow.providers.amazon" , reason = "'amazon' provider not installed" )
0 commit comments