69 lines
2.4 KiB
Python
69 lines
2.4 KiB
Python
"""
|
|
Test script pentru verificarea conexiunii Oracle pool
|
|
"""
|
|
import asyncio
|
|
import sys
|
|
import os
|
|
from datetime import datetime
|
|
|
|
# Load environment variables
|
|
try:
|
|
from dotenv import load_dotenv
|
|
# Load .env from roa2web root directory
|
|
env_path = os.path.join(os.path.dirname(__file__), '../../.env')
|
|
load_dotenv(env_path)
|
|
print(f"📄 Loaded environment from: {env_path}")
|
|
except ImportError:
|
|
print("⚠️ python-dotenv not available, using system environment variables")
|
|
|
|
# Adăugare path pentru shared modules
|
|
sys.path.append(os.path.dirname(__file__))
|
|
|
|
from oracle_pool import oracle_pool
|
|
|
|
async def test_oracle_pool():
|
|
"""Test simplu pentru verificarea pool-ului Oracle"""
|
|
print("🔄 Testing Oracle connection pool...")
|
|
|
|
try:
|
|
# Inițializare pool
|
|
print("📊 Initializing Oracle pool...")
|
|
await oracle_pool.initialize()
|
|
print("✅ Pool initialized successfully")
|
|
|
|
# Test conexiune
|
|
print("🔍 Testing database connection...")
|
|
async with oracle_pool.get_connection() as conn:
|
|
with conn.cursor() as cursor:
|
|
cursor.execute("SELECT 1 FROM DUAL")
|
|
result = cursor.fetchone()
|
|
print(f"✅ Database connection test successful: {result}")
|
|
|
|
print("🎯 Testing connection pool info...")
|
|
if oracle_pool._pool:
|
|
print(f"📈 Pool connections opened: {oracle_pool._pool.opened}")
|
|
print(f"📊 Pool connections busy: {oracle_pool._pool.busy}")
|
|
|
|
# Cleanup
|
|
print("🧹 Closing pool...")
|
|
await oracle_pool.close_pool()
|
|
print("✅ Pool closed successfully")
|
|
|
|
print("\n🎉 All tests passed! Oracle pool is working correctly.")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error testing Oracle pool: {str(e)}")
|
|
print(f"💡 Make sure environment variables are set:")
|
|
print(f" - ORACLE_USER: {'✅ SET' if os.getenv('ORACLE_USER') else '❌ NOT SET'}")
|
|
print(f" - ORACLE_PASSWORD: {'✅ SET' if os.getenv('ORACLE_PASSWORD') else '❌ NOT SET'}")
|
|
print(f" - ORACLE_DSN: {'✅ SET' if os.getenv('ORACLE_DSN') else '❌ NOT SET'}")
|
|
return False
|
|
|
|
return True
|
|
|
|
if __name__ == "__main__":
|
|
print(f"🚀 ROA2WEB Oracle Pool Test - {datetime.now()}")
|
|
print("=" * 50)
|
|
|
|
success = asyncio.run(test_oracle_pool())
|
|
sys.exit(0 if success else 1) |