|
|
ο»Ώ""" |
|
|
π§ͺ ENTERPRISE PLATFORM - QUICK TEST |
|
|
Quick test to verify everything works. |
|
|
""" |
|
|
import requests |
|
|
import time |
|
|
import sys |
|
|
|
|
|
def test_platform(): |
|
|
"""Test the enterprise platform""" |
|
|
print("\n" + "="*80) |
|
|
print("π§ͺ ENTERPRISE PLATFORM QUICK TEST") |
|
|
print("="*80) |
|
|
|
|
|
base_url = "http://localhost:8000" |
|
|
|
|
|
print(f"\nTesting platform at: {base_url}") |
|
|
print("Make sure platform is running first!") |
|
|
print("Run: python enterprise_platform.py") |
|
|
print() |
|
|
|
|
|
try: |
|
|
|
|
|
print("1. Testing root endpoint...") |
|
|
response = requests.get(base_url, timeout=3) |
|
|
if response.status_code == 200: |
|
|
data = response.json() |
|
|
print(f" β
Service: {data.get('service')}") |
|
|
print(f" β
Version: {data.get('version')}") |
|
|
print(f" β
Status: {data.get('status')}") |
|
|
else: |
|
|
print(f" β Failed: HTTP {response.status_code}") |
|
|
return False |
|
|
|
|
|
|
|
|
print("\n2. Testing health endpoint...") |
|
|
response = requests.get(f"{base_url}/health", timeout=3) |
|
|
if response.status_code == 200: |
|
|
data = response.json() |
|
|
print(f" β
Status: {data.get('status')}") |
|
|
print(f" β
PyTorch: {data.get('components', {}).get('pytorch')}") |
|
|
else: |
|
|
print(f" β Failed: HTTP {response.status_code}") |
|
|
return False |
|
|
|
|
|
|
|
|
print("\n3. Testing prediction endpoint...") |
|
|
test_data = { |
|
|
"data": { |
|
|
"input": [0.0] * 784 |
|
|
} |
|
|
} |
|
|
|
|
|
response = requests.post( |
|
|
f"{base_url}/predict", |
|
|
json=test_data, |
|
|
timeout=5 |
|
|
) |
|
|
|
|
|
if response.status_code == 200: |
|
|
data = response.json() |
|
|
print(f" β
Prediction made") |
|
|
print(f" β
Status: {data.get('status')}") |
|
|
print(f" β
Prediction: {data.get('prediction')}") |
|
|
print(f" β
Confidence: {data.get('confidence', 0):.2%}") |
|
|
else: |
|
|
print(f" β οΈ Prediction returned: HTTP {response.status_code}") |
|
|
if response.text: |
|
|
print(f" Response: {response.text[:100]}...") |
|
|
|
|
|
print("\n" + "="*80) |
|
|
print("π ALL TESTS PASSED!") |
|
|
print("\nπ Access your platform at:") |
|
|
print(f" Main: {base_url}") |
|
|
print(f" Docs: {base_url}/docs") |
|
|
print(f" Health: {base_url}/health") |
|
|
|
|
|
return True |
|
|
|
|
|
except requests.exceptions.ConnectionError: |
|
|
print("\nβ Cannot connect to server!") |
|
|
print(" Make sure the platform is running:") |
|
|
print(" python enterprise_platform.py") |
|
|
return False |
|
|
except Exception as e: |
|
|
print(f"\nβ Test failed: {e}") |
|
|
return False |
|
|
|
|
|
if __name__ == "__main__": |
|
|
print("\nEnterprise Adversarial ML Security Platform - Quick Test") |
|
|
print("Version: 4.0.0") |
|
|
|
|
|
try: |
|
|
success = test_platform() |
|
|
sys.exit(0 if success else 1) |
|
|
except KeyboardInterrupt: |
|
|
print("\n\nTest cancelled.") |
|
|
sys.exit(1) |
|
|
|