feat: add kill_job tool
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# coding=utf-8
|
||||
from datetime import datetime
|
||||
from unittest.mock import patch
|
||||
|
||||
from spark_executor.core.job_store import JobStore
|
||||
from spark_executor.models import Job
|
||||
from spark_executor.tools import kill
|
||||
|
||||
|
||||
def test_kill_job_calls_yarn_kill():
|
||||
kill.store = JobStore()
|
||||
kill.store.put(
|
||||
Job(
|
||||
job_id="abc",
|
||||
application_id="application_1",
|
||||
script_path="/tmp/j.py",
|
||||
queue="default",
|
||||
submit_time=datetime(2026, 6, 24),
|
||||
connection="prod",
|
||||
)
|
||||
)
|
||||
with patch("spark_executor.tools.kill.kill_application") as m:
|
||||
result = kill.kill_job("abc")
|
||||
m.assert_called_once_with("application_1")
|
||||
assert result == {
|
||||
"job_id": "abc",
|
||||
"application_id": "application_1",
|
||||
"status": "KILLED",
|
||||
}
|
||||
|
||||
|
||||
def test_kill_job_raises_for_unknown_job():
|
||||
kill.store = JobStore()
|
||||
import pytest
|
||||
with pytest.raises(KeyError):
|
||||
kill.kill_job("missing")
|
||||
Reference in New Issue
Block a user