Skip to content

Commit c0580f3

Browse files
maltesanderclaude
andcommitted
test(smoke): add 53-assert discovery cm + secret snapshot
First slice of the ConfigMap snapshot assertion: the discovery ConfigMap and the operator-managed Secret's key presence. The five role-group ConfigMap snapshots follow in the next commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9f83a01 commit c0580f3

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{# vector_enabled gates conditional appender lines added to role-group
2+
ConfigMaps when VECTOR_AGGREGATOR is set in the environment. The five
3+
role-group ConfigMaps (broker/coordinator/historical/middlemanager/router)
4+
are added in a follow-up commit; the flag is declared here for forward
5+
reference. #}
6+
{% set vector_enabled = lookup('env', 'VECTOR_AGGREGATOR') | length > 0 %}
7+
---
8+
# Snapshot the full `.data` of each operator-managed ConfigMap.
9+
# Any code change that alters rendered config values will fail these diffs.
10+
#
11+
# Runs as its own step (after 50/51/52) so kuttl does not re-evaluate the heavy
12+
# heredocs on every 1-second readiness retry of the install step. By this
13+
# point the cluster is in steady state, so each script runs once.
14+
#
15+
# The heredoc is quoted (`<<'YAMLEOF'`) so shell substitution is disabled and
16+
# Java-properties escapes like `${env\:VAR}` survive verbatim. After the
17+
# heredoc, `sed` substitutes `__NAMESPACE__` (kuttl namespaces are random per
18+
# install). For role-group ConfigMaps (added in a follow-up commit) the
19+
# *actual* side is additionally normalized with `s|/znode-[a-f0-9-]+|/znode-__ZNODE__|`
20+
# because the zk operator generates a new znode UUID per install. Both sides
21+
# are then canonicalized to JSON via `yq -o=json`; keys are already
22+
# alphabetical on both sides (operator stores BTreeMap; kubectl serializes
23+
# maps sorted; the heredoc is hand-sorted).
24+
apiVersion: kuttl.dev/v1beta1
25+
kind: TestAssert
26+
timeout: 60
27+
commands:
28+
# Operator-managed Secret: verify the data keys exist. Values are random
29+
# per install and are not asserted.
30+
- script: kubectl -n $NAMESPACE get secret druid-shared-internal-secret -o yaml | yq -e '.data | has("INTERNAL_INITIAL_CLIENT_PASSWORD")'
31+
- script: kubectl -n $NAMESPACE get secret druid-shared-internal-secret -o yaml | yq -e '.data | has("OIDC_COOKIE_PASSPHRASE")'
32+
33+
# Discovery ConfigMap
34+
- script: |
35+
expected=$(cat <<'YAMLEOF' | sed "s|__NAMESPACE__|$NAMESPACE|g" | yq -o=json
36+
DRUID_AVATICA_JDBC: jdbc:avatica:remote:url=http://druid-router.__NAMESPACE__.svc.cluster.local:9088/druid/v2/sql/avatica/
37+
DRUID_ROUTER: druid-router.__NAMESPACE__.svc.cluster.local:9088
38+
DRUID_SQLALCHEMY: druid://druid-router.__NAMESPACE__.svc.cluster.local:9088/druid/v2/sql
39+
YAMLEOF
40+
)
41+
actual=$(kubectl -n $NAMESPACE get cm druid -o yaml | yq -o=json '.data')
42+
if [ "$expected" != "$actual" ]; then
43+
echo "ERROR: ConfigMap druid data drifted from snapshot."
44+
echo "=== expected ==="
45+
printf '%s\n' "$expected"
46+
echo "=== actual ==="
47+
printf '%s\n' "$actual"
48+
exit 1
49+
fi

0 commit comments

Comments
 (0)