adaptai / platform /signalcore /verify_deployment.py
ADAPT-Chase's picture
Add files using upload-large-folder tool
38c314f verified
#!/usr/bin/env python3
"""
Phase 2 Deployment Verification Script
Tests the deployed neuromorphic security and DataOps integration services
"""
import asyncio
import sys
import time
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), 'commsops'))
from neuromorphic_security import NeuromorphicSecurityAPI
from dataops_integration import DataOpsIntegration, create_dataops_integration
async def test_neuromorphic_security():
"""Test the neuromorphic security service"""
print("πŸ”’ Testing Neuromorphic Security Service...")
api = NeuromorphicSecurityAPI()
# Test various message types
test_messages = [
(b'Normal operational data', 'Normal message'),
(b'X' * 5000, 'Large payload'),
(b'\x00\x01\x02\x03' * 100, 'Binary data'),
(b'Potential security threat pattern', 'Suspicious content')
]
results = []
for message_data, description in test_messages:
result = await api.scan_message(message_data, 'data_ops')
results.append({
'description': description,
'approved': result.approved,
'confidence': result.confidence,
'risk_score': result.risk_score,
'processing_time': result.processing_time_ms
})
print(f" {description}: {'βœ…' if result.approved else '❌'} "
f"(Risk: {result.risk_score:.2f}, Time: {result.processing_time_ms:.2f}ms)")
# Get overall metrics
metrics = await api.get_security_metrics()
print(f" Total messages scanned: {metrics['total_messages_scanned']}")
print(f" Approval rate: {metrics['approval_rate']:.2%}")
return all(r['approved'] for r in results if 'Normal' in r['description'])
async def test_dataops_integration():
"""Test the DataOps integration service"""
print("πŸ”— Testing DataOps Integration Service...")
integration = create_dataops_integration()
# Test storage with security
test_data = {
'operation': 'test_storage',
'data': {'sample': 'integration_test', 'value': 42, 'timestamp': time.time()},
'metadata': {'test_id': 'phase2_verification', 'domain': 'data_ops'}
}
start_time = time.time()
storage_result = await integration.store_with_security(test_data, 'data_ops')
storage_time = (time.time() - start_time) * 1000
print(f" Storage operation: {'βœ…' if storage_result.success else '❌'} "
f"(Time: {storage_time:.2f}ms)")
if storage_result.success:
# Test retrieval
start_time = time.time()
retrieved_data = await integration.retrieve_with_security(storage_result.storage_id)
retrieval_time = (time.time() - start_time) * 1000
print(f" Retrieval operation: {'βœ…' if retrieved_data.get('security_valid') else '❌'} "
f"(Time: {retrieval_time:.2f}ms)")
# Get performance metrics
metrics = await integration.get_performance_metrics()
print(f" Cross-domain latency: {metrics['integration_metrics']['cross_domain_latency']:.2f}ms")
print(f" Data throughput: {metrics['integration_metrics']['data_throughput']:,} ops/s")
return storage_result.success
async def test_service_connectivity():
"""Test that services are running and responsive"""
print("πŸ“‘ Testing Service Connectivity...")
# Check if supervisor services are running
try:
import subprocess
result = subprocess.run(['sudo', 'supervisorctl', 'status', 'commsops:'],
capture_output=True, text=True, timeout=10)
if 'RUNNING' in result.stdout:
print(" βœ… Supervisor services: RUNNING")
# Parse service status
lines = result.stdout.strip().split('\n')
for line in lines:
if 'commsops:' in line:
service_name = line.split()[0]
status = line.split()[1]
print(f" {service_name}: {status}")
return True
else:
print(" ❌ Supervisor services: NOT RUNNING")
return False
except Exception as e:
print(f" ❌ Service check failed: {e}")
return False
async def main():
"""Main verification routine"""
print("πŸš€ Phase 2 Deployment Verification")
print("=" * 50)
all_tests_passed = True
# Test 1: Service connectivity
connectivity_ok = await test_service_connectivity()
all_tests_passed &= connectivity_ok
print()
# Test 2: Neuromorphic security
if connectivity_ok:
security_ok = await test_neuromorphic_security()
all_tests_passed &= security_ok
print()
# Test 3: DataOps integration
if connectivity_ok:
integration_ok = await test_dataops_integration()
all_tests_passed &= integration_ok
print()
# Final results
print("πŸ“Š Verification Results:")
print("=" * 50)
print(f"Service Connectivity: {'βœ… PASS' if connectivity_ok else '❌ FAIL'}")
if connectivity_ok:
print(f"Neuromorphic Security: {'βœ… PASS' if security_ok else '❌ FAIL'}")
print(f"DataOps Integration: {'βœ… PASS' if integration_ok else '❌ FAIL'}")
print(f"\nOverall Status: {'πŸŽ‰ ALL TESTS PASSED' if all_tests_passed else '❌ DEPLOYMENT ISSUES'}")
if all_tests_passed:
print("\nπŸš€ Phase 2 Integration is fully operational and production-ready!")
print("Next steps:")
print(" - Integrate with monitoring dashboard")
print(" - Update alerting systems")
print(" - Begin Phase 3 MLOps integration")
else:
print("\n⚠️ Some tests failed. Check service logs and configuration.")
return all_tests_passed
if __name__ == "__main__":
success = asyncio.run(main())
sys.exit(0 if success else 1)