From 5b935a9086ec1080f896b9a71c52283122aa0163 Mon Sep 17 00:00:00 2001 From: "Timoney, Dan (dt5972)" Date: Fri, 29 Oct 2021 14:47:40 -0400 Subject: Sync local changes to support GRA microservice Sync changes made downstream to support GRA microservice Change-Id: If3bf5d879f7d61ab91209c63b0344d78128246a8 Issue-ID: CCSDK-3504 Signed-off-by: Dan Timoney --- .../gra-docker/src/main/scripts/compareContrail.sh | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 ms/gra/gra-docker/src/main/scripts/compareContrail.sh (limited to 'ms/gra/gra-docker/src/main/scripts/compareContrail.sh') diff --git a/ms/gra/gra-docker/src/main/scripts/compareContrail.sh b/ms/gra/gra-docker/src/main/scripts/compareContrail.sh new file mode 100755 index 0000000..5c613e7 --- /dev/null +++ b/ms/gra/gra-docker/src/main/scripts/compareContrail.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +if [ $# -eq 2 ] +then + verbose=false + file1=$1 + file2=$2 +elif [ $# -eq 3 -a $1 = "-v" ] +then + verbose=true + file1=$2 + file2=$3 +else + echo "Usage: $0 [-v] file1 file2" + exit 1 +fi + +tmppfx=contrail$$ + +formattedfile1=/tmp/$tmppfx-formatted1 +formattedfile2=/tmp/$tmppfx-formatted2 +idlist1=/tmp/$tmppfx-contrail-ids-1 +idlist2=/tmp/$tmppfx-contrail-ids-2 + + +echo "Comparing $file1 to $file2 ...." + +cat $file1 | python3 -mjson.tool > $formattedfile1 +cat $file2 | python3 -mjson.tool > $formattedfile2 + +cat $formattedfile1 | grep '"allotted-resource-id":' | cut -d: -f2 | sed -e "s/,$//" -e 's/\"//g' -e '/^[[:space:]]*$/d' | sort -u > $idlist1 +cat $formattedfile2 | grep '"allotted-resource-id":' | cut -d: -f2 | sed -e "s/,$//" -e 's/\"//g' -e '/^[[:space:]]*$/d' | sort -u > $idlist2 + +echo +echo "Diff of allotted resource ids:" +echo "------------------------------" +diff $idlist1 $idlist2 + +if [ "$verbose" = "true" ] +then + echo + echo "Full diff:" + echo "----------" + diff $formattedfile1 $formattedfile2 +fi + +echo +echo "Allotted resource counts:" +echo "-------------------------" +echo " $file1 : $(cat $idlist1 | wc -l)" +echo " $file2 : $(cat $idlist2 | wc -l)" + + + + -- cgit 1.2.3-korg