jason810496 commented on code in PR #63519:
URL: https://github.com/apache/airflow/pull/63519#discussion_r2931465842


##########
airflow-e2e-tests/tests/airflow_e2e_tests/conftest.py:
##########
@@ -155,21 +183,85 @@ def spin_up_airflow_environment(tmp_path_factory: 
pytest.TempPathFactory):
         console.print("[red]Failed to start docker compose")
         if _E2ETestState.compose_instance:
             _print_logs(_E2ETestState.compose_instance)
+            # TO BE REMOVED: startup failures often happen in init/exited 
services that are missing

Review Comment:
   Do we need to remove these setup in this PR? Or we should keep them until we 
figure out?



##########
airflow-e2e-tests/tests/airflow_e2e_tests/remote_log_elasticsearch_tests/test_remote_logging_elasticsearch.py:
##########
@@ -0,0 +1,104 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+from __future__ import annotations
+
+import time
+from datetime import datetime, timezone
+
+import pytest
+
+from airflow_e2e_tests.e2e_test_utils.clients import AirflowClient, 
get_elasticsearch_session
+
+
+class TestRemoteLoggingElasticsearch:
+    airflow_client = AirflowClient()
+    dag_id = "example_xcom_test"
+    task_id = "bash_pull"
+    retry_interval_in_seconds = 5
+    max_retries = 12
+    target_index = "airflow-e2e-logs"
+    expected_message = "finished"
+    elasticsearch_url = "http://localhost:9200";
+    expected_log_id_prefix = f"{dag_id}-{task_id}-"
+
+    def test_remote_logging_elasticsearch(self):
+        """Test that a DAG using remote logging to Elasticsearch completes 
successfully."""
+
+        self.airflow_client.un_pause_dag(TestRemoteLoggingElasticsearch.dag_id)
+
+        resp = self.airflow_client.trigger_dag(
+            TestRemoteLoggingElasticsearch.dag_id,
+            json={"logical_date": datetime.now(timezone.utc).isoformat()},
+        )
+        run_id = resp["dag_run_id"]
+        state = self.airflow_client.wait_for_dag_run(
+            dag_id=TestRemoteLoggingElasticsearch.dag_id,
+            run_id=run_id,
+        )
+
+        assert state == "success", (
+            f"DAG {TestRemoteLoggingElasticsearch.dag_id} did not complete 
successfully. Final state: {state}"
+        )
+
+        elasticsearch_session = get_elasticsearch_session()
+        matching_logs = []
+        for _ in range(self.max_retries):
+            response = elasticsearch_session.post(
+                f"{self.elasticsearch_url}/{self.target_index}/_search",
+                json={
+                    "size": 200,
+                    "query": {"match_all": {}},
+                },
+            )
+            if response.status_code == 404:
+                time.sleep(self.retry_interval_in_seconds)
+                continue

Review Comment:
   Do we need to handle the retry here again? The request session already have 
retry if I understand correctly.
   
   
   Or if we need to handle the retry here, should the status codes include 50x 
like the request session factory function?



-- 
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]

Reply via email to