Skip to content

Commit a2b0adf

Browse files
genzgdjovezhong
authored andcommitted
Docker test fixes (ClickHouse#473)
* Don't prevent settings that don't change the value * Add docker related config file * Fix typo
1 parent c89705f commit a2b0adf

File tree

8 files changed

+36
-33
lines changed

8 files changed

+36
-33
lines changed

.docker/clickhouse/single_node/config.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
<?xml version="1.0"?>
22
<clickhouse>
33

4-
<http_port>8123</http_port>
5-
<tcp_port>9000</tcp_port>
6-
7-
<users_config>users.xml</users_config>
84
<default_profile>default</default_profile>
95
<default_database>default</default_database>
10-
116
<mark_cache_size>5368709120</mark_cache_size>
127

138
<path>/var/lib/clickhouse/</path>
149
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
1510
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
1611
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
1712
<keep_alive_timeout>3</keep_alive_timeout>
13+
<format_schema_path>/var/lib/clickhouse/format_schemas/</format_schema_path>
1814

1915
<logger>
2016
<level>warning</level>
@@ -37,5 +33,11 @@
3733
<table>session_log</table>
3834
</session_log>
3935

36+
<user_directories>
37+
<users_xml>
38+
<path>users.xml</path>
39+
</users_xml>
40+
</user_directories>
41+
4042
<custom_settings_prefixes>SQL_</custom_settings_prefixes>
4143
</clickhouse>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<clickhouse>
2+
<listen_host>0.0.0.0</listen_host>
3+
<http_port>8123</http_port>
4+
<tcp_port>9000</tcp_port>
5+
</clickhouse>

.docker/clickhouse/single_node_tls/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM clickhouse/clickhouse-server:24.8-alpine
1+
FROM clickhouse/clickhouse-server:25.1-alpine
22
COPY .docker/clickhouse/single_node_tls/certificates /etc/clickhouse-server/certs
33
RUN chown clickhouse:clickhouse -R /etc/clickhouse-server/certs \
44
&& chmod 600 /etc/clickhouse-server/certs/* \

.docker/clickhouse/single_node_tls/config.xml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<?xml version="1.0"?>
22
<clickhouse>
33

4-
<https_port>8443</https_port>
5-
<tcp_port_secure>9440</tcp_port_secure>
6-
<listen_host>0.0.0.0</listen_host>
7-
8-
<users_config>users.xml</users_config>
94
<default_profile>default</default_profile>
105
<default_database>default</default_database>
116

@@ -15,6 +10,7 @@
1510
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
1611
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
1712
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
13+
<format_schema_path>/var/lib/clickhouse/format_schemas/</format_schema_path>
1814

1915
<logger>
2016
<level>warning</level>
@@ -45,4 +41,10 @@
4541
</query_log>
4642

4743
<custom_settings_prefixes>SQL_</custom_settings_prefixes>
44+
45+
<user_directories>
46+
<users_xml>
47+
<path>users.xml</path>
48+
</users_xml>
49+
</user_directories>
4850
</clickhouse>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<clickhouse>
2+
<listen_host>0.0.0.0</listen_host>
3+
<https_port>8443</https_port>
4+
<tcp_port_secure>9440</tcp_port_secure>
5+
</clickhouse>

docker-compose.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,3 @@ services:
1212
hard: 262144
1313
volumes:
1414
- /mnt/timeplusd:/var/lib/timeplusd
15-
16-
clickhouse_tls:
17-
build:
18-
context: ./
19-
dockerfile: .docker/clickhouse/single_node_tls/Dockerfile
20-
container_name: "clickhouse-connect-clickhouse-server-tls"
21-
environment:
22-
CLICKHOUSE_SKIP_USER_SETUP: 1
23-
ports:
24-
- "10843:8443"
25-
- "10840:9440"
26-
ulimits:
27-
nofile:
28-
soft: 262144
29-
hard: 262144
30-
volumes:
31-
- "./.docker/clickhouse/single_node_tls/config.xml:/etc/clickhouse-server/config.xml"
32-
- "./.docker/clickhouse/single_node_tls/users.xml:/etc/clickhouse-server/users.xml"

tests/integration_tests/test_dynamic.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,7 @@ def test_json_str_time(test_client: Client):
162162
pytest.skip('JSON string/numbers bug before 25.1, skipping')
163163
result = test_client.query("SELECT '{\"timerange\": \"2025-01-01T00:00:00+0000\"}'::JSON").result_set
164164
assert result[0][0]['timerange'] == datetime.datetime(2025, 1, 1)
165+
166+
# The following query is broken -- looks like something to do with Nullable(String) in the Tuple
167+
# result = test_client.query("SELECT'{\"k\": [123, \"xyz\"]}'::JSON",
168+
# settings={'input_format_json_read_numbers_as_strings': 0}).result_set

timeplus_connect/driver/client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,14 @@ def _validate_settings(self, settings: Optional[Dict[str, Any]]) -> Dict[str, st
122122
return validated
123123

124124
def _validate_setting(self, key: str, value: Any, invalid_action: str) -> Optional[str]:
125+
new_value = str(value)
126+
if value is True:
127+
new_value = '1'
128+
elif value is False:
129+
new_value = '0'
125130
if key not in self.valid_transport_settings:
126131
setting_def = self.server_settings.get(key)
127-
if setting_def is None or setting_def.readonly:
132+
if setting_def is None or (setting_def.readonly and setting_def.value != new_value):
128133
if key in self.optional_transport_settings:
129134
return None
130135
if invalid_action == 'send':
@@ -134,9 +139,7 @@ def _validate_setting(self, key: str, value: Any, invalid_action: str) -> Option
134139
return None
135140
else:
136141
raise ProgrammingError(f'Setting {key} is unknown or readonly') from None
137-
if isinstance(value, bool):
138-
return '1' if value else '0'
139-
return str(value)
142+
return new_value
140143

141144
def _setting_status(self, key: str) -> SettingStatus:
142145
comp_setting = self.server_settings.get(key)

0 commit comments

Comments
 (0)