add script to test output differences between branches

parent a69b2332
/.idea/
.DS_Store
db.sqlite3
*.sqlite3
*.py[co]
.tox
.tox2
......@@ -30,4 +30,5 @@ failmap_dataset*
failmap_testdataset*
dev_db/
failmap_debug_dataset*
temp/*
\ No newline at end of file
temp/*
*.out
#!/usr/bin/env bash
set -ex
# Compare output of a test script run against two different branches.
# This script will checkout a the specified branches, create a clean database and rebuild ratings
# after which a script is used to generate output. This output can then be compared for discrepancies.
# usage: tools/compare_differences.sh <branch1> <branch2> <test_script> [<dataset-name>]
branches=(${1?First argument needs to be branch name} ${2?Second argument needs to be branch name})
test_script=${3?Last argument needs to be test script}
dataset=${4:-productiondata}
for branch in "${branches[@]}"; do
git checkout "$branch"
# prepare database
export DB_NAME=$branch.sqlite3
test -f "$DB_NAME" && rm "$DB_NAME"
failmap-admin migrate -v0
# load dataset and update ratings
failmap-admin load-dataset -v0 "$dataset"
failmap-admin rebuild-ratings -v0
# create output
"$test_script" > "$branch.out"
done
# compare output
sdiff "${branches[@]/%/.out}" | less
#!/usr/bin/env bash
set -x
# output a sorted list of all urls id's and their respective rating
failmap-admin shell <<EOF | sort
from failmap_admin.map.models import UrlRating
print('\n'.join('{url__url}\t{rating}'.format(**x) for x in UrlRating.objects.all().values('url__url', 'rating')))
EOF
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment