You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2025/08/02 17:03:52 UTC

(airflow) branch main updated: Add mongo client timeouts to mongo tests (#54052)

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 3b73e4067a0 Add mongo client timeouts to mongo tests (#54052)
3b73e4067a0 is described below

commit 3b73e4067a0d0b3d524aa8525511a0d5a3a33430
Author: GPK <go...@gmail.com>
AuthorDate: Sat Aug 2 18:03:45 2025 +0100

    Add mongo client timeouts to mongo tests (#54052)
---
 providers/mongo/tests/unit/mongo/hooks/test_mongo.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/providers/mongo/tests/unit/mongo/hooks/test_mongo.py b/providers/mongo/tests/unit/mongo/hooks/test_mongo.py
index 02e7b451e42..b3d81140023 100644
--- a/providers/mongo/tests/unit/mongo/hooks/test_mongo.py
+++ b/providers/mongo/tests/unit/mongo/hooks/test_mongo.py
@@ -31,8 +31,14 @@ from tests_common.test_utils.compat import connection_as_json
 
 @pytest.fixture
 def container_mongo_client(mongodb_container):
-    client = MongoClient(mongodb_container)
-
+    # Add some timeouts to the connection options to ensure that the MongoDB client interacts correctly
+
+    options = {"ssl": False, "socketTimeoutMS": 60000, "connectTimeoutMS": 60000}
+    client = MongoClient(mongodb_container, **options)
+    try:
+        client.admin.command("ping")
+    except Exception as e:
+        raise e
     yield client
 
     client.close()
@@ -84,7 +90,7 @@ def mongo_connections(mongodb_container):
             password="test",
             host=mongodb_container_host,
             port=int(mongodb_container_port),
-            extra='{"allow_insecure": true, "ssl": false}',
+            extra='{"allow_insecure": true, "ssl": false, "socketTimeoutMS": 60000, "connectTimeoutMS": 60000}',
         ),
     ]