Abhishekmishra2808 commented on code in PR #61242:
URL: https://github.com/apache/airflow/pull/61242#discussion_r2745688602
##########
airflow-core/tests/integration/otel/test_otel.py:
##########
@@ -55,6 +56,44 @@
log = logging.getLogger("integration.otel.test_otel")
+def wait_for_otel_collector(host: str, port: int, timeout: int = 120) -> None:
+ """
+ Wait for the OTel collector to be reachable before running tests.
+
+ This prevents flaky test failures caused by transient DNS resolution issues
+ (e.g., 'Temporary failure in name resolution' for breeze-otel-collector).
+
+ Note: If the collector is not reachable after timeout, logs a warning but
+ does not fail - allows tests to run and fail naturally if needed.
+ """
+ deadline = time.monotonic() + timeout
+ last_error = None
+ while time.monotonic() < deadline:
+ try:
+ # Test DNS resolution and TCP connectivity
+ sock = socket.create_connection((host, port), timeout=5)
+ sock.close()
Review Comment:
Good catch, Henry! Using a context manager is much cleaner. I’ll update the
implementation to use with `socket.create_connection` to ensure the socket is
always properly closed.
--
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]