diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:54:28 +0000 |
commit | e6918187568dbd01842d8d1d2c808ce16a894239 (patch) | |
tree | 64f88b554b444a49f656b6c656111a145cbbaa28 /monitoring/ceph-mixin/test-jsonnet.sh | |
parent | Initial commit. (diff) | |
download | ceph-e6918187568dbd01842d8d1d2c808ce16a894239.tar.xz ceph-e6918187568dbd01842d8d1d2c808ce16a894239.zip |
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'monitoring/ceph-mixin/test-jsonnet.sh')
-rwxr-xr-x | monitoring/ceph-mixin/test-jsonnet.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/monitoring/ceph-mixin/test-jsonnet.sh b/monitoring/ceph-mixin/test-jsonnet.sh new file mode 100755 index 000000000..87c533892 --- /dev/null +++ b/monitoring/ceph-mixin/test-jsonnet.sh @@ -0,0 +1,35 @@ +#!/bin/sh -e + +TEMPDIR=$(mktemp -d) +BASEDIR=$(dirname "$0") + +jsonnet -J vendor -m ${TEMPDIR} $BASEDIR/dashboards.jsonnet + +truncate -s 0 ${TEMPDIR}/json_difference.log +for file in ${BASEDIR}/dashboards_out/*.json +do + file_name="$(basename $file)" + for generated_file in ${TEMPDIR}/*.json + do + generated_file_name="$(basename $generated_file)" + if [ "$file_name" == "$generated_file_name" ]; then + jsondiff --indent 2 "${generated_file}" "${file}" \ + | tee -a ${TEMPDIR}/json_difference.log + fi + done +done + +jsonnet -J vendor -S alerts.jsonnet -o ${TEMPDIR}/prometheus_alerts.yml +jsondiff --indent 2 "prometheus_alerts.yml" "${TEMPDIR}/prometheus_alerts.yml" \ + | tee -a ${TEMPDIR}/json_difference.log + +err=0 +if [ $(wc -l < ${TEMPDIR}/json_difference.log) -eq 0 ] +then + rm -rf ${TEMPDIR} + echo "Congratulations! Grafonnet Check Passed" +else + rm -rf ${TEMPDIR} + echo "Grafonnet Check Failed, failed comparing generated file with existing" + exit 1 +fi |