summaryrefslogtreecommitdiffstats
path: root/ms/gra/gra-docker/src/main/scripts/compareContrail.sh
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dt5972@att.com>2021-10-29 14:47:40 -0400
committerDan Timoney <dtimoney@att.com>2021-11-01 10:17:41 -0400
commit5b935a9086ec1080f896b9a71c52283122aa0163 (patch)
treef28aee1327e5b6c8ad423dec5950d46f66ac201b /ms/gra/gra-docker/src/main/scripts/compareContrail.sh
parent53b2788231f5ab3aeda4f09e1445a02c3a3b6be9 (diff)
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 <dtimoney@att.com>
Diffstat (limited to 'ms/gra/gra-docker/src/main/scripts/compareContrail.sh')
-rwxr-xr-xms/gra/gra-docker/src/main/scripts/compareContrail.sh55
1 files changed, 55 insertions, 0 deletions
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)"
+
+
+
+