Skip to content

Commit 7619a69

Browse files
committed
flush fix, sync fix in e2e test
Signed-off-by: Sai Shree Pradhan <saishree.pradhan@databricks.com>
1 parent fe8cd57 commit 7619a69

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/databricks/sql/telemetry/telemetry_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def export_latency_log(self, latency_ms, sql_execution_event, sql_statement_id):
127127
def close(self):
128128
pass
129129

130+
def _flush(self):
131+
pass
132+
130133

131134
class TelemetryClient(BaseTelemetryClient):
132135
"""

tests/e2e/test_concurrent_telemetry.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def telemetry_setup_teardown(self):
3535
if TelemetryClientFactory._executor:
3636
TelemetryClientFactory._executor.shutdown(wait=True)
3737
TelemetryClientFactory._executor = None
38+
TelemetryClientFactory._stop_flush_thread()
3839
TelemetryClientFactory._initialized = False
3940

4041
def test_concurrent_queries_sends_telemetry(self):
@@ -101,8 +102,15 @@ def execute_query_worker(thread_id):
101102
# Run the workers concurrently
102103
run_in_threads(execute_query_worker, num_threads, pass_index=True)
103104

104-
if TelemetryClientFactory._executor:
105-
TelemetryClientFactory._executor.shutdown(wait=True)
105+
timeout_seconds = 60 # Max time to wait for telemetry to arrive
106+
start_time = time.time()
107+
expected_event_count = num_threads * 2 # initial_log + latency_log per thread
108+
109+
# Poll until the expected number of events are captured or we time out
110+
while len(captured_telemetry) < expected_event_count:
111+
if time.time() - start_time > timeout_seconds:
112+
break # Exit loop if timeout is reached
113+
time.sleep(0.1)
106114

107115
# --- VERIFICATION ---
108116
assert not captured_exceptions

0 commit comments

Comments
 (0)