| 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 -eu |
| 33 | |
| 34 | |
| 35 | # ====== Handle arguments =================================================== |
| 36 | if [ $# -lt 1 ] ; then |
| 37 | echo >&2 "Usage: $0 ALL|mariadb|mongodb|mysql|postgresql [--memcheck|--helgrind] [--really-run-i-know-that-it-may-mess-up-the-system]" |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | if [ "$1" == "ALL" ] ; then |
| 42 | shift |
| 43 | # shellcheck disable=SC2068 |
| 44 | $0 mariadb $@ |
| 45 | # shellcheck disable=SC2068 |
| 46 | $0 postgresql $@ |
| 47 | # shellcheck disable=SC2068 |
| 48 | $0 mongodb $@ |
| 49 | exit 0 |
| 50 | fi |
| 51 | |
| 52 | DBMS="$1" |
| 53 | REALLY_RUN="" |
| 54 | shift |
| 55 | while [ $# -gt 0 ] ; do |
| 56 | if [ "$1" == "--memcheck" ] ; then |
| 57 | export VALGRIND_CMD="valgrind --tool=memcheck --leak-check=full" |
| 58 | elif [ "$1" == "--helgrind" ] ; then |
| 59 | export VALGRIND_CMD="valgrind --tool=helgrind" |
| 60 | elif [ "$1" == "--really-run-i-know-that-it-may-mess-up-the-system" ] ; then |
| 61 | REALLY_RUN="$1" |
| 62 | else |
| 63 | echo >&2 "ERROR: Unknown option $1!" |
| 64 | exit 1 |
| 65 | fi |
| 66 | shift |
| 67 | done |
| 68 | |
| 69 | |
| 70 | # ====== Hostname check ===================================================== |
| 71 | HOSTNAME="$(hostname -s)" |
| 72 | if [ "${HOSTNAME}" != "localhost" ] && [ "${HOSTNAME}" != "dbtest" ] && [ "${HOSTNAME}" != "vbox" ] ; then |
| 73 | if [ "${REALLY_RUN}" != "--really-run-i-know-that-it-may-mess-up-the-system" ] ; then |
| 74 | echo >&2 "Hostname is not \"localhost\" or \"dbtest\". This script assumes to be run on a TEST SYSTEM only, since it replaces (i.e. erases!) existing installations of PostgreSQL, MariaDB/MySQL and MongoDB!" |
| 75 | echo >&2 "Stopping here." |
| 76 | exit 1 |
| 77 | fi |
| 78 | fi |
| 79 | |
| 80 | |
| 81 | # ====== Find template ====================================================== |
| 82 | template="$(find . -name "*-users.conf.example" | head -n1)" |
| 83 | if [ ! -e "${template}" ] ; then |
| 84 | echo >&2 "ERROR: Configuration template not found!" |
| 85 | exit |
| 86 | fi |
| 87 | echo "Template is: ${template}" |
| 88 | . "${template}" |
| 89 | if [ "${DATABASE}" == "" ] ; then |
| 90 | echo >&2 "ERROR: No database name given!" |
| 91 | exit 1 |
| 92 | fi |
| 93 | echo "Database is: ${DATABASE}" |
| 94 | USERS_CONFIG="${HOME}/${DATABASE}-users.conf" |
| 95 | echo "Users sonfiguration file is: ${USERS_CONFIG}" |
| 96 | |
| 97 | |
| 98 | # ====== Run full test ====================================================== |
| 99 | ./0-make-configurations "${template}" "${USERS_CONFIG}" "${DATABASE}" |
| 100 | |
| 101 | # Uninstall existing DBMS first: |
| 102 | ./9-uninstall-database "${DBMS}" --force-removal-without-confirmation |
| 103 | |
| 104 | # Install the DBMS and configure it: |
| 105 | ./1-install-database "${DBMS}" "${USERS_CONFIG}" |
| 106 | # Copy the CA certificate and CRL: |
| 107 | cp /etc/ssl/TestLevel1/certs/TestLevel1.crt /etc/ssl/TestGlobal.crl "${HOME}/" |
| 108 | |
| 109 | ./2-initialise-database "${DBMS}" "${USERS_CONFIG}" --force-removal-without-confirmation |
| 110 | ./3-test-database "${DBMS}" "${USERS_CONFIG}" |
| 111 | |
| 112 | # Run importer test: |
| 113 | ./4-clean-database "${DBMS}" "${USERS_CONFIG}" --force-removal-without-confirmation |
| 114 | # shellcheck disable=SC2211 |
| 115 | ./5-perform-*-importer-test "${DBMS}" "${USERS_CONFIG}" |
| 116 | ./3-test-database "${DBMS}" "${USERS_CONFIG}" |
| 117 | # shellcheck disable=SC2211 |
| 118 | ./6-perform-*-query-test "${DBMS}" "${USERS_CONFIG}" |
| 119 | |
| 120 | |
| 121 | echo -e '\x1b[42m*** TEST SUCCESSFULLY FINISHED! ***\x1b[0m' |