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:
@@ -10,12 +10,17 @@ from ingestor.managers.ingestor_manager import IngestorManager
|
||||
def ingestor_manager(data_manager_mock, resource_manager_mock):
|
||||
return IngestorManager(
|
||||
kafka_servers="localhost:9092",
|
||||
redis_host="localhost",
|
||||
redis_port=6379,
|
||||
redis_data={
|
||||
"host": "localhost",
|
||||
"port": 6379
|
||||
},
|
||||
lease_ttl=60,
|
||||
heartbeat_ttl=60,
|
||||
pod_id="test_pod",
|
||||
poll_interval=5,
|
||||
mongo_connection_string="mongodb://localhost:27017",
|
||||
mongo_database="sientia",
|
||||
export_to_kafka=False,
|
||||
logger=MagicMock(),
|
||||
notification_handler=MagicMock()
|
||||
)
|
||||
@@ -29,19 +34,25 @@ def test___init__(notification_handler_mock, resource_manager_mock, data_manager
|
||||
|
||||
ingestor = IngestorManager(
|
||||
kafka_servers="localhost:9092",
|
||||
redis_host="localhost",
|
||||
redis_port=6379,
|
||||
redis_data={
|
||||
"host": "localhost",
|
||||
"port": 6379
|
||||
},
|
||||
lease_ttl=60,
|
||||
heartbeat_ttl=60,
|
||||
pod_id="test_pod",
|
||||
poll_interval=5,
|
||||
mongo_connection_string="mongodb://localhost:27017",
|
||||
mongo_database="sientia",
|
||||
export_to_kafka=False,
|
||||
logger=MagicMock(),
|
||||
notification_handler=MagicMock()
|
||||
)
|
||||
|
||||
opc_manager_mock.assert_not_called()
|
||||
data_manager_mock.assert_called_once_with(
|
||||
"localhost:9092", ingestor.logger, ingestor.notification_handler)
|
||||
"localhost:9092", "mongodb://localhost:27017", "sientia", False,
|
||||
ingestor.logger, ingestor.notification_handler)
|
||||
resource_manager_mock.assert_called_once_with(
|
||||
"localhost", 6379, 60, 60, "test_pod", None, None)
|
||||
assert ingestor.poll_interval == 5
|
||||
@@ -176,8 +187,10 @@ def test_update_opc_servers(metrics, opc_manager, ingestor_manager):
|
||||
|
||||
assert ingestor_manager.opc_managers['server2'] != mock
|
||||
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.assert_called_once_with(pod_id=ingestor_manager.pod_id)
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.return_value.set.assert_called_once_with(len(ingestor_manager.opc_managers))
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.assert_called_once_with(
|
||||
pod_id=ingestor_manager.pod_id)
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.return_value.set.assert_called_once_with(
|
||||
len(ingestor_manager.opc_managers))
|
||||
|
||||
|
||||
def test_declare_active(ingestor_manager):
|
||||
@@ -359,7 +372,8 @@ def test_drop_slot_leases(metrics, ingestor_manager):
|
||||
ingestor_manager.resource_manager.drop_tag_lease.assert_any_call("1")
|
||||
ingestor_manager.resource_manager.drop_tag_lease.assert_any_call("2")
|
||||
|
||||
metrics.SLOTS_RELEASED.labels.assert_any_call(pod_id=ingestor_manager.pod_id)
|
||||
metrics.SLOTS_RELEASED.labels.assert_any_call(
|
||||
pod_id=ingestor_manager.pod_id)
|
||||
metrics.SLOTS_RELEASED.labels.return_value.inc.assert_any_call()
|
||||
|
||||
|
||||
@@ -540,8 +554,10 @@ def test_check_opc_servers_integrity_all_healthy(metrics, ingestor_manager):
|
||||
# Verify that no reinitialization was needed
|
||||
ingestor_manager.initialize_opc_from_config.assert_not_called()
|
||||
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.assert_called_once_with(pod_id=ingestor_manager.pod_id)
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.return_value.set.assert_called_once_with(len(ingestor_manager.opc_managers))
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.assert_called_once_with(
|
||||
pod_id=ingestor_manager.pod_id)
|
||||
metrics.OPC_MANAGERS_ACTIVE.labels.return_value.set.assert_called_once_with(
|
||||
len(ingestor_manager.opc_managers))
|
||||
|
||||
|
||||
def test_check_opc_servers_integrity_server_lost(ingestor_manager):
|
||||
|
||||
Reference in New Issue
Block a user