conductor(checkpoint): Checkpoint end of Phase 2
This commit is contained in:
@@ -4,7 +4,9 @@ import cluster_aggregator
|
||||
|
||||
@patch("consul_client.get_cluster_services")
|
||||
@patch("litefs_client.get_node_status")
|
||||
def test_aggregate_cluster_status(mock_litefs, mock_consul):
|
||||
@patch("nomad_client.get_allocation_id")
|
||||
@patch("nomad_client.get_allocation_logs")
|
||||
def test_aggregate_cluster_status(mock_nomad_logs, mock_nomad_id, mock_litefs, mock_consul):
|
||||
"""Test aggregating Consul and LiteFS data."""
|
||||
# Mock Consul data
|
||||
mock_consul.return_value = [
|
||||
@@ -19,6 +21,7 @@ def test_aggregate_cluster_status(mock_litefs, mock_consul):
|
||||
return {"is_primary": False, "uptime": 50, "advertise_url": "url2", "replication_lag": 10}
|
||||
|
||||
mock_litefs.side_effect = litefs_side_effect
|
||||
mock_nomad_id.return_value = None
|
||||
|
||||
cluster_data = cluster_aggregator.get_cluster_status("http://consul:8500")
|
||||
|
||||
@@ -35,12 +38,17 @@ def test_aggregate_cluster_status(mock_litefs, mock_consul):
|
||||
|
||||
@patch("consul_client.get_cluster_services")
|
||||
@patch("litefs_client.get_node_status")
|
||||
def test_aggregate_cluster_status_unhealthy(mock_litefs, mock_consul):
|
||||
@patch("nomad_client.get_allocation_id")
|
||||
@patch("nomad_client.get_allocation_logs")
|
||||
def test_aggregate_cluster_status_unhealthy(mock_nomad_logs, mock_nomad_id, mock_litefs, mock_consul):
|
||||
"""Test health calculation when nodes are critical."""
|
||||
mock_consul.return_value = [
|
||||
{"node": "node1", "address": "1.1.1.1", "role": "primary", "status": "critical"}
|
||||
]
|
||||
mock_litefs.return_value = {"is_primary": True, "uptime": 100}
|
||||
mock_nomad_id.return_value = "alloc1"
|
||||
mock_nomad_logs.return_value = "error logs"
|
||||
|
||||
cluster_data = cluster_aggregator.get_cluster_status("http://consul:8500")
|
||||
assert cluster_data["health"] == "Unhealthy"
|
||||
assert cluster_data["nodes"][0]["nomad_logs"] == "error logs"
|
||||
|
||||
Reference in New Issue
Block a user