v1.0 - Version stable: multi-PC, détection UI-DETR-1, 3 modes exécution
- Frontend v4 accessible sur réseau local (192.168.1.40) - Ports ouverts: 3002 (frontend), 5001 (backend), 5004 (dashboard) - Ollama GPU fonctionnel - Self-healing interactif - Dashboard confiance Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
229
run_real_upload_functionality_tests.py
Executable file
229
run_real_upload_functionality_tests.py
Executable file
@@ -0,0 +1,229 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Real Functionality Test Suite for RPA Vision V3 Upload Pipeline
|
||||
|
||||
Runs comprehensive tests of the upload functionality using real data,
|
||||
real HTTP requests, and actual server processing pipeline.
|
||||
|
||||
Tests both authenticated and unauthenticated scenarios to validate
|
||||
complete server behavior.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import requests
|
||||
from pathlib import Path
|
||||
|
||||
def check_server_status():
|
||||
"""Check if server is running and what endpoints are available"""
|
||||
base_url = "http://127.0.0.1:8000"
|
||||
endpoints_to_check = [
|
||||
"/api/traces/status",
|
||||
"/api/traces/upload",
|
||||
"/api/traces/queue",
|
||||
"/api/traces/sessions"
|
||||
]
|
||||
|
||||
print("🔍 Checking server status...")
|
||||
|
||||
server_running = False
|
||||
available_endpoints = []
|
||||
|
||||
for endpoint in endpoints_to_check:
|
||||
try:
|
||||
response = requests.get(f"{base_url}{endpoint}", timeout=3)
|
||||
if response.status_code in [200, 401, 403, 405]: # Any response means endpoint exists
|
||||
available_endpoints.append(endpoint)
|
||||
server_running = True
|
||||
print(f" ✅ {endpoint} - Status {response.status_code}")
|
||||
else:
|
||||
print(f" ❌ {endpoint} - Status {response.status_code}")
|
||||
except requests.exceptions.ConnectionError:
|
||||
print(f" ❌ {endpoint} - Connection refused")
|
||||
except Exception as e:
|
||||
print(f" ⚠️ {endpoint} - Error: {e}")
|
||||
|
||||
return server_running, available_endpoints
|
||||
|
||||
def run_test_script(script_name, description):
|
||||
"""Run a test script and return success status"""
|
||||
print(f"\n{'='*60}")
|
||||
print(f"🧪 Running: {description}")
|
||||
print(f"Script: {script_name}")
|
||||
print('='*60)
|
||||
|
||||
try:
|
||||
# Run the test script
|
||||
result = subprocess.run([
|
||||
sys.executable, script_name
|
||||
], capture_output=False, text=True, timeout=120)
|
||||
|
||||
success = result.returncode == 0
|
||||
|
||||
if success:
|
||||
print(f"✅ {description} - PASSED")
|
||||
else:
|
||||
print(f"❌ {description} - FAILED (exit code: {result.returncode})")
|
||||
|
||||
return success
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
print(f"⏰ {description} - TIMEOUT (>120s)")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"💥 {description} - ERROR: {e}")
|
||||
return False
|
||||
|
||||
def check_test_files_exist():
|
||||
"""Verify all test files exist"""
|
||||
test_files = [
|
||||
"test_simple_upload_no_auth.py",
|
||||
"test_upload_with_auth_real.py"
|
||||
]
|
||||
|
||||
missing_files = []
|
||||
for file in test_files:
|
||||
if not Path(file).exists():
|
||||
missing_files.append(file)
|
||||
|
||||
if missing_files:
|
||||
print(f"❌ Missing test files: {missing_files}")
|
||||
return False
|
||||
|
||||
print("✅ All test files found")
|
||||
return True
|
||||
|
||||
def check_environment_setup():
|
||||
"""Check if environment is properly configured"""
|
||||
print("🔧 Checking environment setup...")
|
||||
|
||||
# Check for environment files
|
||||
env_files = [".env.local", ".env"]
|
||||
env_file_found = False
|
||||
|
||||
for env_file in env_files:
|
||||
if Path(env_file).exists():
|
||||
print(f" ✅ Found {env_file}")
|
||||
env_file_found = True
|
||||
break
|
||||
|
||||
if not env_file_found:
|
||||
print(" ⚠️ No .env files found (authentication tests may fail)")
|
||||
|
||||
# Check for server files
|
||||
server_files = [
|
||||
"server/api_upload.py",
|
||||
"server/processing_pipeline.py",
|
||||
"core/persistence/storage_manager.py"
|
||||
]
|
||||
|
||||
missing_server_files = []
|
||||
for file in server_files:
|
||||
if not Path(file).exists():
|
||||
missing_server_files.append(file)
|
||||
|
||||
if missing_server_files:
|
||||
print(f" ⚠️ Missing server files: {missing_server_files}")
|
||||
return False
|
||||
|
||||
print(" ✅ Server files found")
|
||||
return True
|
||||
|
||||
def main():
|
||||
"""Run the complete real functionality test suite"""
|
||||
print("🚀 RPA Vision V3 - Real Functionality Test Suite")
|
||||
print("Testing Upload Pipeline with Real Data and Server Integration")
|
||||
print("="*80)
|
||||
|
||||
# Pre-flight checks
|
||||
print("\n📋 Pre-flight Checks")
|
||||
print("-" * 40)
|
||||
|
||||
if not check_test_files_exist():
|
||||
print("❌ Cannot proceed without test files")
|
||||
return False
|
||||
|
||||
if not check_environment_setup():
|
||||
print("⚠️ Environment setup issues detected")
|
||||
|
||||
# Check server status
|
||||
server_running, available_endpoints = check_server_status()
|
||||
|
||||
if not server_running:
|
||||
print("\n❌ Server is not running!")
|
||||
print("\nTo start the server:")
|
||||
print(" ./run.sh --server")
|
||||
print(" # or")
|
||||
print(" python server/api_upload.py")
|
||||
print("\nThen run this test suite again.")
|
||||
return False
|
||||
|
||||
print(f"\n✅ Server is running with {len(available_endpoints)} endpoints available")
|
||||
|
||||
# Run the test suite
|
||||
print("\n🧪 Running Real Functionality Tests")
|
||||
print("-" * 40)
|
||||
|
||||
test_results = []
|
||||
|
||||
# Test 1: Upload without authentication (should be rejected for security)
|
||||
test_results.append(run_test_script(
|
||||
"test_simple_upload_no_auth.py",
|
||||
"Upload without Authentication (Security Test)"
|
||||
))
|
||||
|
||||
# Small delay between tests
|
||||
time.sleep(2)
|
||||
|
||||
# Test 2: Upload with authentication (should succeed if tokens are configured)
|
||||
test_results.append(run_test_script(
|
||||
"test_upload_with_auth_real.py",
|
||||
"Upload with Authentication (Functionality Test)"
|
||||
))
|
||||
|
||||
# Summary
|
||||
print("\n" + "="*80)
|
||||
print("📊 Test Suite Summary")
|
||||
print("="*80)
|
||||
|
||||
passed_tests = sum(test_results)
|
||||
total_tests = len(test_results)
|
||||
|
||||
print(f"Tests Passed: {passed_tests}/{total_tests}")
|
||||
|
||||
if passed_tests == total_tests:
|
||||
print("🎉 ALL TESTS PASSED!")
|
||||
print("The RPA Vision V3 upload pipeline is working correctly.")
|
||||
success = True
|
||||
else:
|
||||
print("❌ SOME TESTS FAILED!")
|
||||
print("Check the individual test outputs above for details.")
|
||||
success = False
|
||||
|
||||
print("\n📝 Test Details:")
|
||||
test_names = [
|
||||
"Upload without Authentication (Security)",
|
||||
"Upload with Authentication (Functionality)"
|
||||
]
|
||||
|
||||
for i, (name, result) in enumerate(zip(test_names, test_results)):
|
||||
status = "✅ PASS" if result else "❌ FAIL"
|
||||
print(f" {i+1}. {name}: {status}")
|
||||
|
||||
print("\n💡 Next Steps:")
|
||||
if success:
|
||||
print(" - Upload pipeline is working correctly")
|
||||
print(" - You can now test with real agent_v0 uploads")
|
||||
print(" - Check server logs for processing details")
|
||||
else:
|
||||
print(" - Review failed test outputs above")
|
||||
print(" - Check server configuration and authentication")
|
||||
print(" - Verify environment variables are set correctly")
|
||||
print(" - Check server logs for errors")
|
||||
|
||||
return success
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = main()
|
||||
exit(0 if success else 1)
|
||||
Reference in New Issue
Block a user