chore(conductor): Mark track 'cluster_status_python' as complete
This commit is contained in:
@@ -3,5 +3,5 @@
|
|||||||
This file tracks all major tracks for the project. Each track has its own detailed plan in its respective folder.
|
This file tracks all major tracks for the project. Each track has its own detailed plan in its respective folder.
|
||||||
---
|
---
|
||||||
|
|
||||||
- [~] **Track: create a script that runs on my local system (i don't run consul locally) that: - check consul services are registered correctly - diplays the expected state (who is primary, what replicas exist) - show basic litefs status info for each node**
|
- [x] **Track: create a script that runs on my local system (i don't run consul locally) that: - check consul services are registered correctly - diplays the expected state (who is primary, what replicas exist) - show basic litefs status info for each node**
|
||||||
*Link: [./tracks/cluster_status_python_20260208/](./tracks/cluster_status_python_20260208/)*
|
*Link: [./tracks/cluster_status_python_20260208/](./tracks/cluster_status_python_20260208/)*
|
||||||
|
|||||||
@@ -23,9 +23,9 @@
|
|||||||
- [x] Implement `tabulate` based output with a health summary
|
- [x] Implement `tabulate` based output with a health summary
|
||||||
- [x] Task: Conductor - User Manual Verification 'Phase 3: Data Processing and Formatting' (Protocol in workflow.md)
|
- [x] Task: Conductor - User Manual Verification 'Phase 3: Data Processing and Formatting' (Protocol in workflow.md)
|
||||||
|
|
||||||
## Phase 4: CLI Interface and Final Polishing [ ]
|
## Phase 4: CLI Interface and Final Polishing [x]
|
||||||
- [ ] Task: Implement command-line arguments (argparse)
|
- [x] Task: Implement command-line arguments (argparse)
|
||||||
- [ ] Write tests for CLI argument parsing (Consul URL overrides, etc.)
|
- [x] Write tests for CLI argument parsing (Consul URL overrides, etc.)
|
||||||
- [ ] Finalize the `main` entry point
|
- [x] Finalize the `main` entry point
|
||||||
- [ ] Task: Final verification of script against requirements
|
- [x] Task: Final verification of script against requirements
|
||||||
- [ ] Task: Conductor - User Manual Verification 'Phase 4: CLI Interface and Final Polishing' (Protocol in workflow.md)
|
- [x] Task: Conductor - User Manual Verification 'Phase 4: CLI Interface and Final Polishing' (Protocol in workflow.md)
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ test:
|
|||||||
. .venv/bin/activate && pytest -v --cov=.
|
. .venv/bin/activate && pytest -v --cov=.
|
||||||
|
|
||||||
run:
|
run:
|
||||||
. .venv/bin/activate && python3 cluster_status.py
|
. .venv/bin/activate && PYTHONPATH=. python3 cli.py
|
||||||
|
|||||||
33
scripts/cluster_status/cli.py
Executable file
33
scripts/cluster_status/cli.py
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
import sys
|
||||||
|
import config
|
||||||
|
import cluster_aggregator
|
||||||
|
import output_formatter
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(description="Monitor Navidrome LiteFS/Consul cluster status.")
|
||||||
|
parser.add_argument("--consul-url", help="Override Consul API URL (default from env or hardcoded)")
|
||||||
|
parser.add_argument("--no-color", action="store_true", help="Disable colorized output")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
|
# Resolve Consul URL
|
||||||
|
consul_url = config.get_consul_url(args.consul_url)
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Fetch and aggregate data
|
||||||
|
cluster_data = cluster_aggregator.get_cluster_status(consul_url)
|
||||||
|
|
||||||
|
# Format and print output
|
||||||
|
print(output_formatter.format_summary(cluster_data, use_color=not args.no_color))
|
||||||
|
print("\n" + output_formatter.format_node_table(cluster_data["nodes"], use_color=not args.no_color))
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
18
scripts/cluster_status/tests/test_main.py
Normal file
18
scripts/cluster_status/tests/test_main.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import pytest
|
||||||
|
from unittest.mock import patch, MagicMock
|
||||||
|
import cli
|
||||||
|
import sys
|
||||||
|
|
||||||
|
def test_arg_parsing_default():
|
||||||
|
"""Test that default arguments are parsed correctly."""
|
||||||
|
with patch.object(sys, 'argv', ['cli.py']):
|
||||||
|
args = cli.parse_args()
|
||||||
|
assert args.consul_url is None # Should use config default later
|
||||||
|
assert args.no_color is False
|
||||||
|
|
||||||
|
def test_arg_parsing_custom():
|
||||||
|
"""Test that custom arguments are parsed correctly."""
|
||||||
|
with patch.object(sys, 'argv', ['cli.py', '--consul-url', 'http://custom:8500', '--no-color']):
|
||||||
|
args = cli.parse_args()
|
||||||
|
assert args.consul_url == 'http://custom:8500'
|
||||||
|
assert args.no_color is True
|
||||||
Reference in New Issue
Block a user