snapshot
This commit is contained in:
55
test_consul_integration.py
Normal file
55
test_consul_integration.py
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple test script to verify Consul persistence integration
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from checker import ConnectionMonitor
|
||||
|
||||
def test_consul_initialization():
|
||||
"""Test that Consul client initializes correctly"""
|
||||
print("Testing Consul initialization...")
|
||||
|
||||
# Test with Consul URL
|
||||
monitor = ConnectionMonitor(
|
||||
qbittorrent_url='http://test:8080',
|
||||
nomad_url='http://test:4646',
|
||||
tracker_name='test_tracker',
|
||||
consul_url='http://consul.service.dc1.consul:8500'
|
||||
)
|
||||
|
||||
if monitor.consul_client:
|
||||
print("✓ Consul client initialized successfully")
|
||||
else:
|
||||
print("⚠ Consul client not available (python-consul package may be missing)")
|
||||
print("State persistence will be disabled but monitoring will continue")
|
||||
|
||||
# Test state methods
|
||||
print("Testing state persistence methods...")
|
||||
try:
|
||||
# Test save (should handle gracefully if Consul not available)
|
||||
saved = monitor._save_state_to_consul()
|
||||
if saved:
|
||||
print("✓ State save to Consul successful")
|
||||
else:
|
||||
print("⚠ State save failed (expected if Consul not available)")
|
||||
|
||||
# Test load (should handle gracefully if Consul not available)
|
||||
loaded = monitor._load_state_from_consul()
|
||||
if loaded:
|
||||
print("✓ State load from Consul successful")
|
||||
else:
|
||||
print("⚠ State load failed (expected if Consul not available)")
|
||||
|
||||
except Exception as e:
|
||||
print(f"✗ Error testing state methods: {e}")
|
||||
return False
|
||||
|
||||
print("✓ All Consul integration tests completed successfully")
|
||||
return True
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_consul_initialization()
|
||||
Reference in New Issue
Block a user