Debian Codegraph @

ansible_collections/community/clickhouse/tests/integration/targets/clickhouse_grants/tasks/cluster.yaml

raw
1 ##############################################################################
2 # Tests for the `cluster` parameter
3 ##############################################################################
4
5 - name: Ensure clean state before cluster tests
6 community.clickhouse.clickhouse_grants:
7 state: absent
8 grantee: alice
9
10 # Test: grant in check_mode with cluster should report ON CLUSTER in statements
11 - name: Grant privileges in check mode with cluster (should return diff and statement)
12 register: result_cluster_check
13 check_mode: true
14 community.clickhouse.clickhouse_grants:
15 state: present
16 grantee: alice
17 cluster: test_cluster
18 privileges:
19 - object: 'cluster_db.*'
20 privs:
21 "SELECT": true
22
23 - name: Verify cluster check_mode returned diff and ON CLUSTER statement
24 ansible.builtin.assert:
25 that:
26 - result_cluster_check is changed
27 - result_cluster_check.diff is defined
28 - result_cluster_check.executed_statements | length == 1
29 - "'ON CLUSTER test_cluster' in result_cluster_check.executed_statements[0]"
30
31 # Test: actually grant with cluster - ensure the module includes ON CLUSTER in executed statements
32 - name: Actually grant privileges with cluster
33 register: result_cluster_apply
34 community.clickhouse.clickhouse_grants:
35 state: present
36 grantee: alice
37 cluster: test_cluster
38 privileges:
39 - object: 'cluster_db.*'
40 privs:
41 "SELECT": true
42
43 - name: Check that grant with cluster reported change and statements include ON CLUSTER
44 ansible.builtin.assert:
45 that:
46 - result_cluster_apply is changed
47 - result_cluster_apply.executed_statements | length > 0
48 - "'ON CLUSTER test_cluster' in result_cluster_apply.executed_statements[0]"
49
50 # Test: idempotency with cluster
51 - name: Run same grant with cluster again for idempotency
52 register: result_cluster_idempotent
53 community.clickhouse.clickhouse_grants:
54 state: present
55 grantee: alice
56 cluster: test_cluster
57 privileges:
58 - object: 'cluster_db.*'
59 privs:
60 "SELECT": true
61
62 - name: Check idempotency for cluster grant
63 ansible.builtin.assert:
64 that:
65 - result_cluster_idempotent is not changed
66 - result_cluster_idempotent.executed_statements | length == 0
67
68 # Test: revoke in check_mode with cluster should report statements
69 - name: Revoke all privileges with cluster in check mode
70 register: result_cluster_revoke_check
71 check_mode: true
72 community.clickhouse.clickhouse_grants:
73 state: absent
74 grantee: alice
75 cluster: test_cluster
76
77 - name: Verify revoke in check_mode reported ON CLUSTER statements
78 ansible.builtin.assert:
79 that:
80 - result_cluster_revoke_check is changed
81 - result_cluster_revoke_check.executed_statements | length > 0
82 - "'ON CLUSTER test_cluster' in result_cluster_revoke_check.executed_statements[0]"
83
84 # Test: actually revoke with cluster
85 - name: Actually revoke all privileges with cluster
86 register: result_cluster_revoke
87 community.clickhouse.clickhouse_grants:
88 state: absent
89 grantee: alice
90 cluster: test_cluster
91
92 - name: Check actual revoke with cluster worked and statements include ON CLUSTER
93 ansible.builtin.assert:
94 that:
95 - result_cluster_revoke is changed
96 - result_cluster_revoke.executed_statements | length > 0
97 - "'ON CLUSTER test_cluster' in result_cluster_revoke.executed_statements[0]"