Skip to content

Commit 1719afc

Browse files
committed
Fix --check for client package install (#19)
- Fix `--check` for client package install (when the client package already installed it requires the versions of `clickhouse-client` and `clickhouse-common-static` to match, since `clickhouse-common-static` is not installed in the same command as `clickhouse-client`, fix it by handling various `clickhouse_setup` in a separate tasks there), note however, that it tricky to add a test for this, since for this we need some package already installed, while for now we don't have such "complex" tests, so there will be not test for it (only basic, see below) - Do not trigger restart-clickhouse on client format schema deploy (breaks `clickhouse_setup=client`) - Add tests for `clickhouse_mode=client` on CI Fixes: #18
2 parents 2967a83 + 9043392 commit 1719afc

File tree

6 files changed

+171
-160
lines changed

6 files changed

+171
-160
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ jobs:
5050
version: "22.04"
5151
- name: ubuntu
5252
version: "24.04"
53+
- name: ubuntu
54+
version: "24.04"
55+
setup: client
5356
steps:
5457
- name: Checkout
5558
uses: actions/checkout@v4
@@ -67,4 +70,8 @@ jobs:
6770
run: pip install -r requirements-test.txt
6871

6972
- name: Molecule
70-
run: DISTRO_NAME=${{ matrix.distro.name }} DISTRO_VER=${{ matrix.distro.version }} molecule test
73+
run:
74+
DISTRO_NAME=${{ matrix.distro.name }}
75+
DISTRO_VER=${{ matrix.distro.version }}
76+
CLICKHOUSE_SETUP=${{ matrix.distro.setup }}
77+
molecule test

molecule/default/inventory/group_vars/all.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ clickhouse_packages:
55
- clickhouse-client
66

77
clickhouse_version: "{{ lookup('env', 'CLICKHOUSE_VER') }}"
8+
clickhouse_setup: "{{ lookup('env', 'CLICKHOUSE_SETUP') }}"
89

910
clickhouse_users:
1011
default:

molecule/default/molecule.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ provisioner:
3030
name: ansible
3131
env:
3232
CLICKHOUSE_VER: ${CLICKHOUSE_VER:-'*'}
33+
CLICKHOUSE_SETUP: ${CLICKHOUSE_SETUP:-'full'}
3334
inventory:
3435
links:
3536
group_vars: ./inventory/group_vars/

molecule/default/verify.yml

Lines changed: 159 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -54,159 +54,162 @@
5454
result: ""
5555
5656
tasks:
57-
- name: Include role default variables
58-
include_vars:
59-
dir: ../../defaults/
60-
extensions:
61-
- yml
62-
name: role_defaults
63-
64-
- name: Assert clickhouse user created
65-
getent:
66-
database: passwd
67-
key: clickhouse
68-
69-
- name: Assert clickhouse group created
70-
getent:
71-
database: group
72-
key: clickhouse
73-
74-
- name: Collect installed packages
75-
package_facts:
76-
manager: auto
77-
78-
- name: Assert Clickhouse Packages
79-
assert:
80-
that:
81-
- "'{{ item }}' in ansible_facts.packages"
82-
loop: "{{ clickhouse_packages }}"
83-
84-
- name: Collect systemd services
85-
service_facts:
86-
87-
- name: Assert systemd unit is in running state
88-
assert:
89-
that:
90-
- "ansible_facts.services['clickhouse-server.service'].status == 'enabled'"
91-
- "ansible_facts.services['clickhouse-server.service'].state == 'running'"
92-
93-
- name: Collect default role override files
94-
find:
95-
path: ../../templates/clickhouse-server/config.d/
96-
patterns: "*.yml.j2"
97-
delegate_to: localhost
98-
register: default_role_overrides_files
99-
100-
- name: Default role overrides
101-
set_fact:
102-
default_role_overrides: >
103-
{{ default_role_overrides_files.files |
104-
map(attribute='path') |
105-
map('basename') |
106-
map('replace', '.j2', '')
107-
}}
108-
109-
- name: Assert role default overrides exist
110-
include_tasks: ./helpers/assert_config_exists.yml
111-
vars:
112-
target_config_dir: /etc/clickhouse-server/config.d
113-
with_items:
114-
- "{{ default_role_overrides }}"
115-
116-
- name: Collect user-defined config override files
117-
find:
118-
path: templates/config.d/
119-
patterns: "*.yml.j2"
120-
delegate_to: localhost
121-
register: user_defined_config_overrides_files
122-
123-
- name: User-defined config overrides
124-
set_fact:
125-
user_defined_config_overrides: >
126-
{{ user_defined_config_overrides_files.files |
127-
map(attribute='path') |
128-
map('basename') |
129-
map('replace', '.j2', '')
130-
}}
131-
132-
- name: Assert user-defined configuration overrides exist
133-
include_tasks: ./helpers/assert_config_exists.yml
134-
vars:
135-
target_config_dir: /etc/clickhouse-server/config.d
136-
with_items:
137-
- "{{ user_defined_config_overrides }}"
138-
139-
- name: Collect user-defined user override files
140-
find:
141-
path: templates/users.d/
142-
patterns: "*.yml.j2"
143-
delegate_to: localhost
144-
register: user_defined_user_overrides_files
145-
146-
- name: User-defined user overrides
147-
set_fact:
148-
user_defined_user_overrides: >
149-
{{ user_defined_user_overrides_files.files |
150-
map(attribute='path') |
151-
map('basename') |
152-
map('replace', '.j2', '')
153-
}}
154-
155-
- name: Assert user-defined configuration overrides exist
156-
include_tasks: ./helpers/assert_config_exists.yml
157-
vars:
158-
target_config_dir: /etc/clickhouse-server/users.d
159-
with_items:
160-
- "{{ user_defined_user_overrides }}"
161-
162-
- name: Assert configuration has been applied correctly
163-
include_tasks: ./helpers/assert_query_result.yml
164-
with_items:
165-
- "{{ database_level_assertions }}"
166-
167-
- name: Assert HTTP interface ping returns 200
168-
uri:
169-
url: http://localhost:8123/ping
170-
171-
- name: Assert Prometheus endpoint returns 200
172-
uri:
173-
url: http://localhost:9363/metrics
174-
175-
- name: Assert preconfigured HTTP handlers return 200
176-
uri:
177-
url: http://localhost:8123/{{ item }}
178-
with_items:
179-
- metrics/dictionary
180-
- metrics/rocksdb
181-
- metrics/distribution_queue
182-
183-
- name: Assert all user defined handlers return 200
184-
uri:
185-
url: http://localhost:8123/{{ item }}
186-
with_items:
187-
- first_test_handler
188-
- second_test_handler
189-
- third_test_handler
190-
191-
- name: Assert server format schema is accessible
192-
uri:
193-
url: "http://localhost:8123/?format_schema=record:Record&query=select+1+key,'foo'+value+format+Protobuf"
194-
195-
- name: Assert client format schema is accessible
196-
command: >
197-
clickhouse-client --query "select 1 key, 'foo' value format Protobuf settings format_schema='record:Record'"
198-
199-
- name: Assert no unexpected messages found in .err.log
200-
command: >
201-
grep -v \
202-
-e 'Access(local_directory): File /var/lib/clickhouse/access/users.list doesn\'t exist' \
203-
-e 'Access(local_directory): Recovering lists in directory /var/lib/clickhouse/access/' \
204-
-e 'Available memory at server startup is too low' \
205-
-e 'Delay accounting is not enabled' \
206-
-e 'Integrity check of the executable skipped because the reference checksum could not be read' \
207-
-e 'Linux is not using a fast clock source' \
208-
-e 'Linux threads max count is too low' \
209-
-e 'Linux transparent hugepages are set to "always"' \
210-
/var/log/clickhouse-server/clickhouse-server.err.log
211-
register: grep_result
212-
failed_when: grep_result.rc != 1
57+
- name: Server tests
58+
when: clickhouse_setup == "full"
59+
block:
60+
- name: Include role default variables
61+
include_vars:
62+
dir: ../../defaults/
63+
extensions:
64+
- yml
65+
name: role_defaults
66+
67+
- name: Assert clickhouse user created
68+
getent:
69+
database: passwd
70+
key: clickhouse
71+
72+
- name: Assert clickhouse group created
73+
getent:
74+
database: group
75+
key: clickhouse
76+
77+
- name: Collect installed packages
78+
package_facts:
79+
manager: auto
80+
81+
- name: Assert Clickhouse Packages
82+
assert:
83+
that:
84+
- "'{{ item }}' in ansible_facts.packages"
85+
loop: "{{ clickhouse_packages }}"
86+
87+
- name: Collect systemd services
88+
service_facts:
89+
90+
- name: Assert systemd unit is in running state
91+
assert:
92+
that:
93+
- "ansible_facts.services['clickhouse-server.service'].status == 'enabled'"
94+
- "ansible_facts.services['clickhouse-server.service'].state == 'running'"
95+
96+
- name: Collect default role override files
97+
find:
98+
path: ../../templates/clickhouse-server/config.d/
99+
patterns: "*.yml.j2"
100+
delegate_to: localhost
101+
register: default_role_overrides_files
102+
103+
- name: Default role overrides
104+
set_fact:
105+
default_role_overrides: >
106+
{{ default_role_overrides_files.files |
107+
map(attribute='path') |
108+
map('basename') |
109+
map('replace', '.j2', '')
110+
}}
111+
112+
- name: Assert role default overrides exist
113+
include_tasks: ./helpers/assert_config_exists.yml
114+
vars:
115+
target_config_dir: /etc/clickhouse-server/config.d
116+
with_items:
117+
- "{{ default_role_overrides }}"
118+
119+
- name: Collect user-defined config override files
120+
find:
121+
path: templates/config.d/
122+
patterns: "*.yml.j2"
123+
delegate_to: localhost
124+
register: user_defined_config_overrides_files
125+
126+
- name: User-defined config overrides
127+
set_fact:
128+
user_defined_config_overrides: >
129+
{{ user_defined_config_overrides_files.files |
130+
map(attribute='path') |
131+
map('basename') |
132+
map('replace', '.j2', '')
133+
}}
134+
135+
- name: Assert user-defined configuration overrides exist
136+
include_tasks: ./helpers/assert_config_exists.yml
137+
vars:
138+
target_config_dir: /etc/clickhouse-server/config.d
139+
with_items:
140+
- "{{ user_defined_config_overrides }}"
141+
142+
- name: Collect user-defined user override files
143+
find:
144+
path: templates/users.d/
145+
patterns: "*.yml.j2"
146+
delegate_to: localhost
147+
register: user_defined_user_overrides_files
148+
149+
- name: User-defined user overrides
150+
set_fact:
151+
user_defined_user_overrides: >
152+
{{ user_defined_user_overrides_files.files |
153+
map(attribute='path') |
154+
map('basename') |
155+
map('replace', '.j2', '')
156+
}}
157+
158+
- name: Assert user-defined configuration overrides exist
159+
include_tasks: ./helpers/assert_config_exists.yml
160+
vars:
161+
target_config_dir: /etc/clickhouse-server/users.d
162+
with_items:
163+
- "{{ user_defined_user_overrides }}"
164+
165+
- name: Assert configuration has been applied correctly
166+
include_tasks: ./helpers/assert_query_result.yml
167+
with_items:
168+
- "{{ database_level_assertions }}"
169+
170+
- name: Assert HTTP interface ping returns 200
171+
uri:
172+
url: http://localhost:8123/ping
173+
174+
- name: Assert Prometheus endpoint returns 200
175+
uri:
176+
url: http://localhost:9363/metrics
177+
178+
- name: Assert preconfigured HTTP handlers return 200
179+
uri:
180+
url: http://localhost:8123/{{ item }}
181+
with_items:
182+
- metrics/dictionary
183+
- metrics/rocksdb
184+
- metrics/distribution_queue
185+
186+
- name: Assert all user defined handlers return 200
187+
uri:
188+
url: http://localhost:8123/{{ item }}
189+
with_items:
190+
- first_test_handler
191+
- second_test_handler
192+
- third_test_handler
193+
194+
- name: Assert server format schema is accessible
195+
uri:
196+
url: "http://localhost:8123/?format_schema=record:Record&query=select+1+key,'foo'+value+format+Protobuf"
197+
198+
- name: Assert client format schema is accessible
199+
command: >
200+
clickhouse-client --query "select 1 key, 'foo' value format Protobuf settings format_schema='record:Record'"
201+
202+
- name: Assert no unexpected messages found in .err.log
203+
command: >
204+
grep -v \
205+
-e 'Access(local_directory): File /var/lib/clickhouse/access/users.list doesn\'t exist' \
206+
-e 'Access(local_directory): Recovering lists in directory /var/lib/clickhouse/access/' \
207+
-e 'Available memory at server startup is too low' \
208+
-e 'Delay accounting is not enabled' \
209+
-e 'Integrity check of the executable skipped because the reference checksum could not be read' \
210+
-e 'Linux is not using a fast clock source' \
211+
-e 'Linux threads max count is too low' \
212+
-e 'Linux transparent hugepages are set to "always"' \
213+
/var/log/clickhouse-server/clickhouse-server.err.log
214+
register: grep_result
215+
failed_when: grep_result.rc != 1

tasks/install_repo.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
name: >
4545
{{
4646
clickhouse_packages |
47-
reject('equalto', 'clickhouse-client') |
4847
product([clickhouse_version | d('*')]) |
4948
map('join', '=')
5049
}}
@@ -61,7 +60,7 @@
6160
name: >
6261
{{
6362
clickhouse_packages |
64-
select('equalto', 'clickhouse-client') |
63+
select('in', ['clickhouse-client', 'clickhouse-common-static']) |
6564
product([clickhouse_version | d('*')]) |
6665
map('join', '=')
6766
}}
@@ -71,3 +70,4 @@
7170
retries: 5
7271
delay: 5
7372
until: clickhouse_apt_packages is success
73+
when: clickhouse_setup == "client"

tasks/pre_configure.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@
260260
dest: "/etc/clickhouse-client/format_schemas/{{ item | basename }}"
261261
owner: root
262262
group: root
263-
notify: restart-clickhouse
264263
loop: "{{ clickhouse_format_schema_files }}"
265264
- name: Deploy clickhouse-client configuration files
266265
template:

0 commit comments

Comments
 (0)