File size: 3,832 Bytes
a7ae6b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""
Test script to verify all DataOps database connections for Elizabeth
"""

import os
import sys
import redis
import chromadb
import psycopg2
import pymongo
import qdrant_client
from datetime import datetime

def test_redis():
    """Test Redis connection"""
    try:
        client = redis.Redis(host='localhost', port=6379, decode_responses=True)
        client.ping()
        print("βœ… Redis: Connected successfully")
        return True
    except Exception as e:
        print(f"❌ Redis: Connection failed - {e}")
        return False

def test_postgresql():
    """Test PostgreSQL connection"""
    try:
        conn = psycopg2.connect(
            host="localhost",
            database="novadb",
            user="postgres",
            password="nova_db_pass"
        )
        cursor = conn.cursor()
        cursor.execute("SELECT version();")
        version = cursor.fetchone()
        print(f"βœ… PostgreSQL: Connected successfully - {version[0]}")
        conn.close()
        return True
    except Exception as e:
        print(f"❌ PostgreSQL: Connection failed - {e}")
        return False

def test_mongodb():
    """Test MongoDB connection"""
    try:
        client = pymongo.MongoClient("mongodb://localhost:27017/")
        db = client["nova_documents"]
        # Test connection by listing collections
        collections = db.list_collection_names()
        print(f"βœ… MongoDB: Connected successfully - Collections: {len(collections)}")
        return True
    except Exception as e:
        print(f"❌ MongoDB: Connection failed - {e}")
        return False

def test_chromadb():
    """Test ChromaDB connection"""
    try:
        client = chromadb.PersistentClient(path="/data/chromadb")
        collections = client.list_collections()
        print(f"βœ… ChromaDB: Connected successfully - Collections: {len(collections)}")
        return True
    except Exception as e:
        print(f"❌ ChromaDB: Connection failed - {e}")
        return False

def test_qdrant():
    """Test Qdrant connection"""
    try:
        client = qdrant_client.QdrantClient(
            host="localhost", 
            port=17000,
            prefer_grpc=False
        )
        collections = client.get_collections()
        print(f"βœ… Qdrant: Connected successfully - Collections: {len(collections.collections)}")
        return True
    except Exception as e:
        print(f"❌ Qdrant: Connection failed - {e}")
        return False

def test_dragonfly():
    """Test DragonFly connection"""
    try:
        client = redis.Redis(host='localhost', port=18000, decode_responses=True)
        client.ping()
        print("βœ… DragonFly: Connected successfully")
        return True
    except Exception as e:
        print(f"❌ DragonFly: Connection failed - {e}")
        return False

def main():
    """Main test function"""
    print("πŸ” Testing Elizabeth DataOps Database Connections")
    print("=" * 60)
    
    results = {}
    
    # Test all databases
    results["redis"] = test_redis()
    results["postgresql"] = test_postgresql()
    results["mongodb"] = test_mongodb()
    results["chromadb"] = test_chromadb()
    results["qdrant"] = test_qdrant()
    results["dragonfly"] = test_dragonfly()
    
    print("=" * 60)
    
    # Summary
    successful = sum(results.values())
    total = len(results)
    
    print(f"πŸ“Š Connection Summary: {successful}/{total} successful")
    
    if successful == total:
        print("πŸŽ‰ All DataOps databases connected successfully!")
        print("Elizabeth can now utilize the complete infrastructure.")
    else:
        print("⚠️  Some connections failed. Elizabeth will use available databases.")
    
    return all(results.values())

if __name__ == "__main__":
    success = main()
    sys.exit(0 if success else 1)