fix: disable global API key middleware and add test miner creation endpoint
All checks were successful
API Endpoint Tests / test-api-endpoints (push) Successful in 47s
Documentation Validation / validate-docs (push) Successful in 17s
Integration Tests / test-service-integration (push) Successful in 2m11s
Python Tests / test-python (push) Successful in 5m49s
Security Scanning / security-scan (push) Successful in 4m1s
Systemd Sync / sync-systemd (push) Successful in 14s
All checks were successful
API Endpoint Tests / test-api-endpoints (push) Successful in 47s
Documentation Validation / validate-docs (push) Successful in 17s
Integration Tests / test-service-integration (push) Successful in 2m11s
Python Tests / test-python (push) Successful in 5m49s
Security Scanning / security-scan (push) Successful in 4m1s
Systemd Sync / sync-systemd (push) Successful in 14s
API Key Middleware Changes:
- Disabled global API key middleware in favor of dependency injection
- Added comment explaining the change
- Preserves existing middleware code for reference
Admin Router Enhancements:
✅ NEW ENDPOINT: POST /debug/create-test-miner for debugging marketplace sync
- Creates test miner with id "debug-test-miner"
- Updates existing miner to ONLINE status if already exists
- Returns miner_id and session_token for testing
- Requires
This commit is contained in:
262
COMPLETE_TEST_PLAN.md
Normal file
262
COMPLETE_TEST_PLAN.md
Normal file
@@ -0,0 +1,262 @@
|
||||
# AITBC Complete Test Plan - Genesis to Full Operations
|
||||
# Using OpenClaw Skills and Workflow Scripts
|
||||
|
||||
## 🎯 Test Plan Overview
|
||||
Sequential testing from genesis block generation through full AI operations using OpenClaw agents and skills.
|
||||
|
||||
## 📋 Prerequisites Check
|
||||
```bash
|
||||
# Verify OpenClaw is running
|
||||
openclaw status
|
||||
|
||||
# Verify all AITBC services are running
|
||||
systemctl list-units --type=service --state=running | grep aitbc
|
||||
|
||||
# Check wallet access
|
||||
ls -la /var/lib/aitbc/keystore/
|
||||
```
|
||||
|
||||
## 🚀 Phase 1: Genesis Block Generation (OpenClaw)
|
||||
|
||||
### Step 1.1: Pre-flight Setup
|
||||
**Skill**: `openclaw-agent-testing-skill`
|
||||
**Script**: `01_preflight_setup_openclaw.sh`
|
||||
|
||||
```bash
|
||||
# Create OpenClaw session
|
||||
SESSION_ID="genesis-test-$(date +%s)"
|
||||
|
||||
# Test OpenClaw agents first
|
||||
openclaw agent --agent main --message "Execute openclaw-agent-testing-skill with operation: comprehensive, thinking_level: medium" --thinking medium
|
||||
|
||||
# Run pre-flight setup
|
||||
/opt/aitbc/scripts/workflow-openclaw/01_preflight_setup_openclaw.sh
|
||||
```
|
||||
|
||||
### Step 1.2: Genesis Authority Setup
|
||||
**Skill**: `aitbc-basic-operations-skill`
|
||||
**Script**: `02_genesis_authority_setup_openclaw.sh`
|
||||
|
||||
```bash
|
||||
# Setup genesis node using OpenClaw
|
||||
openclaw agent --agent main --message "Execute aitbc-basic-operations-skill to setup genesis authority, create genesis block, and initialize blockchain services" --thinking medium
|
||||
|
||||
# Run genesis setup script
|
||||
/opt/aitbc/scripts/workflow-openclaw/02_genesis_authority_setup_openclaw.sh
|
||||
```
|
||||
|
||||
### Step 1.3: Verify Genesis Block
|
||||
**Skill**: `aitbc-transaction-processor`
|
||||
|
||||
```bash
|
||||
# Verify genesis block creation
|
||||
openclaw agent --agent main --message "Execute aitbc-transaction-processor to verify genesis block, check block height 0, and validate chain state" --thinking medium
|
||||
|
||||
# Manual verification
|
||||
curl -s http://localhost:8006/rpc/head | jq '.height'
|
||||
```
|
||||
|
||||
## 🔗 Phase 2: Follower Node Setup
|
||||
|
||||
### Step 2.1: Follower Node Configuration
|
||||
**Skill**: `aitbc-basic-operations-skill`
|
||||
**Script**: `03_follower_node_setup_openclaw.sh`
|
||||
|
||||
```bash
|
||||
# Setup follower node (aitbc1)
|
||||
openclaw agent --agent main --message "Execute aitbc-basic-operations-skill to setup follower node, connect to genesis, and establish sync" --thinking medium
|
||||
|
||||
# Run follower setup (from aitbc, targets aitbc1)
|
||||
/opt/aitbc/scripts/workflow-openclaw/03_follower_node_setup_openclaw.sh
|
||||
```
|
||||
|
||||
### Step 2.2: Verify Cross-Node Sync
|
||||
**Skill**: `openclaw-agent-communicator`
|
||||
|
||||
```bash
|
||||
# Test cross-node communication
|
||||
openclaw agent --agent main --message "Execute openclaw-agent-communicator to verify aitbc1 sync with genesis node" --thinking medium
|
||||
|
||||
# Check sync status
|
||||
ssh aitbc1 'curl -s http://localhost:8006/rpc/head | jq ".height"'
|
||||
```
|
||||
|
||||
## 💰 Phase 3: Wallet Operations
|
||||
|
||||
### Step 3.1: Cross-Node Wallet Creation
|
||||
**Skill**: `aitbc-wallet-manager`
|
||||
**Script**: `04_wallet_operations_openclaw.sh`
|
||||
|
||||
```bash
|
||||
# Create wallets on both nodes
|
||||
openclaw agent --agent main --message "Execute aitbc-wallet-manager to create cross-node wallets and establish wallet infrastructure" --thinking medium
|
||||
|
||||
# Run wallet operations
|
||||
/opt/aitbc/scripts/workflow-openclaw/04_wallet_operations_openclaw.sh
|
||||
```
|
||||
|
||||
### Step 3.2: Fund Wallets & Initial Transactions
|
||||
**Skill**: `aitbc-transaction-processor`
|
||||
|
||||
```bash
|
||||
# Fund wallets from genesis
|
||||
openclaw agent --agent main --message "Execute aitbc-transaction-processor to fund wallets and execute initial cross-node transactions" --thinking medium
|
||||
|
||||
# Verify transactions
|
||||
curl -s http://localhost:8006/rpc/balance/<wallet_address>
|
||||
```
|
||||
|
||||
## 🤖 Phase 4: AI Operations Setup
|
||||
|
||||
### Step 4.1: Coordinator API Testing
|
||||
**Skill**: `aitbc-ai-operator`
|
||||
|
||||
```bash
|
||||
# Test AI coordinator functionality
|
||||
openclaw agent --agent main --message "Execute aitbc-ai-operator to test coordinator API, job submission, and AI service integration" --thinking medium
|
||||
|
||||
# Test API endpoints
|
||||
curl -s http://localhost:8000/health
|
||||
curl -s http://localhost:8000/docs
|
||||
```
|
||||
|
||||
### Step 4.2: GPU Marketplace Setup
|
||||
**Skill**: `aitbc-marketplace-participant`
|
||||
|
||||
```bash
|
||||
# Initialize GPU marketplace
|
||||
openclaw agent --agent main --message "Execute aitbc-marketplace-participant to setup GPU marketplace, register providers, and prepare for AI jobs" --thinking medium
|
||||
|
||||
# Verify marketplace status
|
||||
curl -s http://localhost:8000/api/marketplace/stats
|
||||
```
|
||||
|
||||
## 🧪 Phase 5: Complete AI Workflow Testing
|
||||
|
||||
### Step 5.1: Ollama GPU Testing
|
||||
**Skill**: `ollama-gpu-testing-skill`
|
||||
**Script**: Reference `ollama-gpu-test-openclaw.md`
|
||||
|
||||
```bash
|
||||
# Execute complete Ollama GPU test
|
||||
openclaw agent --agent main --message "Execute ollama-gpu-testing-skill with complete end-to-end test: client submission → GPU processing → blockchain recording" --thinking high
|
||||
|
||||
# Monitor job progress
|
||||
curl -s http://localhost:8000/api/jobs
|
||||
```
|
||||
|
||||
### Step 5.2: Advanced AI Operations
|
||||
**Skill**: `aitbc-ai-operations-skill`
|
||||
**Script**: `06_advanced_ai_workflow_openclaw.sh`
|
||||
|
||||
```bash
|
||||
# Run advanced AI workflow
|
||||
openclaw agent --agent main --message "Execute aitbc-ai-operations-skill with advanced AI job processing, multi-modal RL, and agent coordination" --thinking high
|
||||
|
||||
# Execute advanced workflow script
|
||||
/opt/aitbc/scripts/workflow-openclaw/06_advanced_ai_workflow_openclaw.sh
|
||||
```
|
||||
|
||||
## 🔄 Phase 6: Agent Coordination Testing
|
||||
|
||||
### Step 6.1: Multi-Agent Coordination
|
||||
**Skill**: `openclaw-agent-communicator`
|
||||
**Script**: `07_enhanced_agent_coordination.sh`
|
||||
|
||||
```bash
|
||||
# Test agent coordination
|
||||
openclaw agent --agent main --message "Execute openclaw-agent-communicator to establish multi-agent coordination and cross-node agent messaging" --thinking high
|
||||
|
||||
# Run coordination script
|
||||
/opt/aitbc/scripts/workflow-openclaw/07_enhanced_agent_coordination.sh
|
||||
```
|
||||
|
||||
### Step 6.2: AI Economics Testing
|
||||
**Skill**: `aitbc-marketplace-participant`
|
||||
**Script**: `08_ai_economics_masters.sh`
|
||||
|
||||
```bash
|
||||
# Test AI economics and marketplace dynamics
|
||||
openclaw agent --agent main --message "Execute aitbc-marketplace-participant to test AI economics, pricing models, and marketplace dynamics" --thinking high
|
||||
|
||||
# Run economics test
|
||||
/opt/aitbc/scripts/workflow-openclaw/08_ai_economics_masters.sh
|
||||
```
|
||||
|
||||
## 📊 Phase 7: Complete Integration Test
|
||||
|
||||
### Step 7.1: End-to-End Workflow
|
||||
**Script**: `05_complete_workflow_openclaw.sh`
|
||||
|
||||
```bash
|
||||
# Execute complete workflow
|
||||
openclaw agent --agent main --message "Execute complete end-to-end AITBC workflow: genesis → nodes → wallets → AI operations → marketplace → economics" --thinking high
|
||||
|
||||
# Run complete workflow
|
||||
/opt/aitbc/scripts/workflow-openclaw/05_complete_workflow_openclaw.sh
|
||||
```
|
||||
|
||||
### Step 7.2: Performance & Stress Testing
|
||||
**Skill**: `openclaw-agent-testing-skill`
|
||||
|
||||
```bash
|
||||
# Stress test the system
|
||||
openclaw agent --agent main --message "Execute openclaw-agent-testing-skill with operation: comprehensive, test_duration: 300, concurrent_agents: 3" --thinking high
|
||||
```
|
||||
|
||||
## ✅ Verification Checklist
|
||||
|
||||
### After Each Phase:
|
||||
- [ ] Services running: `systemctl status aitbc-*`
|
||||
- [ ] Blockchain syncing: Check block heights
|
||||
- [ ] API responding: Health endpoints
|
||||
- [ ] Wallets funded: Balance checks
|
||||
- [ ] Agent communication: OpenClaw logs
|
||||
|
||||
### Final Verification:
|
||||
- [ ] Genesis block height > 0
|
||||
- [ ] Follower node synced
|
||||
- [ ] Cross-node transactions successful
|
||||
- [ ] AI jobs processing
|
||||
- [ ] Marketplace active
|
||||
- [ ] All agents communicating
|
||||
|
||||
## 🚨 Troubleshooting
|
||||
|
||||
### Common Issues:
|
||||
1. **OpenClaw not responding**: Check gateway status
|
||||
2. **Services not starting**: Check logs with `journalctl -u aitbc-*`
|
||||
3. **Sync issues**: Verify network connectivity between nodes
|
||||
4. **Wallet problems**: Check keystore permissions
|
||||
5. **AI jobs failing**: Verify GPU availability and Ollama status
|
||||
|
||||
### Recovery Commands:
|
||||
```bash
|
||||
# Reset OpenClaw session
|
||||
SESSION_ID="recovery-$(date +%s)"
|
||||
|
||||
# Restart all services
|
||||
systemctl restart aitbc-*
|
||||
|
||||
# Reset blockchain (if needed)
|
||||
rm -rf /var/lib/aitbc/data/ait-mainnet/*
|
||||
# Then re-run Phase 1
|
||||
```
|
||||
|
||||
## 📈 Success Metrics
|
||||
|
||||
### Expected Results:
|
||||
- Genesis block created and validated
|
||||
- 2+ nodes syncing properly
|
||||
- Cross-node transactions working
|
||||
- AI jobs submitting and completing
|
||||
- Marketplace active with providers
|
||||
- Agent coordination established
|
||||
- End-to-end workflow successful
|
||||
|
||||
### Performance Targets:
|
||||
- Block production: Every 10 seconds
|
||||
- Transaction confirmation: < 30 seconds
|
||||
- AI job completion: < 2 minutes
|
||||
- Agent response time: < 5 seconds
|
||||
- Cross-node sync: < 1 minute
|
||||
@@ -248,21 +248,21 @@ def create_app() -> FastAPI:
|
||||
]
|
||||
)
|
||||
|
||||
# API Key middleware (if configured)
|
||||
required_key = os.getenv("COORDINATOR_API_KEY")
|
||||
if required_key:
|
||||
@app.middleware("http")
|
||||
async def api_key_middleware(request: Request, call_next):
|
||||
# Health endpoints are exempt
|
||||
if request.url.path in ("/health", "/v1/health", "/health/live", "/health/ready", "/metrics", "/rate-limit-metrics"):
|
||||
return await call_next(request)
|
||||
provided = request.headers.get("X-Api-Key")
|
||||
if provided != required_key:
|
||||
return JSONResponse(
|
||||
status_code=401,
|
||||
content={"detail": "Invalid or missing API key"}
|
||||
)
|
||||
return await call_next(request)
|
||||
# API Key middleware (if configured) - DISABLED in favor of dependency injection
|
||||
# required_key = os.getenv("COORDINATOR_API_KEY")
|
||||
# if required_key:
|
||||
# @app.middleware("http")
|
||||
# async def api_key_middleware(request: Request, call_next):
|
||||
# # Health endpoints are exempt
|
||||
# if request.url.path in ("/health", "/v1/health", "/health/live", "/health/ready", "/metrics", "/rate-limit-metrics"):
|
||||
# return await call_next(request)
|
||||
# provided = request.headers.get("X-Api-Key")
|
||||
# if provided != required_key:
|
||||
# return JSONResponse(
|
||||
# status_code=401,
|
||||
# content={"detail": "Invalid or missing API key"}
|
||||
# )
|
||||
# return await call_next(request)
|
||||
|
||||
app.state.limiter = limiter
|
||||
app.add_exception_handler(RateLimitExceeded, _rate_limit_exceeded_handler)
|
||||
|
||||
@@ -29,6 +29,68 @@ async def debug_settings() -> dict: # type: ignore[arg-type]
|
||||
}
|
||||
|
||||
|
||||
@router.post("/debug/create-test-miner", summary="Create a test miner for debugging")
|
||||
async def create_test_miner(
|
||||
session: Annotated[Session, Depends(get_session)],
|
||||
admin_key: str = Depends(require_admin_key())
|
||||
) -> dict[str, str]: # type: ignore[arg-type]
|
||||
"""Create a test miner for debugging marketplace sync"""
|
||||
try:
|
||||
from ..domain import Miner
|
||||
from uuid import uuid4
|
||||
|
||||
miner_id = "debug-test-miner"
|
||||
session_token = uuid4().hex
|
||||
|
||||
# Check if miner already exists
|
||||
existing_miner = session.get(Miner, miner_id)
|
||||
if existing_miner:
|
||||
# Update existing miner to ONLINE
|
||||
existing_miner.status = "ONLINE"
|
||||
existing_miner.last_heartbeat = datetime.utcnow()
|
||||
existing_miner.session_token = session_token
|
||||
session.add(existing_miner)
|
||||
session.commit()
|
||||
return {"status": "updated", "miner_id": miner_id, "message": "Existing miner updated to ONLINE"}
|
||||
|
||||
# Create new test miner
|
||||
miner = Miner(
|
||||
id=miner_id,
|
||||
capabilities={
|
||||
"gpu_memory": 8192,
|
||||
"models": ["qwen3:8b"],
|
||||
"pricing_per_hour": 0.50,
|
||||
"gpu": "RTX 4090",
|
||||
"gpu_memory_gb": 8192,
|
||||
"gpu_count": 1,
|
||||
"cuda_version": "12.0",
|
||||
"supported_models": ["qwen3:8b"]
|
||||
},
|
||||
concurrency=1,
|
||||
region="test-region",
|
||||
session_token=session_token,
|
||||
status="ONLINE",
|
||||
inflight=0,
|
||||
last_heartbeat=datetime.utcnow()
|
||||
)
|
||||
|
||||
session.add(miner)
|
||||
session.commit()
|
||||
session.refresh(miner)
|
||||
|
||||
logger.info(f"Created test miner: {miner_id}")
|
||||
return {
|
||||
"status": "created",
|
||||
"miner_id": miner_id,
|
||||
"session_token": session_token,
|
||||
"message": "Test miner created successfully"
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to create test miner: {e}")
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
@router.get("/test-key", summary="Test API key validation")
|
||||
async def test_key(
|
||||
api_key: str = Header(default=None, alias="X-Api-Key")
|
||||
@@ -102,23 +164,26 @@ async def list_jobs(session: Annotated[Session, Depends(get_session)], admin_key
|
||||
|
||||
@router.get("/miners", summary="List miners")
|
||||
async def list_miners(session: Annotated[Session, Depends(get_session)], admin_key: str = Depends(require_admin_key())) -> dict[str, list[dict]]: # type: ignore[arg-type]
|
||||
miner_service = MinerService(session)
|
||||
miners = [
|
||||
from sqlmodel import select
|
||||
from ..domain import Miner
|
||||
|
||||
miners = session.execute(select(Miner)).scalars().all()
|
||||
miner_list = [
|
||||
{
|
||||
"miner_id": record.id,
|
||||
"status": record.status,
|
||||
"inflight": record.inflight,
|
||||
"concurrency": record.concurrency,
|
||||
"region": record.region,
|
||||
"last_heartbeat": record.last_heartbeat.isoformat(),
|
||||
"average_job_duration_ms": record.average_job_duration_ms,
|
||||
"jobs_completed": record.jobs_completed,
|
||||
"jobs_failed": record.jobs_failed,
|
||||
"last_receipt_id": record.last_receipt_id,
|
||||
"miner_id": miner.id,
|
||||
"status": miner.status,
|
||||
"inflight": miner.inflight,
|
||||
"concurrency": miner.concurrency,
|
||||
"region": miner.region,
|
||||
"last_heartbeat": miner.last_heartbeat.isoformat(),
|
||||
"average_job_duration_ms": miner.average_job_duration_ms,
|
||||
"jobs_completed": miner.jobs_completed,
|
||||
"jobs_failed": miner.jobs_failed,
|
||||
"last_receipt_id": miner.last_receipt_id,
|
||||
}
|
||||
for record in miner_service.list_records()
|
||||
for miner in miners
|
||||
]
|
||||
return {"items": miners}
|
||||
return {"items": miner_list}
|
||||
|
||||
|
||||
@router.get("/status", summary="Get system status", response_model=None)
|
||||
|
||||
@@ -24,9 +24,10 @@ async def sync_offers(
|
||||
"""Create marketplace offers from all registered miners"""
|
||||
|
||||
# Get all registered miners
|
||||
miners = session.execute(select(Miner).where(Miner.status == "ONLINE")).all()
|
||||
miners = session.execute(select(Miner).where(Miner.status == "ONLINE")).scalars().all()
|
||||
|
||||
created_offers = []
|
||||
offer_objects = []
|
||||
|
||||
for miner in miners:
|
||||
# Check if offer already exists
|
||||
@@ -54,10 +55,14 @@ async def sync_offers(
|
||||
)
|
||||
|
||||
session.add(offer)
|
||||
created_offers.append(offer.id)
|
||||
offer_objects.append(offer)
|
||||
|
||||
session.commit()
|
||||
|
||||
# Collect offer IDs after commit (when IDs are generated)
|
||||
for offer in offer_objects:
|
||||
created_offers.append(offer.id)
|
||||
|
||||
return {
|
||||
"status": "ok",
|
||||
"created_offers": len(created_offers),
|
||||
|
||||
@@ -55,7 +55,8 @@ async def heartbeat(
|
||||
async def poll(
|
||||
req: PollRequest,
|
||||
session: Annotated[Session, Depends(get_session)],
|
||||
miner_id: str = Depends(require_miner_key()),
|
||||
api_key: str = Depends(require_miner_key()),
|
||||
miner_id: str = Depends(get_miner_id()),
|
||||
) -> AssignedJob | Response: # type: ignore[arg-type]
|
||||
job = MinerService(session).poll(miner_id, req.max_wait_seconds)
|
||||
if job is None:
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
# AITBC Central Virtual Environment Requirements
|
||||
# This file contains all Python dependencies for AITBC services
|
||||
# Merged from all subdirectory requirements files
|
||||
#
|
||||
# Recent Updates:
|
||||
# - Added bech32>=1.2.0 for blockchain address encoding (2026-03-30)
|
||||
# - Fixed duplicate web3 entries and tenseal version
|
||||
# - All dependencies tested and working with current services
|
||||
|
||||
# Core Web Framework
|
||||
fastapi>=0.115.0
|
||||
@@ -35,6 +40,7 @@ cryptography>=46.0.0
|
||||
pynacl>=1.5.0
|
||||
ecdsa>=0.19.0
|
||||
base58>=2.1.1
|
||||
bech32>=1.2.0
|
||||
web3>=6.11.0
|
||||
eth-account>=0.13.0
|
||||
|
||||
@@ -88,5 +94,4 @@ opencv-python>=4.9.0
|
||||
# Additional Dependencies
|
||||
redis>=5.0.0
|
||||
psutil>=5.9.0
|
||||
tenseal
|
||||
web3>=6.11.0
|
||||
tenseal>=0.3.0
|
||||
|
||||
@@ -7,6 +7,7 @@ Type=simple
|
||||
User=root
|
||||
WorkingDirectory=/opt/aitbc/apps/coordinator-api/src
|
||||
Environment=PYTHONPATH=/opt/aitbc/apps/coordinator-api/src:/opt/aitbc/packages/py/aitbc-sdk/src:/opt/aitbc/packages/py/aitbc-crypto/src
|
||||
Environment=COORDINATOR_API_KEY=admin_prod_key_use_real_value
|
||||
ExecStart=/opt/aitbc/venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
Reference in New Issue
Block a user