mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 14:27:15 +00:00
improved server comparison script
This commit is contained in:
1 parent
0806d8a478
commit
4fac31b8ab
1 file changed
+33
-11
+33
-11
@@ -4,17 +4,28 @@
|
||||
# service output, sorts it, compares them, and if equal, obtains all corresponding leaderboardgroups/*
|
||||
# documents and compares those in turn.
|
||||
|
||||
options='c'
|
||||
options='cevl'
|
||||
while getopts $options option
|
||||
do
|
||||
case $option in
|
||||
c) continue="1";;
|
||||
e) exitOnError="1";;
|
||||
v) verbose="1";;
|
||||
l) list="1";;
|
||||
\?) echo "Invalid option"
|
||||
exit 4;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ "$verbose" = "1" ]; then
|
||||
WGET_ERR=/dev/stderr
|
||||
WGET_QUIET=""
|
||||
else
|
||||
WGET_ERR=/dev/null
|
||||
WGET_QUIET="--quiet"
|
||||
fi
|
||||
|
||||
OLDSERVER=$1
|
||||
NEWSERVER=$2
|
||||
OLDGROUPS=leaderboardgroups.old.sed
|
||||
@@ -22,30 +33,41 @@ NEWGROUPS=leaderboardgroups.new.sed
|
||||
|
||||
# If we continue, don't download again
|
||||
if [ "$continue" != "1" ]; then
|
||||
wget -O - ${OLDSERVER}/sailingserver/api/v1/leaderboardgroups | sed -e 's/,/\n/g' -e 's/\[/\n/' -e 's/\]/\n/' -e 's/\"//g' | grep -v "^$" | sort >$OLDGROUPS
|
||||
wget -O - ${NEWSERVER}/sailingserver/api/v1/leaderboardgroups | sed -e 's/,/\n/g' -e 's/\[/\n/' -e 's/\]/\n/' -e 's/\"//g' | grep -v "^$" | sort >$NEWGROUPS
|
||||
wget $WGET_QUIET -O - ${OLDSERVER}/sailingserver/api/v1/leaderboardgroups | sed -e 's/,/\n/g' -e 's/\[/\n/' -e 's/\]/\n/' -e 's/\"//g' | grep -v "^$" | sort >$OLDGROUPS
|
||||
wget $WGET_QUIET -O - ${NEWSERVER}/sailingserver/api/v1/leaderboardgroups | sed -e 's/,/\n/g' -e 's/\[/\n/' -e 's/\]/\n/' -e 's/\"//g' | grep -v "^$" | sort >$NEWGROUPS
|
||||
fi
|
||||
|
||||
diff leaderboardgroups.old.sed leaderboardgroups.new.sed
|
||||
if [ "$?" = "0" ]; then
|
||||
OLD_LB=`head -n 1 $OLDGROUPS`
|
||||
NEW_LB=`head -n 1 $NEWGROUPS`
|
||||
exec 3<> $OLDGROUPS
|
||||
exec 4<> $NEWGROUPS
|
||||
read OLD_LB <&3
|
||||
read NEW_LB <&4
|
||||
while [ "$OLD_LB" != "" ]; do
|
||||
wget -O - "${OLDSERVER}/sailingserver/api/v1/leaderboardgroups/`echo $OLD_LB | sed -e 's/ /%20/g'`" | sed -e 's/\b470W\b/470/g' -e 's/\b470M\b/470/g' -e 's/\<505\>/5O5/g' -e 's/Laser Int\./Laser/g' | python -m json.tool | grep -v timepoint >"${OLD_LB}.old.json"
|
||||
wget -O - "${NEWSERVER}/sailingserver/api/v1/leaderboardgroups/`echo $NEW_LB | sed -e 's/ /%20/g'`" | sed -e 's/\b470W\b/470/g' -e 's/\b470M\b/470/g' -e 's/\<505\>/5O5/g' -e 's/Laser Int\./Laser/g' | python -m json.tool | grep -v timepoint >"${NEW_LB}.new.json"
|
||||
if [ "$list" = "1" ]; then
|
||||
echo " * $OLD_LB"
|
||||
fi
|
||||
wget $WGET_QUIET -O - "${OLDSERVER}/sailingserver/api/v1/leaderboardgroups/`echo $OLD_LB | sed -e 's/ /%20/g'`" | sed -e 's/\b470W\b/470/g' -e 's/\b470M\b/470/g' -e 's/\<505\>/5O5/g' -e 's/Laser Int\./Laser/g' -e 's/J-24/J\/24/g' -e 's/[^ ]Radial/Laser Radial/g' -e 's/J80/J\/80/g' -e 's/12mR/12 Meter/g' -e 's/Extreme40/Extreme 40/g' -e 's/Drachen/Dragon Int\./g' -e 's/TORNADO/Tornado Catamaran/g' -e 's/Melges24/Melges 24/g' -e 's/RAD W/RADW/g' -e 's/B25/Platu 25/g' -e 's/Europe[^ ]/Europe Int\./g' | python -m json.tool | grep -v timepoint >"${OLD_LB}.old.json" 2>$WGET_ERR
|
||||
wget $WGET_QUIET -O - "${NEWSERVER}/sailingserver/api/v1/leaderboardgroups/`echo $NEW_LB | sed -e 's/ /%20/g'`" | sed -e 's/\b470W\b/470/g' -e 's/\b470M\b/470/g' -e 's/\<505\>/5O5/g' -e 's/Laser Int\./Laser/g' -e 's/J-24/J\/24/g' -e 's/[^ ]Radial/Laser Radial/g' -e 's/J80/J\/80/g' -e 's/12mR/12 Meter/g' -e 's/Extreme40/Extreme 40/g' -e 's/Drachen/Dragon Int\./g' -e 's/TORNADO/Tornado Catamaran/g' -e 's/Melges24/Melges 24/g' -e 's/RAD W/RADW/g' -e 's/B25/Platu 25/g' -e 's/Europe[^ ]/Europe Int\./g' | python -m json.tool | grep -v timepoint >"${NEW_LB}.new.json" 2>$WGET_ERR
|
||||
diff -b -i -B "${OLD_LB}.old.json" "${NEW_LB}.new.json"
|
||||
DIFFRESULT=$?
|
||||
if [ "$DIFFRESULT" != "0" ]; then
|
||||
echo "Difference detected in leaderboard group $OLD_LB vs. $NEW_LB; exiting"
|
||||
exit $DIFFRESULT
|
||||
echo "Difference detected in leaderboard group $OLD_LB vs. $NEW_LB"
|
||||
if [ "$exitOnError" = "1" ]; then
|
||||
echo "Exiting..."
|
||||
exit $DIFFRESULT
|
||||
fi
|
||||
else
|
||||
# no diff; remove the leaderboards successfully compared from both leaderboardgroups lists in case a later -c invocation occurs
|
||||
sed -i -e '1d' $OLDGROUPS
|
||||
sed -i -e '1d' $NEWGROUPS
|
||||
fi
|
||||
OLD_LB=`head -n 1 $OLDGROUPS`
|
||||
NEW_LB=`head -n 1 $NEWGROUPS`
|
||||
read OLD_LB <&3
|
||||
read NEW_LB <&4
|
||||
done
|
||||
else
|
||||
# pass on diff result to caller
|
||||
exit $?
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user