Skip to content

Commit e104eb9

Browse files
create dedicated client for temp table test
1 parent 29dfd78 commit e104eb9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/integration_tests/test_client.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import pytest
66

77
from clickhouse_connect import create_client
8-
from clickhouse_connect import datatypes
8+
from clickhouse_connect import datatypes, common
99
from clickhouse_connect.driver.client import Client
1010
from clickhouse_connect.driver.exceptions import DatabaseError
1111
from tests.integration_tests.conftest import TestConfig
@@ -215,7 +215,13 @@ def test_empty_result(test_client: Client):
215215
assert len(test_client.query("SELECT * FROM system.tables WHERE name = '_NOT_A THING'").result_rows) == 0
216216

217217

218-
def test_temporary_tables(test_client: Client):
218+
def test_temporary_tables(test_create_client: Callable):
219+
# Create a dedicated client for this test to ensure connection isolation
220+
# which hopefully helps prevent problems in cloud env.
221+
old_max_age = common.get_setting('max_connection_age')
222+
common.set_setting('max_connection_age', 0)
223+
test_client = test_create_client()
224+
219225
session_id = test_client.get_client_setting("session_id")
220226
session_settings = {"session_id": session_id}
221227
test_client.command("""
@@ -236,6 +242,9 @@ def test_temporary_tables(test_client: Client):
236242
assert len(df['field1']) == 4
237243
test_client.command('DROP TABLE IF EXISTS temp_test_table', settings=session_settings)
238244

245+
test_client.close()
246+
common.set_setting('max_connection_age', old_max_age)
247+
239248

240249
def test_str_as_bytes(test_client: Client, table_context: Callable):
241250
with table_context('test_insert_bytes', ['key UInt32', 'byte_str String', 'n_byte_str Nullable(String)']):

0 commit comments

Comments
 (0)