amoghrajesh commented on code in PR #77015:
URL: https://github.com/apache/airflow/pull/77015#discussion_r4663954284
##########
providers/databricks/tests/unit/databricks/operators/test_databricks.py:
##########
@@ -3648,6 +3648,69 @@ def
test_resubmits_when_stored_run_in_terminal_failure(self, db_mock_class):
task_store.set.assert_called_once_with("databricks_run_now_id", RUN_ID)
assert op.run_id == RUN_ID
+ @pytest.mark.parametrize(
+ ("resume_on_retry", "airflow_3_5_plus", "warns"),
+ [
+ pytest.param(True, False, True, id="true_below_3_5"),
+ pytest.param(False, False, False, id="false_below_3_5"),
+ pytest.param(None, False, False, id="unset_below_3_5"),
+ pytest.param(True, True, False, id="true_on_3_5"),
+ ],
+ )
+ def test_resume_on_retry_warns_only_when_requested_below_3_5(
+ self, recwarn, resume_on_retry, airflow_3_5_plus, warns
+ ):
+ with mock.patch(
+
"airflow.providers.databricks.operators.databricks.AIRFLOW_V_3_5_PLUS",
airflow_3_5_plus
+ ):
+ DatabricksRunNowOperator(task_id=TASK_ID, job_id=JOB_ID,
resume_on_retry=resume_on_retry)
+
+ messages = [str(w.message) for w in recwarn if issubclass(w.category,
UserWarning)]
+ assert ("`resume_on_retry` has no effect on Airflow versions below
3.5." in messages) is warns
+
+ @pytest.mark.skipif(not AIRFLOW_V_3_5_PLUS, reason="resume_failed_job
requires Airflow 3.5+")
+
@mock.patch("airflow.providers.databricks.operators.databricks.DatabricksHook")
+ def test_repairs_stored_failed_run_instead_of_resubmitting(self,
db_mock_class):
+ op = DatabricksRunNowOperator(task_id=TASK_ID, job_id=JOB_ID)
+ db_mock = db_mock_class.return_value
+ db_mock.get_run.side_effect = [
+ make_run_state("TERMINATED", "FAILED"),
+ make_run_state("TERMINATED", "SUCCESS"),
+ ]
+ db_mock.get_latest_repair_id.return_value = None
+ task_store = MagicMock(spec_set=["get", "set"])
+ task_store.get.return_value = RUN_ID
+
+ op.execute(self._context(task_store))
+
+ db_mock.repair_run.assert_called_once_with({"run_id": RUN_ID,
"rerun_all_failed_tasks": True})
Review Comment:
Added both
--
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]