Debian Codegraph @

src/TestDB/5-perform-hpct-importer-test

raw
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 show-script "$(basename "$0")"
62
63 DATABASE="just_a_test_database"
64 # shellcheck disable=SC1090
65 . "$2"
66
67 DBMS="$1"
68 DATABASE_CONFIG="${HOME}/${DATABASE}-importer-${DBMS}.conf"
69 IMPORTER_CONFIG="${HOME}/importer-${DATABASE}.conf"
70
71 if [ ! -v VALGRIND_CMD ] ; then
72 VALGRIND_CMD=""
73 fi
74
75
76 # ###### Run test ###########################################################
77 if [ -e "${DATABASE_CONFIG}" ] ; then
78
79 echo -e "\x1b[34m$(date +"%F %H:%M:%S"): Running importer ...\x1b[0m"
80
81 cd ..
82 if [ ! -e Makefile ] ; then
83 # Running in development environment:
84 if [ -x ../autogen.sh ] ; then
85 cd ..
86 ./autogen.sh
87 cd src
88 fi
89 fi
90 if [ -e Makefile ] ; then
91 # Running in development environment:
92 make hpct-importer
93 rm -f core
94 fi
95 cd TestDB
96
97 mkdir -p data/ good/ bad/
98 rm -rf good/*
99 rm -rf bad/*
100
101 rsync -a --include='*hpct.*' --include='*results.*' --include='*/' --exclude='*' ../results-examples/ data/
102 if [ -x ../hpct-importer ] ; then
103 # Running in development environment:
104 importer="../hpct-importer"
105 else
106 importer="hpct-importer"
107 fi
108 ${VALGRIND_CMD} "${importer}" \
109 -C "${IMPORTER_CONFIG}" \
110 -D "${DATABASE_CONFIG}" \
111 --quit-when-idle \
112 --loglevel 2
113
114
115 # ###### Error ##############################################################
116 else
117 echo >&2 "ERROR: ${DATABASE_CONFIG} not found!"
118 exit 1
119 fi