Revanth14 commented on code in PR #67626:
URL: https://github.com/apache/airflow/pull/67626#discussion_r3315544655


##########
providers/dbt/cloud/tests/unit/dbt/cloud/triggers/test_dbt.py:
##########
@@ -87,6 +89,37 @@ async def test_dbt_run_job_trigger(self, 
mock_get_job_status, end_time):
         assert task.done() is False
         asyncio.get_event_loop().stop()
 
+    @pytest.mark.asyncio
+    
@mock.patch("airflow.providers.dbt.cloud.hooks.dbt.DbtCloudHook.get_job_status")
+    async def test_dbt_run_job_trigger_uses_wall_clock_end_time(self, 
mock_get_job_status, monkeypatch):
+        """Assert serialized end_time is compared to wall-clock time, not 
monotonic time."""
+
+        clock = MagicMock()
+        clock.time.return_value = 1000.0
+        clock.monotonic.return_value = 10000.0
+        monkeypatch.setattr(dbt_trigger_module, "time", clock)
+
+        mock_get_job_status.return_value = DbtCloudJobRunStatus.RUNNING.value
+        trigger = DbtCloudRunJobTrigger(
+            conn_id=self.CONN_ID,
+            poll_interval=self.POLL_INTERVAL,
+            end_time=1060.0,
+            run_id=self.RUN_ID,
+            account_id=self.ACCOUNT_ID,
+        )
+
+        task = asyncio.create_task(trigger.run().__anext__())
+        await asyncio.sleep(0)
+
+        assert task.done() is False
+        clock.time.assert_called()
+        clock.monotonic.assert_not_called()
+        mock_get_job_status.assert_called_once_with(self.RUN_ID, 
self.ACCOUNT_ID)
+
+        task.cancel()
+        with suppress(asyncio.CancelledError):
+            await task
+

Review Comment:
   Thanks, I adjusted this test to assert the same behavior: the trigger uses 
`time.time()` and does not call `time.monotonic()` when comparing the 
serialized `end_time`.
   
   I used a single patch for `airflow.providers.dbt.cloud.triggers.dbt.time` so 
the assertion stays scoped to the trigger module’s `time` usage, while still 
avoiding an immediate timeout when monotonic time would be past the deadline.



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