From cbaffc8a5d16b9540ab9dbdbc6c2f7eeb39ad005 Mon Sep 17 00:00:00 2001 From: Keith Rothman <537074+litghost@users.noreply.github.com> Date: Fri, 18 Jan 2019 10:08:38 -0800 Subject: [PATCH] Add utility to compare JSON from two database's. Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com> --- utils/check_json.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 utils/check_json.sh diff --git a/utils/check_json.sh b/utils/check_json.sh new file mode 100755 index 00000000..4378a4f2 --- /dev/null +++ b/utils/check_json.sh @@ -0,0 +1,26 @@ +#!/bin/bash -e + +# check_json.sh +# +# Tool for comparing database JSON outputs from two database's. + +DIR_A=$1 +DIR_B=$2 + +for A_JSON_IN in $( ls ${DIR_A}/*.json ); do + A_JSON_OUT="$(mktemp)_a" + B_JSON_OUT="$(mktemp)_b" + + B_JSON_IN="${DIR_B}/$(basename ${A_JSON_IN})" + + if [ ! -f "${B_JSON_IN}" ]; then + echo "${B_JSON_IN} not found!" + continue + fi + + python3 -m utils.xjson ${A_JSON_IN} > ${A_JSON_OUT} + python3 -m utils.xjson ${B_JSON_IN} > ${B_JSON_OUT} + + echo "Comparing $(basename ${A_JSON_IN})" + diff -U 3 ${A_JSON_OUT} ${B_JSON_OUT} || true +done