|
|
|
|
|
""" |
|
|
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_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)") |
|
|
|
|
|
|
|
|
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_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: |
|
|
|
|
|
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)") |
|
|
|
|
|
|
|
|
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...") |
|
|
|
|
|
|
|
|
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") |
|
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
|
connectivity_ok = await test_service_connectivity() |
|
|
all_tests_passed &= connectivity_ok |
|
|
print() |
|
|
|
|
|
|
|
|
if connectivity_ok: |
|
|
security_ok = await test_neuromorphic_security() |
|
|
all_tests_passed &= security_ok |
|
|
print() |
|
|
|
|
|
|
|
|
if connectivity_ok: |
|
|
integration_ok = await test_dataops_integration() |
|
|
all_tests_passed &= integration_ok |
|
|
print() |
|
|
|
|
|
|
|
|
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) |