image_management_api/test_qdrant_connection.py
2025-05-24 18:33:51 +02:00

44 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""
Simple test script to verify Qdrant connection
Auto-generated by deployment/scripts/setup_local_env.sh
"""
import os
import sys
from src.services.vector_db import VectorDatabaseService
def test_qdrant_connection():
"""Test the connection to Qdrant"""
# Set environment variables from deployed infrastructure
os.environ['QDRANT_HOST'] = '34.171.134.17'
os.environ['QDRANT_PORT'] = '6333'
try:
print("Testing Qdrant connection...")
print(f"Host: {os.environ['QDRANT_HOST']}")
print(f"Port: {os.environ['QDRANT_PORT']}")
# Initialize the service
vector_db = VectorDatabaseService()
# Test health check
is_healthy = vector_db.health_check()
print(f"Health check: {'✓ PASSED' if is_healthy else '✗ FAILED'}")
# Get collection info
collection_info = vector_db.get_collection_info()
print(f"Collection info: {collection_info}")
print("\n✓ Qdrant connection test PASSED!")
return True
except Exception as e:
print(f"\n✗ Qdrant connection test FAILED: {e}")
return False
if __name__ == "__main__":
success = test_qdrant_connection()
sys.exit(0 if success else 1)