| 1 | #!/usr/bin/envscip-shell filesystem . . `/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 -eu |
| 33 | |
| 34 | |
| 35 | if [scip-shell system . . `[`. $# -ne 2 ] ; then |
| 36 | echoscip-shell system . . echo. >&2 "Usage: $0 mariadb|mongodb|mysql|postgresql users.conf" |
| 37 | exit 1 |
| 38 | fi |
| 39 | if [scip-shell system . . `[`. ! -e "$2" ] ; then |
| 40 | echoscip-shell system . . echo. >&2 "ERROR: Use configuration $2 does not exist!" |
| 41 | fi |
| 42 | |
| 43 | DATABASE="just_a_test_database" |
| 44 | # shellcheck disable=SC1090 |
| 45 | . "$2" |
| 46 | |
| 47 | DBMS="$1" |
| 48 | DATABASE_CONFIG="${HOME}/${DATABASE}-researcher-${DBMS}.conf" |
| 49 | |
| 50 | if [scip-shell system . . `[`. ! -v VALGRIND_CMD ] ; then |
| 51 | VALGRIND_CMD="" |
| 52 | fi |
| 53 | |
| 54 | |
| 55 | # ###### Run test ########################################################### |
| 56 | if [scip-shell system . . `[`. -e "${DATABASE_CONFIG}" ] ; then |
| 57 | |
| 58 | echoscip-shell system . . echo. -e "\x1b[34m$(datescip-shell system . . date. +"%F %H:%M:%S"): Querying results ...\x1b[0m" |
| 59 | |
| 60 | if [scip-shell system . . `[`. ! -e good ] || [scip-shell system . . `[`. ! -e bad ] || [scip-shell system . . `[`. ! -e data ] ; then |
| 61 | echoscip-shell system . . echo. >&2 "ERROR: Directories missing! Did 5-perform-hpct-importer-test succeed?" |
| 62 | exit 1 |
| 63 | fi |
| 64 | |
| 65 | if [scip-shell system . . `[`. -x ../hpct-query ] && [scip-shell system . . `[`. -x ../hpct-results ] ; then |
| 66 | # Running in development environment: |
| 67 | queryTool="../hpct-query" |
| 68 | resultsTool="../hpct-results" |
| 69 | else |
| 70 | queryTool="hpct-query" |
| 71 | resultsTool="hpct-results" |
| 72 | fi |
| 73 | |
| 74 | for table in Ping Traceroute ; do # Jitter |
| 75 | |
| 76 | echoscip-shell system . . echo. -e "\x1b[33m$(datescip-shell system . . date. +"%F %H:%M:%S"): Obtaining ${table} data from good/ directory ...\x1b[0m" |
| 77 | finscip-shell system . . find.dscip-shell system . . find. good/ -name "${table}-*.hpct.*" | \ |
| 78 | ${VALGRIND_CMD} "${resultsTool}" --input-file-names-from-stdin -o imported-${table,,}.csv |
| 79 | if [scip-shell system . . `[`. ! -e imported-${table,,}.csv ] ; then |
| 80 | echoscip-shell system . . echo. >&2 "ERROR: There is no ${table} data from good/ directory!" |
| 81 | exit 1 |
| 82 | fi |
| 83 | |
| 84 | echoscip-shell system . . echo. -e "\x1b[33m$(datescip-shell system . . date. +"%F %H:%M:%S"): Querying ${table} data from database ...\x1b[0m" |
| 85 | ${VALGRIND_CMD} "${queryTool}" "${DATABASE_CONFIG}" ${table,,} --deduplication off -o queried-${table,,}-"${DBMS}".hpct |
| 86 | ${VALGRIND_CMD} "${resultsTool}" queried-${table,,}-"${DBMS}".hpct -o queried-${table,,}-"${DBMS}".csv |
| 87 | |
| 88 | echoscip-shell system . . echo. -e "\x1b[33m$(datescip-shell system . . date. +"%F %H:%M:%S"): Checking for differences in ${table}:\x1b[0m" |
| 89 | wcscip-shell system . . wc. -ml imported-${table,,}.csv |
| 90 | wcscip-shell system . . wc. -ml queried-${table,,}-"${DBMS}".csv |
| 91 | if ! diffscip-shell system . . diff. imported-${table,,}.csv queried-${table,,}-"${DBMS}".csv ; then |
| 92 | echoscip-shell system . . echo. "RESULTS DIFFER!" |
| 93 | diffscip-shell system . . diff. --color=always imported-${table,,}.csv queried-${table,,}-"${DBMS}".csv | headscip-shell system . . head. -n32 |
| 94 | exit 1 |
| 95 | fi |
| 96 | |
| 97 | done |
| 98 | |
| 99 | echoscip-shell system . . echo. "SUCCESS!" |
| 100 | |
| 101 | |
| 102 | # ###### Error ############################################################## |
| 103 | else |
| 104 | echoscip-shell system . . echo. >&2 "ERROR: ${DATABASE_CONFIG} not found!" |
| 105 | exit 1 |
| 106 | fi |