rawwar commented on code in PR #44206:
URL: https://github.com/apache/airflow/pull/44206#discussion_r1850368734


##########
tests/api_fastapi/core_api/routes/public/test_task_instances.py:
##########
@@ -1497,6 +1497,75 @@ def 
test_should_respond_200_with_different_try_numbers(self, test_client, try_nu
             "dag_run_id": "TEST_DAG_RUN_ID",
         }
 
+    @pytest.mark.parametrize("try_number", [1, 2])
+    def test_should_respond_200_with_mapped_task_at_different_try_numbers(
+        self, test_client, try_number, session
+    ):
+        tis = self.create_task_instances(session, task_instances=[{"state": 
State.FAILED}])
+        print(tis)
+        old_ti = tis[0]
+        print(old_ti)
+        for idx in (1, 2):
+            ti = TaskInstance(task=old_ti.task, run_id=old_ti.run_id, 
map_index=idx)
+            ti.rendered_task_instance_fields = RTIF(ti, render_templates=False)
+            ti.try_number = 1
+            for attr in ["duration", "end_date", "pid", "start_date", "state", 
"queue", "note"]:
+                setattr(ti, attr, getattr(old_ti, attr))
+            session.add(ti)
+        session.commit()
+        tis = session.query(TaskInstance).all()
+        print(tis)
+        # Record the task instance history
+        from airflow.models.taskinstance import clear_task_instances
+
+        clear_task_instances(tis, session)
+        # Simulate the try_number increasing to new values in TI
+        for ti in tis:
+            if ti.map_index > 0:
+                ti.try_number += 1
+                ti.queue = "default_queue"
+                session.merge(ti)
+        session.commit()
+        tis = session.query(TaskInstance).all()
+        print(tis)

Review Comment:
   ```suggestion
   ```



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