|
| 1 | +--- |
| 2 | +# Snapshot the discovery ConfigMap `test-kafka` in KRaft mode: both its `.data` (the KAFKA |
| 3 | +# bootstrap-server list) and its metadata (labels + ownerReferences). The KRaft counterpart |
| 4 | +# of the smoke test's 34-assert. |
| 5 | +# |
| 6 | +# The `.data` heredoc is quoted (`<<'YAMLEOF'`) so shell substitution is disabled; only |
| 7 | +# `__NAMESPACE__` is substituted via `sed`, because kuttl runs in a randomized namespace. |
| 8 | +# Both sides are normalized to canonical JSON via `yq -o=json`. The three broker role groups |
| 9 | +# appear in the bootstrap list in alphabetical order (operator stores role groups in a |
| 10 | +# BTreeMap), on the TLS client port 9093 (smoke-kraft always sets serverSecretClass: tls). |
| 11 | +apiVersion: kuttl.dev/v1beta1 |
| 12 | +kind: TestAssert |
| 13 | +timeout: 60 |
| 14 | +commands: |
| 15 | + - script: | |
| 16 | + expected=$(cat <<'YAMLEOF' | sed "s|__NAMESPACE__|$NAMESPACE|g" | yq -o=json |
| 17 | + KAFKA: test-kafka-broker-automatic-log-config-bootstrap.__NAMESPACE__.svc.cluster.local:9093,test-kafka-broker-custom-log-config-bootstrap.__NAMESPACE__.svc.cluster.local:9093,test-kafka-broker-default-bootstrap.__NAMESPACE__.svc.cluster.local:9093 |
| 18 | + |
| 19 | + YAMLEOF |
| 20 | + ) |
| 21 | + actual=$(kubectl -n $NAMESPACE get cm test-kafka -o yaml | yq -o=json '.data') |
| 22 | + expected_file=$(mktemp) && actual_file=$(mktemp) |
| 23 | + printf '%s\n' "$expected" > "$expected_file" |
| 24 | + printf '%s\n' "$actual" > "$actual_file" |
| 25 | + if ! diff_out=$(diff -u "$expected_file" "$actual_file"); then |
| 26 | + echo "ERROR: ConfigMap test-kafka data drifted from snapshot." |
| 27 | + printf '%s\n' "$diff_out" |
| 28 | + rm -f "$expected_file" "$actual_file" |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | + rm -f "$expected_file" "$actual_file" |
| 32 | +--- |
| 33 | +# Assert the discovery ConfigMap's metadata (labels + ownerReferences). |
| 34 | +# `app.kubernetes.io/version` must be the full image label value |
| 35 | +# (`<product-version>-stackable<image-version>`), NOT the bare product version. |
| 36 | +# kuttl partial-matches, so volatile fields |
| 37 | +# (uid/resourceVersion/timestamps/managedFields) are ignored automatically. |
| 38 | +# The discovery ConfigMap is built by the same broker/`discovery` code path |
| 39 | +# in both modes, so its labels match the smoke test's. |
| 40 | +apiVersion: v1 |
| 41 | +kind: ConfigMap |
| 42 | +metadata: |
| 43 | + name: test-kafka |
| 44 | + labels: |
| 45 | + app.kubernetes.io/component: broker |
| 46 | + app.kubernetes.io/instance: test-kafka |
| 47 | + app.kubernetes.io/managed-by: kafka.stackable.tech_kafkacluster |
| 48 | + app.kubernetes.io/name: kafka |
| 49 | + app.kubernetes.io/role-group: discovery |
| 50 | + app.kubernetes.io/version: "{{ test_scenario['values']['kafka-kraft'].split(',')[0] }}-stackable0.0.0-dev" |
| 51 | + stackable.tech/vendor: Stackable |
| 52 | + ownerReferences: |
| 53 | + - apiVersion: kafka.stackable.tech/v1alpha1 |
| 54 | + controller: true |
| 55 | + kind: KafkaCluster |
| 56 | + name: test-kafka |
0 commit comments