Update MongoDB connection handling in DataManager and enhance IngestorManager configuration

- Updated DataManager to simplify MongoDB connection logic by removing retry loop and adding logging for connection attempts.
- Enhanced IngestorManager to accept MongoDB connection parameters and export_to_kafka flag as part of its initialization.
- Updated requirements.txt to use the latest version of the sientia-dataops-library.
This commit is contained in:
vitor-aignosi
2025-07-03 15:35:38 -03:00
parent 28866ac9c8
commit 750d947d7e
6 changed files with 125 additions and 39 deletions

View File

@@ -11,6 +11,7 @@ from ingestor.ingestor import Ingestor
def test___init__(notification_handler, init_logger, getenv):
getenv.side_effect = [
"localhost:9092,localhost:35", # KAFKA_SERVERS
"true", # EXPORT_TO_KAFKA
"localhost1", # REDIS_HOST
'63790', # REDIS_PORT
"user", # REDIS_USERNAME
@@ -18,7 +19,11 @@ def test___init__(notification_handler, init_logger, getenv):
'100', # LEASE_TTL
'200', # HEARTBEAT_TTL
"localhost1", # HOSTNAME
'50' # POLL_INTERVAL
'50', # POLL_INTERVAL
"mongodb://localhost:27017", # MONGODB_URL
"sientia", # MONGODB_USERNAME
"sientia", # MONGODB_PASSWORD
"sientia" # MONGODB_DATABASE
]
ingestor = Ingestor()
@@ -114,16 +119,21 @@ def test_prepare_ingestor(ingestor_manager_mock, ingestor):
ingestor_manager_mock.assert_called_once_with(
ingestor.kafka_servers,
ingestor.redis_host,
ingestor.redis_port,
{
"host": ingestor.redis_host,
"port": ingestor.redis_port,
"username": ingestor.redis_username,
"password": ingestor.redis_password
},
ingestor.lease_ttl,
ingestor.heartbeat_ttl,
ingestor.pod_id,
ingestor.poll_interval,
ingestor.mongo_connection_string,
ingestor.mongo_database,
ingestor.logger,
ingestor.notification_handler,
ingestor.redis_username,
ingestor.redis_password
ingestor.export_to_kafka
)
ingestor_manager.declare_active.assert_called_once()
ingestor_manager.get_slot_leases.assert_called_once()