| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | |
| 5 | # NOTE: |
| 6 | # This script compares the data imported into the database by run-importer-test |
| 7 | # with the data in good/ (successfully imported and moved files). |
| 8 | # Limitation: only the headers #T, #P are compared, not the Traceroute hops!! |
| 9 | |
| 10 | if [ $# -ne 1 ] ; then |
| 11 | echo >&2 "Usage: $0 configuration_file" |
| 12 | exit 1 |
| 13 | fi |
| 14 | CONFIGURATION_FILE="$1" |
| 15 | if [ ! -e "${CONFIGURATION_FILE}" ] ; then |
| 16 | echo >&2 "ERROR: Use configuration $1 does not exist!" |
| 17 | fi |
| 18 | |
| 19 | |
| 20 | for type in Ping Traceroute ; do |
| 21 | |
| 22 | echo "Obtaining ${type} data from good/ directory ..." |
| 23 | find good/ -name "${type}-*.bz2" | sort | xargs -r bzcat | tee imported-raw-${type,,}.txt | grep "^#" | sort -k4 >imported-${type,,}.txt |
| 24 | # ls -l imported-raw-${type,,}.txt imported-${type,,}.txt |
| 25 | |
| 26 | |
| 27 | echo "Querying ${type} data from database ..." |
| 28 | ./hpct-query "${CONFIGURATION_FILE}" ${type,,} | tee queried-raw-${type,,}.txt | grep "^#" | sort -k4 >queried-${type,,}.txt |
| 29 | # ls -l queried-raw-${type,,}.txt queried-${type,,}.txt |
| 30 | |
| 31 | echo "Differences for ${type}:" |
| 32 | if [ "${type}" == "Traceroute" ] ; then |
| 33 | ls -l imported-raw-${type,,}.txt |
| 34 | ls -l queried-raw-${type,,}.txt |
| 35 | fi |
| 36 | colordiff imported-${type,,}.txt queried-${type,,}.txt |
| 37 | |
| 38 | done |