Skip to content

Commit 93779cc

Browse files
myasnikovdaniillexfrei
authored andcommitted
test(clickhouse): add backup API render assertions
Add fast Helm assertions for the clickhouse-backup API port, Secret references, non-empty generated password, and disabled-backup behavior. Keep the live ClickHouse, MariaDB, and PostgreSQL Service assertions as integration witnesses for operator and API behavior. Assisted-By: LLM Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent d2e3eb4 commit 93779cc

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
suite: clickhouse-backup sidecar API contract (port and credential wiring)
2+
3+
# The contract between the chart and the cozy-default-altinity backup strategy:
4+
# the strategy Pod reaches the in-Pod clickhouse-backup HTTP API on the named
5+
# port ch-backup-api, authenticating with the credentials in the chart-emitted
6+
# <release>-backup-api-auth Secret. A chart bump that renames the container,
7+
# moves the port, or repoints either secretKeyRef breaks every ClickHouse
8+
# BackupJob, and surfaces only as 401s or a connection refused at backup time.
9+
#
10+
# The e2e suite also checks this wiring on the operator-created Pod and admitted
11+
# Secret. These render assertions add an earlier, chart-owned failure signal on
12+
# every pull request; they do not replace the live operator/API integration.
13+
#
14+
# The e2e Test keeps its own reason to exist: it proves a backup-enabled
15+
# ClickHouse actually reaches a ready replica, which no amount of rendering can.
16+
17+
templates:
18+
- templates/clickhouse.yaml
19+
- templates/backup-api-auth-secret.yaml
20+
21+
release:
22+
name: ch-test
23+
namespace: tenant-test
24+
25+
set:
26+
_cluster: {}
27+
28+
tests:
29+
- it: "sidecar exposes the API on the named port the strategy dials"
30+
template: templates/clickhouse.yaml
31+
documentSelector:
32+
path: kind
33+
value: ClickHouseInstallation
34+
set:
35+
backup:
36+
enabled: true
37+
asserts:
38+
- contains:
39+
path: spec.templates.podTemplates[0].spec.containers[?(@.name=='clickhouse-backup')].ports
40+
content:
41+
name: ch-backup-api
42+
containerPort: 7171
43+
protocol: TCP
44+
45+
- it: "sidecar authenticates from the chart-emitted auth Secret"
46+
template: templates/clickhouse.yaml
47+
documentSelector:
48+
path: kind
49+
value: ClickHouseInstallation
50+
set:
51+
backup:
52+
enabled: true
53+
asserts:
54+
- contains:
55+
path: spec.templates.podTemplates[0].spec.containers[?(@.name=='clickhouse-backup')].env
56+
content:
57+
name: API_USERNAME
58+
valueFrom:
59+
secretKeyRef:
60+
name: ch-test-backup-api-auth
61+
key: username
62+
- contains:
63+
path: spec.templates.podTemplates[0].spec.containers[?(@.name=='clickhouse-backup')].env
64+
content:
65+
name: API_PASSWORD
66+
valueFrom:
67+
secretKeyRef:
68+
name: ch-test-backup-api-auth
69+
key: password
70+
71+
- it: "the auth Secret carries both keys the sidecar reads"
72+
template: templates/backup-api-auth-secret.yaml
73+
set:
74+
backup:
75+
enabled: true
76+
asserts:
77+
- isKind:
78+
of: Secret
79+
- equal:
80+
path: metadata.name
81+
value: ch-test-backup-api-auth
82+
# stringData, not data: the apiserver converts one to the other on
83+
# admission, so the live object the e2e suite inspects has `data` while
84+
# the rendered manifest has `stringData`. Asserting the rendered shape is
85+
# the point of testing here rather than there.
86+
- equal:
87+
path: stringData.username
88+
value: backup
89+
- isNotNullOrEmpty:
90+
path: stringData.password
91+
92+
- it: "no auth Secret when backups are off"
93+
template: templates/backup-api-auth-secret.yaml
94+
set:
95+
backup:
96+
enabled: false
97+
asserts:
98+
- hasDocuments:
99+
count: 0

0 commit comments

Comments
 (0)