Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
exclude: ^(Cargo\.nix|crate-hashes\.json|nix/.*)$
# The files tests/templates/kuttl/smoke/31_configmap_.* define the expected ConfigMap contents.
# New lines at the end of these files are intentional and must not be removed by the pre-commit hook
# "end-of-file-fixer".
exclude: ^(Cargo\.nix|crate-hashes\.json|nix/.*|tests/templates/kuttl/smoke/31_configmap_.*)$

default_language_version:
node: system
Expand Down
51 changes: 46 additions & 5 deletions tests/templates/kuttl/smoke/30-assert.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,45 @@ spec:
name: listener
- mountPath: /stackable/data
name: data
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
- args:
- |
mkdir --parents /stackable/log/_vector-state
# Vector will ignore SIGTERM (as PID != 1) and must be shut down by writing a shutdown trigger file
vector --config /stackable/config/vector.yaml & vector_pid=$!
if [ ! -f "/stackable/log/_vector/shutdown" ]; then
mkdir -p /stackable/log/_vector && inotifywait -qq --event create /stackable/log/_vector; fi
sleep 1
kill $vector_pid
command:
- /bin/bash
- -x
- -euo
- pipefail
- -c
env:
- name: VECTOR_LOG
value: info
- name: VECTOR_AGGREGATOR_ADDRESS
valueFrom:
configMapKeyRef:
key: ADDRESS
name: vector-aggregator-discovery
imagePullPolicy: IfNotPresent
name: vector
resources:
limits:
cpu: 500m
memory: 128Mi
requests:
cpu: 250m
memory: 128Mi
volumeMounts:
- mountPath: /stackable/config
name: hdfs-config
- mountPath: /stackable/log
name: log
{% endif %}
- args:
- |
mkdir -p /stackable/config/zkfc
Expand Down Expand Up @@ -457,9 +496,6 @@ spec:
name: zkfc-config
- mountPath: /stackable/mount/log/zkfc
name: zkfc-log-config
{% if lookup('env', 'VECTOR_AGGREGATOR') %}
- name: vector
{% endif %}
enableServiceLinks: false
initContainers:
- args:
Expand Down Expand Up @@ -710,7 +746,9 @@ spec:
name: hdfs-namenode-default
name: format-zookeeper-log-config
volumeClaimTemplates:
- metadata:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
spec:
accessModes:
Expand All @@ -719,7 +757,10 @@ spec:
requests:
storage: 2Gi
volumeMode: Filesystem
- metadata:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
annotations:
listeners.stackable.tech/listener-class: {{ test_scenario['values']['listener-class'] }}
labels:
Expand Down
28 changes: 10 additions & 18 deletions tests/templates/kuttl/smoke/31-assert.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,20 @@
# envsubst expands only the listed shell variables ($NAMESPACE etc.),
# leaving Hadoop ${env.FOO} references untouched.
#
# Both sides are converted to JSON via yq, then jq normalises trailing
# newlines in string values (collapsing \n+ to \n) so YAML block scalar
# style (|, |+) differences don't cause false failures.
# vector.toml is excluded because its presence depends on the
# VECTOR_AGGREGATOR env var set by the CI/test runner. The snapshot
# files are plain YAML (not Jinja2 templates), so they cannot
# conditionally include it.
#
# kuttl runs script commands with sh, not bash, so process substitution
# is unavailable. Temp files namespaced under $NAMESPACE are used for
# diff output to avoid collisions when tests run concurrently.
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 600
timeout: 60
commands:
#
# ConfigMap data snapshot: hdfs-namenode-default
#
- script: |
envsubst '$NAMESPACE' < 31_configmap_hdfs-namenode-default.yaml | yq -o=json | jq 'with_entries(.value |= sub("\n+$"; "\n"))' > /tmp/$NAMESPACE-expected.json
kubectl -n $NAMESPACE get cm hdfs-namenode-default -o yaml | yq -o=json '.data | del(.["vector.toml"])' | jq 'with_entries(.value |= sub("\n+$"; "\n"))' > /tmp/$NAMESPACE-actual.json
if ! diff /tmp/$NAMESPACE-expected.json /tmp/$NAMESPACE-actual.json; then
envsubst '$NAMESPACE' < 31_configmap_hdfs-namenode-default.yaml > /tmp/$NAMESPACE-expected.yaml
kubectl -n $NAMESPACE get cm hdfs-namenode-default -o yaml | yq '.data' > /tmp/$NAMESPACE-actual.yaml
if ! diff /tmp/$NAMESPACE-expected.yaml /tmp/$NAMESPACE-actual.yaml; then
echo "ERROR: ConfigMap hdfs-namenode-default data drifted from snapshot."
exit 1
fi
Expand All @@ -40,19 +32,19 @@ commands:
{% else %}
export DATANODE_DATA_DIR='[DISK]/stackable/data/data/datanode'
{% endif %}
envsubst '$NAMESPACE $DATANODE_DATA_DIR' < 31_configmap_hdfs-datanode-default.yaml | yq -o=json | jq 'with_entries(.value |= sub("\n+$"; "\n"))' > /tmp/$NAMESPACE-expected.json
kubectl -n $NAMESPACE get cm hdfs-datanode-default -o yaml | yq -o=json '.data | del(.["vector.toml"])' | jq 'with_entries(.value |= sub("\n+$"; "\n"))' > /tmp/$NAMESPACE-actual.json
if ! diff /tmp/$NAMESPACE-expected.json /tmp/$NAMESPACE-actual.json; then
envsubst '$NAMESPACE $DATANODE_DATA_DIR' < 31_configmap_hdfs-datanode-default.yaml > /tmp/$NAMESPACE-expected.yaml
kubectl -n $NAMESPACE get cm hdfs-datanode-default -o yaml | yq '.data' > /tmp/$NAMESPACE-actual.yaml
if ! diff /tmp/$NAMESPACE-expected.yaml /tmp/$NAMESPACE-actual.yaml; then
echo "ERROR: ConfigMap hdfs-datanode-default data drifted from snapshot."
exit 1
fi
#
# ConfigMap data snapshot: hdfs-journalnode-default
#
- script: |
envsubst '$NAMESPACE' < 31_configmap_hdfs-journalnode-default.yaml | yq -o=json | jq 'with_entries(.value |= sub("\n+$"; "\n"))' > /tmp/$NAMESPACE-expected.json
kubectl -n $NAMESPACE get cm hdfs-journalnode-default -o yaml | yq -o=json '.data | del(.["vector.toml"])' | jq 'with_entries(.value |= sub("\n+$"; "\n"))' > /tmp/$NAMESPACE-actual.json
if ! diff /tmp/$NAMESPACE-expected.json /tmp/$NAMESPACE-actual.json; then
envsubst '$NAMESPACE' < 31_configmap_hdfs-journalnode-default.yaml > /tmp/$NAMESPACE-expected.yaml
kubectl -n $NAMESPACE get cm hdfs-journalnode-default -o yaml | yq '.data' > /tmp/$NAMESPACE-actual.yaml
if ! diff /tmp/$NAMESPACE-expected.yaml /tmp/$NAMESPACE-actual.yaml; then
echo "ERROR: ConfigMap hdfs-journalnode-default data drifted from snapshot."
exit 1
fi
185 changes: 0 additions & 185 deletions tests/templates/kuttl/smoke/31_configmap_hdfs-datanode-default.yaml

This file was deleted.

Loading
Loading