kaxil commented on code in PR #43722:
URL: https://github.com/apache/airflow/pull/43722#discussion_r1830875117
##########
tests/api_fastapi/execution_api/routes/test_task_instance.py:
##########
@@ -192,3 +192,133 @@ def test_ti_update_state_database_error(self, client,
session, create_task_insta
response = client.patch(f"/execution/task_instance/{ti.id}/state",
json=payload)
assert response.status_code == 500
assert response.json()["detail"] == "Database error occurred"
+
+
+class TestTIHealthEndpoint:
+ def setup_method(self):
+ clear_db_runs()
+
+ def teardown_method(self):
+ clear_db_runs()
+
+ @pytest.mark.parametrize(
+ ("hostname", "unixname", "expected_status_code", "expected_detail"),
+ [
+ # Case: Successful heartbeat
+ ("random-hostname", "random-unixname", 204, None),
+ # Case: Conflict due to hostname mismatch
+ (
+ "wrong-hostname",
+ "random-unixname",
+ 409,
+ {
+ "reason": "running_elsewhere",
+ "message": "TI is already running elsewhere",
+ "current_hostname": "random-hostname",
+ "current_unixname": "random-unixname",
+ },
+ ),
+ # Case: Conflict due to unixname mismatch
+ (
+ "random-hostname",
+ "wrong-unixname",
+ 409,
+ {
+ "reason": "running_elsewhere",
+ "message": "TI is already running elsewhere",
+ "current_hostname": "random-hostname",
+ "current_unixname": "random-unixname",
+ },
+ ),
+ ],
+ )
+ @mock.patch("airflow.utils.timezone.utcnow")
Review Comment:
Sure, can do. Any strong reason for that preference in this case?
--
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]