Files
sailing-analytics/java/target/compareServers
T

28 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
# Given the base URLs of two SAP Sailing servers, obtains their /sailingserver/api/v1/leaderboardgroups
# service output, sorts it, compares them, and if equal, obtains all corresponding leaderboardgroups/*
# documents and compares those in turn.
OLDSERVER=$1
NEWSERVER=$2
wget -O - ${OLDSERVER}/sailingserver/api/v1/leaderboardgroups | sed -e 's/,/\n/g' -e 's/\[/\n/' -e 's/\]/\n/' -e 's/\"//g' | grep -v "^$" | sort >leaderboardgroups.old.sed
wget -O - ${NEWSERVER}/sailingserver/api/v1/leaderboardgroups | sed -e 's/,/\n/g' -e 's/\[/\n/' -e 's/\]/\n/' -e 's/\"//g' | grep -v "^$" | sort >leaderboardgroups.new.sed
diff leaderboardgroups.old.sed leaderboardgroups.new.sed
if [ "$?" = "0" ]; then
cat leaderboardgroups.old.sed | while read i; do
wget -O - "${OLDSERVER}/sailingserver/api/v1/leaderboardgroups/`echo $i | sed -e 's/ /%20/g'`" | python -m json.tool >"$i.old.json"
wget -O - "${NEWSERVER}/sailingserver/api/v1/leaderboardgroups/`echo $i | sed -e 's/ /%20/g'`" | python -m json.tool >"$i.new.json"
diff -b -i -B "$i.old.json" "$i.new.json"
DIFFRESULT=$?
if [ "$DIFFRESULT" != "0" ]; then
echo "Difference detected in leaderboard group $i; exiting"
exit $DIFFRESULT
fi
done
fi