File size: 1,752 Bytes
b283a26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import sys
import os
from pathlib import Path

# Add project root to path
project_root = Path(__file__).parent
sys.path.append(str(project_root))

from core.redis_client import redis_client

def main():
    """Verify Redis connection with exact configuration"""
    print("Verifying Redis connection with exact configuration...")
    
    # Test the basic connection method
    success = redis_client.test_basic_connection()
    
    if success:
        print("\n✅ Redis connection verified successfully!")
        print("The exact configuration from Redis Cloud works correctly.")
    else:
        print("\n❌ Redis connection verification failed!")
        print("Please check your configuration and network connectivity.")
        return 1
        
    # Also test the actual client being used
    print("\nTesting application Redis client...")
    client = redis_client.get_client()
    
    if client is None:
        print("❌ Application Redis client is None")
        return 1
        
    try:
        client.ping()
        print("✅ Application Redis client ping successful")
        
        # Test set/get operations
        client.set('app_test_key', 'app_test_value')
        value = client.get('app_test_key')
        client.delete('app_test_key')  # Cleanup
        
        if value == 'app_test_value':
            print("✅ Set/Get operations work correctly")
            print("\n🎉 All Redis connection tests passed!")
            return 0
        else:
            print("❌ Set/Get operations failed")
            return 1
            
    except Exception as e:
        print(f"❌ Application Redis client test failed: {e}")
        return 1

if __name__ == "__main__":
    exit_code = main()
    sys.exit(exit_code)