conductor(checkpoint): Checkpoint end of Phase 1
This commit is contained in:
@@ -55,4 +55,30 @@ def test_get_node_status_error(mock_get):
|
||||
status = litefs_client.get_node_status("192.168.1.101")
|
||||
|
||||
assert "error" in status
|
||||
assert status["is_primary"] is False
|
||||
assert status["is_primary"] is False
|
||||
|
||||
@patch("nomad_client.exec_command")
|
||||
def test_get_node_status_nomad_exec(mock_exec):
|
||||
"""Test fetching LiteFS status via nomad alloc exec."""
|
||||
# Mock LiteFS status output (text format)
|
||||
mock_status_output = """
|
||||
Config:
|
||||
Path: /etc/litefs.yml
|
||||
...
|
||||
Status:
|
||||
Primary: true
|
||||
Uptime: 1h5m10s
|
||||
Replication Lag: 0s
|
||||
"""
|
||||
mock_exec.return_value = mock_status_output
|
||||
|
||||
# We need to mock requests.get to fail first
|
||||
with patch("requests.get") as mock_get:
|
||||
mock_get.side_effect = Exception("HTTP failed")
|
||||
|
||||
status = litefs_client.get_node_status("1.1.1.1", alloc_id="abc12345")
|
||||
|
||||
assert status["is_primary"] is True
|
||||
assert status["uptime"] == "1h5m10s"
|
||||
# Since it's primary, lag might not be shown or be 0
|
||||
assert status["replication_lag"] == "0s"
|
||||
Reference in New Issue
Block a user