conductor(checkpoint): Checkpoint end of Phase 1 - Nomad Discovery Enhancement
This commit is contained in:
@@ -88,4 +88,46 @@ def test_get_node_map_failure(mock_run):
|
||||
|
||||
# It should not raise
|
||||
node_map = nomad_client.get_node_map()
|
||||
assert node_map == {}
|
||||
assert node_map == {}
|
||||
|
||||
@patch("subprocess.run")
|
||||
def test_get_job_allocations(mock_run):
|
||||
"""Test getting all allocations for a job with their IPs."""
|
||||
# Mock 'nomad job status navidrome-litefs'
|
||||
mock_job_status = MagicMock()
|
||||
mock_job_status.stdout = """
|
||||
Allocations
|
||||
ID Node ID Node Name Status Created
|
||||
abc12345 node1 host1 running 1h ago
|
||||
def67890 node2 host2 running 1h ago
|
||||
"""
|
||||
|
||||
# Mock 'nomad alloc status' for each alloc
|
||||
mock_alloc1 = MagicMock()
|
||||
mock_alloc1.stdout = """
|
||||
ID = abc12345
|
||||
Node Name = host1
|
||||
Allocation Addresses:
|
||||
Label Dynamic Address
|
||||
*http yes 1.1.1.1:4533 -> 4533
|
||||
*litefs yes 1.1.1.1:20202 -> 20202
|
||||
"""
|
||||
mock_alloc2 = MagicMock()
|
||||
mock_alloc2.stdout = """
|
||||
ID = def67890
|
||||
Node Name = host2
|
||||
Allocation Addresses:
|
||||
Label Dynamic Address
|
||||
*http yes 2.2.2.2:4533 -> 4533
|
||||
*litefs yes 2.2.2.2:20202 -> 20202
|
||||
"""
|
||||
|
||||
mock_run.side_effect = [mock_job_status, mock_alloc1, mock_alloc2]
|
||||
|
||||
# This should fail initially because nomad_client.get_job_allocations doesn't exist
|
||||
try:
|
||||
allocs = nomad_client.get_job_allocations("navidrome-litefs")
|
||||
assert len(allocs) == 2
|
||||
assert allocs[0]["ip"] == "1.1.1.1"
|
||||
except AttributeError:
|
||||
pytest.fail("nomad_client.get_job_allocations not implemented")
|
||||
Reference in New Issue
Block a user