Spaces:
No application file
No application file
File size: 5,292 Bytes
ead5455 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | #!/usr/bin/env python3
"""Validate that the MVP system is working correctly"""
import requests
import time
import json
import sys
MCP_URL = "http://localhost:8000/mcp"
API_KEY = "dev-key-123"
def call_mcp(tool, params=None):
response = requests.post(
MCP_URL,
headers={"X-API-Key": API_KEY, "Content-Type": "application/json"},
json={"tool": tool, "params": params or {}}
)
return response.json()
def validate_step(step_name, validation_func):
"""Run a validation step and report results"""
print(f"Validating: {step_name}...", end=" ")
try:
result = validation_func()
if result:
print("✅ PASSED")
return True
else:
print("❌ FAILED")
return False
except Exception as e:
print(f"❌ ERROR: {e}")
return False
def check_neo4j():
"""Check Neo4j is accessible via MCP"""
result = call_mcp("get_schema")
return "labels" in result
def check_postgres():
"""Check PostgreSQL has sample data"""
result = call_mcp("query_postgres", {"query": "SELECT COUNT(*) as count FROM customers"})
return result.get("data", [{}])[0].get("count", 0) > 0
def check_schema_discovery():
"""Check schema can be discovered"""
result = call_mcp("discover_postgres_schema")
schema = result.get("schema", {})
return "customers" in schema and "orders" in schema
def create_test_workflow():
"""Create a test workflow"""
# Create workflow
workflow = call_mcp("write_graph", {
"action": "create_node",
"label": "Workflow",
"properties": {
"id": "validation-workflow",
"name": "Validation Test",
"status": "active"
}
})
# Create test instruction
instruction = call_mcp("write_graph", {
"action": "create_node",
"label": "Instruction",
"properties": {
"id": "validation-inst-1",
"type": "generate_sql",
"sequence": 1,
"status": "pending",
"pause_duration": 5, # Short pause for testing
"parameters": json.dumps({"question": "Count all customers"})
}
})
# Link instruction to workflow
call_mcp("query_graph", {
"query": """
MATCH (w:Workflow {id: 'validation-workflow'}),
(i:Instruction {id: 'validation-inst-1'})
CREATE (w)-[:HAS_INSTRUCTION]->(i)
"""
})
return workflow.get("created") is not None
def check_instruction_execution():
"""Check if instruction gets executed"""
# Wait for agent to pick it up (max 60 seconds)
for _ in range(12):
result = call_mcp("query_graph", {
"query": """
MATCH (i:Instruction {id: 'validation-inst-1'})
RETURN i.status as status
"""
})
status = result["data"][0]["status"] if result.get("data") else "unknown"
if status in ["executing", "complete"]:
return True
time.sleep(5)
return False
def check_execution_logged():
"""Check if execution was logged"""
result = call_mcp("query_graph", {
"query": """
MATCH (i:Instruction {id: 'validation-inst-1'})-[:EXECUTED_AS]->(e:Execution)
RETURN e
"""
})
return len(result.get("data", [])) > 0
def check_frontend():
"""Check if frontend is accessible"""
try:
response = requests.get("http://localhost:3000")
return response.status_code == 200
except:
return False
def main():
print("=" * 50)
print("MVP SYSTEM VALIDATION")
print("=" * 50)
print()
# Track results
all_passed = True
# Core services
all_passed &= validate_step("Neo4j accessible via MCP", check_neo4j)
all_passed &= validate_step("PostgreSQL has sample data", check_postgres)
all_passed &= validate_step("Frontend is accessible", check_frontend)
# Functionality
all_passed &= validate_step("Schema discovery works", check_schema_discovery)
all_passed &= validate_step("Workflow creation works", create_test_workflow)
print()
print("Waiting for agent to process instruction...")
all_passed &= validate_step("Instruction gets executed", check_instruction_execution)
all_passed &= validate_step("Execution is logged", check_execution_logged)
# Final verification
print()
print("=" * 50)
if all_passed:
print("✅ ALL VALIDATIONS PASSED!")
print("The MVP system is working correctly.")
# Show sample query result
result = call_mcp("query_graph", {
"query": """
MATCH (n)
RETURN labels(n)[0] as label, count(n) as count
ORDER BY count DESC
"""
})
print()
print("Graph Statistics:")
for item in result.get("data", []):
print(f" - {item['label']}: {item['count']} nodes")
else:
print("❌ SOME VALIDATIONS FAILED")
print("Please check the logs and fix issues.")
sys.exit(1)
print("=" * 50)
if __name__ == "__main__":
main()
|