| 1 |
#!/usr/bin/env bash |
| 2 |
# ========================================================================== |
| 3 |
# _ _ _ ____ ____ _____ |
| 4 |
# | | | (_) _ \ ___ _ __ / ___|___ _ _|_ _| __ __ _ ___ ___ _ __ |
| 5 |
# | |_| | | |_) / _ \ '__| | / _ \| '_ \| || '__/ _` |/ __/ _ \ '__| |
| 6 |
# | _ | | __/ __/ | | |__| (_) | | | | || | | (_| | (_| __/ | |
| 7 |
# |_| |_|_|_| \___|_| \____\___/|_| |_|_||_| \__,_|\___\___|_| |
| 8 |
# |
| 9 |
# --- High-Performance Connectivity Tracer (HiPerConTracer) --- |
| 10 |
# https://www.nntb.no/~dreibh/hipercontracer/ |
| 11 |
# ========================================================================== |
| 12 |
# |
| 13 |
# High-Performance Connectivity Tracer (HiPerConTracer) |
| 14 |
# Copyright (C) 2015-2026 by Thomas Dreibholz |
| 15 |
# |
| 16 |
# This program is free software: you can redistribute it and/or modify |
| 17 |
# it under the terms of the GNU General Public License as published by |
| 18 |
# the Free Software Foundation, either version 3 of the License, or |
| 19 |
# (at your option) any later version. |
| 20 |
# |
| 21 |
# This program is distributed in the hope that it will be useful, |
| 22 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 |
# GNU General Public License for more details. |
| 25 |
# |
| 26 |
# You should have received a copy of the GNU General Public License |
| 27 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 28 |
# |
| 29 |
# Contact: [email protected] |
| 30 |
|
| 31 |
# Bash options: |
| 32 |
set -euo pipefail |
| 33 |
|
| 34 |
|
| 35 |
# ###### Helper function to show script information ######################### |
| 36 |
show-script () |
| 37 |
{ |
| 38 |
local script="$1" |
| 39 |
local columns |
| 40 |
columns="$(print-utf8 -t 2>/dev/null || echo "80")" |
| 41 |
columns="${columns/ */}" |
| 42 |
columns=$((columns - 2)) |
| 43 |
print-utf8 -n -s "\e[1;36m█" "▀" "█\e[0m" ; |
| 44 |
figlet -w "${columns}" "$(basename "${script}")" | print-utf8 -n -C "\e[1;36m█\e[25m" "█\e[0m" ; |
| 45 |
print-utf8 -n -s "\e[1;36m█" "▄" "█\e[0m" |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
# ##### Main program ######################################################## |
| 51 |
|
| 52 |
# ====== Handle arguments =================================================== |
| 53 |
if [ $# -ne 2 ] ; then |
| 54 |
echo >&2 "Usage: $0 mariadb|mongodb|mysql|postgresql users.conf" |
| 55 |
exit 1 |
| 56 |
fi |
| 57 |
if [ ! -e "$2" ] ; then |
| 58 |
echo >&2 "ERROR: Use configuration $2 does not exist!" |
| 59 |
fi |
| 60 |
|
| 61 |
DATABASE="just_a_test_database" |
| 62 |
# shellcheck disable=SC1090 |
| 63 |
. "$2" |
| 64 |
|
| 65 |
DBMS="$1" |
| 66 |
DATABASE_CONFIG="${HOME}/${DATABASE}-researcher-${DBMS}.conf" |
| 67 |
|
| 68 |
if [ ! -v VALGRIND_CMD ] ; then |
| 69 |
VALGRIND_CMD="" |
| 70 |
fi |
| 71 |
|
| 72 |
show-script "$(basename "$0")" |
| 73 |
|
| 74 |
|
| 75 |
# ###### Run test ########################################################### |
| 76 |
if [ -e "${DATABASE_CONFIG}" ] ; then |
| 77 |
|
| 78 |
echo -e "\x1b[34m$(date +"%F %H:%M:%S"): Querying results ...\x1b[0m" |
| 79 |
|
| 80 |
if [ ! -e good ] || [ ! -e bad ] || [ ! -e data ] ; then |
| 81 |
echo >&2 "ERROR: Directories missing! Did 5-perform-hpct-importer-test succeed?" |
| 82 |
exit 1 |
| 83 |
fi |
| 84 |
|
| 85 |
if [ -x ../hpct-query ] && [ -x ../hpct-results ] ; then |
| 86 |
# Running in development environment: |
| 87 |
queryTool="../hpct-query" |
| 88 |
resultsTool="../hpct-results" |
| 89 |
else |
| 90 |
queryTool="hpct-query" |
| 91 |
resultsTool="hpct-results" |
| 92 |
fi |
| 93 |
|
| 94 |
for table in Ping Traceroute ; do # Jitter |
| 95 |
|
| 96 |
echo -e "\x1b[33m$(date +"%F %H:%M:%S"): Obtaining ${table} data from good/ directory ...\x1b[0m" |
| 97 |
find good/ -name "${table}-*.hpct.*" | \ |
| 98 |
${VALGRIND_CMD} "${resultsTool}" --input-file-names-from-stdin -o imported-${table,,}.csv |
| 99 |
if [ ! -e imported-${table,,}.csv ] ; then |
| 100 |
echo >&2 "ERROR: There is no ${table} data from good/ directory!" |
| 101 |
exit 1 |
| 102 |
fi |
| 103 |
|
| 104 |
echo -e "\x1b[33m$(date +"%F %H:%M:%S"): Querying ${table} data from database ...\x1b[0m" |
| 105 |
${VALGRIND_CMD} "${queryTool}" "${DATABASE_CONFIG}" ${table,,} --deduplication off -o queried-${table,,}-"${DBMS}".hpct |
| 106 |
${VALGRIND_CMD} "${resultsTool}" queried-${table,,}-"${DBMS}".hpct -o queried-${table,,}-"${DBMS}".csv |
| 107 |
|
| 108 |
echo -e "\x1b[33m$(date +"%F %H:%M:%S"): Checking for differences in ${table}:\x1b[0m" |
| 109 |
wc -ml imported-${table,,}.csv |
| 110 |
wc -ml queried-${table,,}-"${DBMS}".csv |
| 111 |
if ! diff imported-${table,,}.csv queried-${table,,}-"${DBMS}".csv ; then |
| 112 |
echo "RESULTS DIFFER!" |
| 113 |
diff --color=always imported-${table,,}.csv queried-${table,,}-"${DBMS}".csv | head -n32 |
| 114 |
exit 1 |
| 115 |
fi |
| 116 |
|
| 117 |
done |
| 118 |
|
| 119 |
echo "SUCCESS!" |
| 120 |
|
| 121 |
|
| 122 |
# ###### Error ############################################################## |
| 123 |
else |
| 124 |
echo >&2 "ERROR: ${DATABASE_CONFIG} not found!" |
| 125 |
exit 1 |
| 126 |
fi |