feat(connection): add history_server_url config field
Add a new optional field to Connection for the Spark History Server
base URL. The field is stored as part of the connection but is not
yet consumed by any tool — for now it's a labeled place to record
where SHS lives on the cluster, and a hook for future SHS-specific
tools. To actually fetch SHS endpoints today, use fetch_url with the
SHS host added to url_allowlist.
The field is Optional[str], default None. Same nullability as
yarn_rm_url. The SHS host and the YARN RM host are usually
different, so this is independent of yarn_rm_url.
Schema:
- models.py: Connection.history_server_url (str | None, default None)
- requests.py:
- SaveConnectionRequest.history_server_url (str | None, default None)
- UpdateConnectionRequest.history_server_url (str | None, default None)
- tools/connections.py: save_connection signature gains
history_server_url with the _UNSET sentinel pattern (same as
yarn_rm_url, url_allowlist, etc.) so the upsert path correctly
distinguishes "not provided" from "explicitly None".
- tools/connections.py: update_connection docstring lists the new
field in the mutable fields set.
Tests (4 new in tests/unit/test_connection_tools.py):
- test_save_connection_with_history_server_url
- test_save_connection_history_server_url_defaults_to_none
- test_update_connection_changes_history_server_url
- test_update_connection_keeps_history_server_url_when_omitted
Tests: 398 passed (was 394, +4 net).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -195,3 +195,39 @@ def test_update_connection_persists_to_disk(_fresh_store, tmp_path):
|
||||
connections.update_connection(name="prod", master="spark://new:7077")
|
||||
raw = json.loads((tmp_path / "connections.json").read_text())
|
||||
assert raw["prod"]["master"] == "spark://new:7077"
|
||||
|
||||
|
||||
# --- history_server_url ---
|
||||
|
||||
def test_save_connection_with_history_server_url(_fresh_store):
|
||||
connections.save_connection(
|
||||
name="prod",
|
||||
master="yarn",
|
||||
history_server_url="http://history.prod.internal:18080",
|
||||
)
|
||||
assert _fresh_store.get("prod").history_server_url == "http://history.prod.internal:18080"
|
||||
|
||||
|
||||
def test_save_connection_history_server_url_defaults_to_none(_fresh_store):
|
||||
connections.save_connection(name="prod", master="yarn")
|
||||
assert _fresh_store.get("prod").history_server_url is None
|
||||
|
||||
|
||||
def test_update_connection_changes_history_server_url(_fresh_store):
|
||||
connections.save_connection(name="prod", master="yarn")
|
||||
out = connections.update_connection(
|
||||
name="prod",
|
||||
history_server_url="http://history2.prod.internal:18080",
|
||||
)
|
||||
assert out["history_server_url"] == "http://history2.prod.internal:18080"
|
||||
assert _fresh_store.get("prod").history_server_url == "http://history2.prod.internal:18080"
|
||||
|
||||
|
||||
def test_update_connection_keeps_history_server_url_when_omitted(_fresh_store):
|
||||
connections.save_connection(
|
||||
name="prod",
|
||||
master="yarn",
|
||||
history_server_url="http://history.prod.internal:18080",
|
||||
)
|
||||
out = connections.update_connection(name="prod", master="spark://new:7077")
|
||||
assert out["history_server_url"] == "http://history.prod.internal:18080"
|
||||
|
||||
Reference in New Issue
Block a user