Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Successful in 2s
Deploy to Testnet / deploy-testnet (push) Successful in 1m12s
Documentation Validation / validate-docs (push) Failing after 8s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Multi-Node Stress Testing / stress-test (push) Successful in 2s
Node Failover Simulation / failover-test (push) Successful in 4s
- Add environment variables section (GENESIS_IP, FOLLOWER_IP, RPC_PORT, CHAIN_ID) - Document systemd service management for agent daemon - Update wallet configuration with password file paths - Add service management commands (start, status, restart, logs) - Document service file locations and wrapper scripts - Update troubleshooting section with systemd commands - Replace hardcoded IPs with environment variables - Add service health checks to prerequisites - Update version to 2
88 lines
2.7 KiB
Python
88 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Test hierarchical config implementation"""
|
|
|
|
import sys
|
|
import os
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
# Add the aitbc module to path
|
|
sys.path.insert(0, '/opt/aitbc')
|
|
|
|
def test_hierarchical_config():
|
|
print("Testing Hierarchical Configuration System...")
|
|
|
|
try:
|
|
from aitbc.hierarchical_config import load_config, ValidatedAITBCConfig, create_config_template
|
|
print("✓ Imports successful")
|
|
except ImportError as e:
|
|
print(f"✗ Import failed: {e}")
|
|
return False
|
|
|
|
# Test 1: Default loading
|
|
try:
|
|
config = load_config()
|
|
print(f"✓ Default config loaded: env={config.environment}, port={config.port}")
|
|
except Exception as e:
|
|
print(f"✗ Default config failed: {e}")
|
|
return False
|
|
|
|
# Test 2: File-based config
|
|
try:
|
|
with tempfile.NamedTemporaryFile(mode='w', suffix='.yaml', delete=False) as f:
|
|
f.write('''
|
|
environment: production
|
|
port: 9000
|
|
debug: false
|
|
log_level: WARNING
|
|
secret_key: "test-secret"
|
|
jwt_secret: "test-jwt"
|
|
''')
|
|
temp_path = f.name
|
|
|
|
config = load_config(config_file=temp_path)
|
|
print(f"✓ File config loaded: env={config.environment}, port={config.port}")
|
|
os.unlink(temp_path)
|
|
except Exception as e:
|
|
print(f"✗ File config failed: {e}")
|
|
return False
|
|
|
|
# Test 3: Validation
|
|
try:
|
|
# Set up for production validation
|
|
os.environ['AITBC_ENVIRONMENT'] = 'production'
|
|
os.environ['AITBC_SECRET_KEY'] = 'test-key'
|
|
os.environ['AITBC_JWT_SECRET'] = 'test-jwt'
|
|
config = ValidatedAITBCConfig()
|
|
print('✓ Production validation passed')
|
|
|
|
# Should fail without secrets
|
|
del os.environ['AITBC_SECRET_KEY']
|
|
try:
|
|
config = ValidatedAITBCConfig()
|
|
print('✗ Validation should have failed')
|
|
return False
|
|
except Exception:
|
|
print('✓ Validation correctly rejected missing secret')
|
|
os.environ['AITBC_SECRET_KEY'] = 'test-key' # restore
|
|
|
|
except Exception as e:
|
|
print(f'✗ Validation test failed: {e}')
|
|
return False
|
|
|
|
# Test 4: Templates
|
|
try:
|
|
dev = create_config_template('development')
|
|
prod = create_config_template('production')
|
|
print(f'✓ Templates created: dev_debug={dev["debug"]}, prod_workers={prod["workers"]}')
|
|
except Exception as e:
|
|
print(f'✗ Template test failed: {e}')
|
|
return False
|
|
|
|
print("✓ All hierarchical config tests passed!")
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
success = test_hierarchical_config()
|
|
sys.exit(0 if success else 1)
|