FrankYang0529 commented on code in PR #72057:
URL: https://github.com/apache/airflow/pull/72057#discussion_r4172299946


##########
providers/edge3/tests/unit/edge3/worker_api/routes/test_jobs.py:
##########
@@ -177,6 +178,163 @@ def 
test_state_finish_metric_omits_team_name_for_global_job(self, mock_stats_inc
                 },
             )
 
+    @patch(f"{Stats.__module__}.Stats.incr")
+    def test_fetch_returns_highest_priority_job_first(self, mock_stats_incr, 
session: Session):
+        with create_session() as session:
+            session.add(
+                EdgeWorkerModel(
+                    worker_name="worker1", state=EdgeWorkerState.IDLE, 
queues=[QUEUE], team_name=None
+                )
+            )
+            # The oldest job carries the lowest priority, so a FIFO-only query 
returns "low" first.
+            queued_dttm = timezone.utcnow()
+            for offset, (task_id, priority_weight) in enumerate([("low", 1), 
("high", 100), ("medium", 10)]):
+                session.add(
+                    EdgeJobModel(
+                        dag_id=DAG_ID,
+                        task_id=task_id,
+                        run_id=RUN_ID,
+                        try_number=1,
+                        map_index=-1,
+                        state=TaskInstanceState.QUEUED,
+                        queue=QUEUE,
+                        concurrency_slots=1,
+                        command=MOCK_COMMAND_STR,
+                        priority_weight=priority_weight,
+                        queued_dttm=queued_dttm + timedelta(seconds=offset),
+                    )
+                )
+            session.commit()
+
+            body = WorkerQueuesBody(free_concurrency=1, queues=[QUEUE], 
team_name=None)
+            fetched = [fetch("worker1", body, session) for _ in range(3)]
+
+            assert [job.task_id for job in fetched if job] == ["high", 
"medium", "low"]
+
+    @pytest.mark.skipif(not AIRFLOW_V_3_3_PLUS, reason="ExecuteCallback 
requires Airflow 3.3+")
+    @patch(f"{Stats.__module__}.Stats.incr")
+    def test_fetch_returns_callbacks_before_higher_priority_tasks(self, 
mock_stats_incr, session: Session):

Review Comment:
   Updated it. Thanks.



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