| | import sys |
| | import os |
| | from pathlib import Path |
| |
|
| | |
| | project_root = Path(__file__).parent |
| | sys.path.append(str(project_root)) |
| |
|
| | from core.redis_client import redis_client |
| | from utils.config import config |
| |
|
| | def test_redis_connection(): |
| | """Test Redis connection with current configuration""" |
| | print("Testing Redis connection...") |
| | print(f"REDIS_HOST: {config.redis_host}") |
| | print(f"REDIS_PORT: {config.redis_port}") |
| | print(f"REDIS_USERNAME: {config.redis_username}") |
| | print(f"REDIS_DISABLE_SSL: {config.redis_disable_ssl}") |
| | |
| | |
| | client = redis_client.get_client() |
| | |
| | if client is None: |
| | print("β Redis client is None - connection failed") |
| | return False |
| | |
| | try: |
| | |
| | result = client.ping() |
| | print(f"β
Ping result: {result}") |
| | |
| | |
| | test_key = "redis_test_key" |
| | test_value = "redis_test_value" |
| | |
| | client.set(test_key, test_value) |
| | retrieved_value = client.get(test_key) |
| | |
| | if retrieved_value == test_value: |
| | print("β
Set/Get test successful") |
| | |
| | client.delete(test_key) |
| | else: |
| | print("β Set/Get test failed") |
| | |
| | return True |
| | except Exception as e: |
| | print(f"β Redis operation failed: {e}") |
| | return False |
| |
|
| | if __name__ == "__main__": |
| | success = test_redis_connection() |
| | if success: |
| | print("\nπ Redis connection test passed!") |
| | else: |
| | print("\nπ₯ Redis connection test failed!") |
| | sys.exit(1) |
| |
|