You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "amoghrajesh (via GitHub)" <gi...@apache.org> on 2025/11/06 10:05:42 UTC

[PR] Expanding task sdk integration tests to test few dagrun operations [airflow]

amoghrajesh opened a new pull request, #57955:
URL: https://github.com/apache/airflow/pull/57955

   <!--
    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.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   Expanding the test set for task sdk integration tests to test a few dagrun endpoints in execution API:
   - get_state
   - get_count
   
   For remaining endpoints, will be running it part of a community exercise. Will add stubs for remaining tests in a follow up
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [airflow-core/newsfragments](https://github.com/apache/airflow/tree/main/airflow-core/newsfragments).
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expanding task sdk integration tests to test few dagrun operations [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #57955:
URL: https://github.com/apache/airflow/pull/57955#discussion_r2501895573


##########
task-sdk-tests/tests/task_sdk_tests/test_dag_run_operations.py:
##########
@@ -0,0 +1,70 @@
+#
+# 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.
+"""
+Integration tests for DAG Run operations.
+
+These tests validate the Execution API endpoints for DAG Run operations:
+- get_state(): Get DAG run state
+- get_count(): Get count of DAG runs
+"""
+
+from __future__ import annotations
+
+from airflow.sdk.api.datamodels._generated import DagRunStateResponse
+from airflow.sdk.execution_time.comms import DRCount
+from task_sdk_tests import console
+
+
+def test_dag_run_get_state(sdk_client, dag_info):
+    """Test getting DAG run state."""
+    console.print("[yellow]Getting DAG run state...")
+
+    response = sdk_client.dag_runs.get_state(
+        dag_id=dag_info["dag_id"],
+        run_id=dag_info["dag_run_id"],
+    )
+
+    console.print(" DAG Run State Response ".center(72, "="))
+    console.print(f"[bright_blue]Response Type:[/] {type(response).__name__}")
+    console.print(f"[bright_blue]State:[/] {response.state}")
+    console.print("=" * 72)
+
+    assert isinstance(response, DagRunStateResponse)
+    assert response.state is not None
+    assert response.state in ["running", "success"]
+    console.print("[green]✅ DAG run get state test passed!")
+
+
+def test_dag_run_get_count(sdk_client, dag_info):
+    """Test getting count of DAG runs."""
+    console.print("[yellow]Getting DAG run count...")
+
+    response = sdk_client.dag_runs.get_count(
+        dag_id=dag_info["dag_id"],
+        run_ids=[dag_info["dag_run_id"]],
+    )
+
+    console.print(" DAG Run Count Response ".center(72, "="))

Review Comment:
   It was intentional to get a nice display with a space indented out of the mainline logging :)



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expanding task sdk integration tests to test few dagrun operations [airflow]

Posted by "bugraoz93 (via GitHub)" <gi...@apache.org>.
bugraoz93 commented on code in PR #57955:
URL: https://github.com/apache/airflow/pull/57955#discussion_r2500157633


##########
task-sdk-tests/tests/task_sdk_tests/test_dag_run_operations.py:
##########
@@ -0,0 +1,70 @@
+#
+# 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.
+"""
+Integration tests for DAG Run operations.
+
+These tests validate the Execution API endpoints for DAG Run operations:
+- get_state(): Get DAG run state
+- get_count(): Get count of DAG runs
+"""
+
+from __future__ import annotations
+
+from airflow.sdk.api.datamodels._generated import DagRunStateResponse
+from airflow.sdk.execution_time.comms import DRCount
+from task_sdk_tests import console
+
+
+def test_dag_run_get_state(sdk_client, dag_info):
+    """Test getting DAG run state."""
+    console.print("[yellow]Getting DAG run state...")
+
+    response = sdk_client.dag_runs.get_state(
+        dag_id=dag_info["dag_id"],
+        run_id=dag_info["dag_run_id"],
+    )
+
+    console.print(" DAG Run State Response ".center(72, "="))
+    console.print(f"[bright_blue]Response Type:[/] {type(response).__name__}")
+    console.print(f"[bright_blue]State:[/] {response.state}")
+    console.print("=" * 72)
+
+    assert isinstance(response, DagRunStateResponse)
+    assert response.state is not None
+    assert response.state in ["running", "success"]
+    console.print("[green]✅ DAG run get state test passed!")
+
+
+def test_dag_run_get_count(sdk_client, dag_info):
+    """Test getting count of DAG runs."""
+    console.print("[yellow]Getting DAG run count...")
+
+    response = sdk_client.dag_runs.get_count(
+        dag_id=dag_info["dag_id"],
+        run_ids=[dag_info["dag_run_id"]],
+    )
+
+    console.print(" DAG Run Count Response ".center(72, "="))

Review Comment:
   ```suggestion
       console.print("DAG Run Count Response ".center(72, "="))
   ```
   



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expanding task sdk integration tests to test few dagrun operations [airflow]

Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh merged PR #57955:
URL: https://github.com/apache/airflow/pull/57955


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org