Skip to content

Commit 70fd810

Browse files
committed
used batch size instead of default batch size
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent 5a84e11 commit 70fd810

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

tests/unit/test_telemetry.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,15 @@ def test_export_event(self, telemetry_client_setup):
188188
client = telemetry_client_setup["client"]
189189
client._flush = MagicMock()
190190

191-
for i in range(TelemetryClient.DEFAULT_BATCH_SIZE-1):
191+
batch_size = client._batch_size
192+
193+
for i in range(batch_size - 1):
192194
client._export_event(f"event-{i}")
193195

194196
client._flush.assert_not_called()
195-
assert len(client._events_batch) == TelemetryClient.DEFAULT_BATCH_SIZE - 1
196-
197-
# Add one more event to reach batch size (this will trigger flush)
198-
client._export_event(f"event-{TelemetryClient.DEFAULT_BATCH_SIZE - 1}")
197+
assert len(client._events_batch) == batch_size - 1
198+
199+
client._export_event(f"event-{batch_size - 1}")
199200

200201
client._flush.assert_called_once()
201202

@@ -658,11 +659,9 @@ def test_telemetry_client_concurrent_flush_operations(self, race_condition_setup
658659
executor=executor,
659660
)
660661

661-
# Mock _send_telemetry to avoid actual network calls
662662
client._send_telemetry = MagicMock()
663663

664-
# Add events to trigger flush
665-
for i in range(TelemetryClient.DEFAULT_BATCH_SIZE - 1):
664+
for i in range(client._batch_size - 1):
666665
client._export_event(f"event-{i}")
667666

668667
# Track flush operations
@@ -690,13 +689,13 @@ def concurrent_flush():
690689
# Verify flush was called the expected number of times
691690
assert flush_count == 10
692691

693-
# Verify _send_telemetry was called at least once (some calls may have empty batches due to lock)
694-
assert client._send_telemetry.call_count >= 1
692+
# Verify _send_telemetry was called once
693+
assert client._send_telemetry.call_count == 1
695694

696695
# Verify that the total events processed is correct (no data loss)
697696
# The first flush should have processed all events, subsequent flushes should have empty batches
698697
total_events_sent = sum(len(call.args[0]) for call in client._send_telemetry.call_args_list)
699-
assert total_events_sent == TelemetryClient.DEFAULT_BATCH_SIZE - 1
698+
assert total_events_sent == client._batch_size - 1
700699

701700
def test_telemetry_client_factory_concurrent_initialization(self, race_condition_setup):
702701
"""Test race conditions in TelemetryClientFactory.initialize_telemetry_client with concurrent access."""

0 commit comments

Comments
 (0)