- Migrated from HIVE branding to WHOOSH across all components - Enhanced backend API with new services: AI models, BZZZ integration, templates, members - Added comprehensive testing suite with security, performance, and integration tests - Improved frontend with new components for project setup, AI models, and team management - Updated MCP server implementation with WHOOSH-specific tools and resources - Enhanced deployment configurations with production-ready Docker setups - Added comprehensive documentation and setup guides - Implemented age encryption service and UCXL integration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
189 lines
7.7 KiB
Python
189 lines
7.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test BZZZ Integration Service
|
|
Verify integration with existing BZZZ distributed system
|
|
"""
|
|
|
|
import asyncio
|
|
import json
|
|
import sys
|
|
from datetime import datetime
|
|
from app.services.bzzz_integration_service import BzzzIntegrationService, AgentRole
|
|
|
|
async def test_bzzz_integration():
|
|
"""Test BZZZ integration functionality"""
|
|
print("🔗 Testing BZZZ Integration Service")
|
|
print("=" * 60)
|
|
|
|
# Initialize service
|
|
service = BzzzIntegrationService()
|
|
|
|
try:
|
|
# Test initialization
|
|
print("\n1. Testing Service Initialization...")
|
|
initialized = await service.initialize()
|
|
print(f" Initialization result: {'✅ Success' if initialized else '❌ Failed'}")
|
|
|
|
if not initialized:
|
|
print(" ⚠️ Cannot continue without successful initialization")
|
|
return
|
|
|
|
# Test team status
|
|
print("\n2. Testing Team Status...")
|
|
status = await service.get_team_status()
|
|
print(f" Total team members: {status.get('total_members', 0)}")
|
|
print(f" Online members: {status.get('online_members', 0)}")
|
|
print(f" Network health: {status.get('network_health', 0):.2%}")
|
|
print(f" Active decisions: {status.get('active_decisions', 0)}")
|
|
|
|
# Test team member discovery
|
|
print("\n3. Testing Team Member Discovery...")
|
|
print(f" Discovered {len(service.team_members)} team members:")
|
|
for agent_id, member in service.team_members.items():
|
|
print(f" - {agent_id} ({member.role.value}) @ {member.endpoint} [{member.status}]")
|
|
print(f" Capabilities: {', '.join(member.capabilities)}")
|
|
|
|
# Test decision publishing
|
|
print("\n4. Testing Decision Publishing...")
|
|
decision_id = await service.publish_decision(
|
|
title="Test Decision from WHOOSH",
|
|
description="This is a test decision published by the WHOOSH integration service to verify P2P connectivity",
|
|
context={
|
|
"test_type": "integration_test",
|
|
"timestamp": datetime.utcnow().isoformat(),
|
|
"service": "WHOOSH",
|
|
"component": "BZZZ Integration"
|
|
}
|
|
)
|
|
|
|
if decision_id:
|
|
print(f" ✅ Decision published successfully: {decision_id}")
|
|
|
|
# Wait a moment for consensus to develop
|
|
await asyncio.sleep(2)
|
|
|
|
# Test consensus retrieval
|
|
print("\n5. Testing Consensus Retrieval...")
|
|
consensus = await service.get_team_consensus(decision_id)
|
|
if consensus:
|
|
print(f" Decision ID: {consensus['decision_id']}")
|
|
print(f" Total votes: {consensus['total_votes']}")
|
|
print(f" Approvals: {consensus['approvals']}")
|
|
print(f" Approval rate: {consensus['approval_rate']:.2%}")
|
|
print(f" Consensus reached: {'✅ Yes' if consensus['consensus_reached'] else '❌ No'}")
|
|
else:
|
|
print(" ⚠️ No consensus data available yet")
|
|
else:
|
|
print(" ❌ Failed to publish decision")
|
|
|
|
# Test task coordination
|
|
print("\n6. Testing Task Coordination...")
|
|
if service.team_members:
|
|
assignment = await service.coordinate_task_assignment(
|
|
task_description="Test task coordination from WHOOSH integration service",
|
|
required_capabilities=["backend", "ai_coordination"],
|
|
priority="medium"
|
|
)
|
|
|
|
if assignment:
|
|
print(f" ✅ Task assigned to: {assignment['assigned_to']}")
|
|
print(f" Assignment score: {assignment['assignment_score']:.2f}")
|
|
print(f" Alternatives: {len(assignment['alternatives'])} other candidates")
|
|
else:
|
|
print(" ⚠️ No suitable team members found for task")
|
|
else:
|
|
print(" ⚠️ No team members available for task assignment")
|
|
|
|
# Test recent decisions sync
|
|
print("\n7. Testing Decision Synchronization...")
|
|
print(f" Cached decisions: {len(service.active_decisions)}")
|
|
for decision in list(service.active_decisions.values())[:3]: # Show first 3
|
|
print(f" - {decision.title} by {decision.author_role} at {decision.timestamp}")
|
|
|
|
# Network health summary
|
|
print("\n8. Network Health Summary...")
|
|
online_count = sum(1 for m in service.team_members.values() if m.status == "online")
|
|
total_count = len(service.team_members)
|
|
health_percentage = (online_count / total_count * 100) if total_count > 0 else 0
|
|
|
|
print(f" 🌐 Network Status: {online_count}/{total_count} members online ({health_percentage:.1f}%)")
|
|
|
|
# Role distribution
|
|
role_dist = {}
|
|
for member in service.team_members.values():
|
|
role = member.role.value
|
|
role_dist[role] = role_dist.get(role, 0) + 1
|
|
|
|
print(f" 👥 Role Distribution:")
|
|
for role, count in role_dist.items():
|
|
print(f" - {role.replace('_', ' ').title()}: {count}")
|
|
|
|
print("\n✅ BZZZ Integration Test Completed Successfully!")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Test failed with error: {e}")
|
|
import traceback
|
|
traceback.print_exc()
|
|
|
|
finally:
|
|
# Cleanup
|
|
await service.cleanup()
|
|
print("\n🧹 Service cleanup completed")
|
|
|
|
async def test_specific_endpoints():
|
|
"""Test connectivity to specific BZZZ endpoints"""
|
|
print("\n" + "=" * 60)
|
|
print("🔍 Testing Specific BZZZ Endpoints")
|
|
print("=" * 60)
|
|
|
|
endpoints = [
|
|
"http://192.168.1.27:8080", # walnut
|
|
"http://192.168.1.72:8080", # acacia
|
|
"http://192.168.1.113:8080", # ironwood
|
|
]
|
|
|
|
import aiohttp
|
|
async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=10)) as session:
|
|
for endpoint in endpoints:
|
|
try:
|
|
print(f"\n🔗 Testing {endpoint}...")
|
|
|
|
# Test basic health
|
|
async with session.get(f"{endpoint}/api/agent/status") as response:
|
|
if response.status == 200:
|
|
data = await response.json()
|
|
print(f" ✅ Health check: {data.get('status', 'unknown')}")
|
|
else:
|
|
print(f" ⚠️ Health check failed: HTTP {response.status}")
|
|
|
|
# Test agents list
|
|
async with session.get(f"{endpoint}/api/agents") as response:
|
|
if response.status == 200:
|
|
data = await response.json()
|
|
agent_count = len(data.get('agents', []))
|
|
print(f" ✅ Agents list: {agent_count} agents")
|
|
else:
|
|
print(f" ⚠️ Agents list failed: HTTP {response.status}")
|
|
|
|
except Exception as e:
|
|
print(f" ❌ Connection failed: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
print("🚀 Starting BZZZ Integration Tests")
|
|
print(f"🕐 Test started at: {datetime.utcnow().isoformat()}")
|
|
|
|
try:
|
|
# Run main integration test
|
|
asyncio.run(test_bzzz_integration())
|
|
|
|
# Run endpoint-specific tests
|
|
asyncio.run(test_specific_endpoints())
|
|
|
|
print(f"\n🏁 All tests completed at: {datetime.utcnow().isoformat()}")
|
|
|
|
except KeyboardInterrupt:
|
|
print("\n⚠️ Tests interrupted by user")
|
|
sys.exit(1)
|
|
except Exception as e:
|
|
print(f"\n❌ Test suite failed: {e}")
|
|
sys.exit(1) |