Use compare_dbs as a wrapper to check all the used schemes. Add different formats of output to compare_dbs.pl - tap and human readable one. Process all the schemes in one run of compare_dbs.pl and do it in one db connection. If the tap formatter is used - output the result of all schemes in a single file. Change-Id: I2696680aa30b56658f130bd1cea116099c086753changes/86/37086/13
parent
21d7cbbce2
commit
43155235d7
@ -1,2 +1,4 @@
|
||||
templates/* /etc/ngcp-config/templates/etc/ngcp-system-tests/
|
||||
ngcp-system-tests /usr/bin/
|
||||
sbin/ngcp-mysql-compare-dbs /usr/sbin/
|
||||
helper/compare_dbs.pl /usr/share/ngcp-system-tests/
|
||||
|
@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
rm -rf results
|
||||
mkdir results
|
||||
|
||||
if ! [[ -r /etc/ngcp-backup-tools/db-backup.conf ]]; then
|
||||
echo "Cannot read mandatory config file /etc/ngcp-backup-tools/db-backup.conf" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
. /etc/ngcp-backup-tools/db-backup.conf
|
||||
|
||||
location="$(dirname "$0")"
|
||||
version="$(cat /etc/ngcp_version)"
|
||||
case "${version}" in
|
||||
2.8|3.*|mr[3-7].*|mr8.0.*)
|
||||
if [[ ! -r /etc/mysql/sipwise.cnf ]]; then
|
||||
echo "Cannot read mandatory config file /etc/mysql/sipwise.cnf" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
. /etc/mysql/sipwise.cnf
|
||||
for db in "${NGCP_DB_BACKUP_FINAL_LIST[@]}"; do
|
||||
"${location}/compare_dbs.pl" \
|
||||
--result="results/result_${db}.tap" \
|
||||
--connect_db1="DBI:mysql:database=${db};host=sp1" \
|
||||
--user_db1='sipwise' \
|
||||
--pass_db1="${SIPWISE_DB_PASSWORD}" \
|
||||
--connect_db2="DBI:mysql:database=${db};host=sp2" \
|
||||
--user_db2='sipwise' \
|
||||
--pass_db2="${SIPWISE_DB_PASSWORD}" \
|
||||
|| true
|
||||
done
|
||||
;;
|
||||
*)
|
||||
MYSQL_CREDENTIALS='/etc/mysql/sipwise_extra.cnf'
|
||||
if [[ ! -r "${MYSQL_CREDENTIALS}" ]]; then
|
||||
echo "Cannot read mandatory config file '${MYSQL_CREDENTIALS}'" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
for db in "${NGCP_DB_BACKUP_FINAL_LIST[@]}"; do
|
||||
"${location}/compare_dbs.pl" \
|
||||
--result="results/result_${db}.tap" \
|
||||
--connect_db1="DBI:mysql:database=${db};host=sp1;mysql_read_default_file=${MYSQL_CREDENTIALS}" \
|
||||
--connect_db2="DBI:mysql:database=${db};host=sp2;mysql_read_default_file=${MYSQL_CREDENTIALS}" \
|
||||
|| true
|
||||
done
|
||||
;;
|
||||
esac
|
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat - <<__USAGE__
|
||||
$(basename "$0") used to compare mysql schemes between two hosts.
|
||||
|
||||
Usage: $(basename "$0") [options]
|
||||
|
||||
Options:
|
||||
|
||||
--formatter=[tap] - Specify the output format.
|
||||
Skip it to get human readable output.
|
||||
|
||||
-h|--help - Show this message.
|
||||
|
||||
__USAGE__
|
||||
}
|
||||
|
||||
FORMATTER=''
|
||||
|
||||
args=$(getopt -n "$(basename "$0")" -o h -l help,formatter: -- "$@")
|
||||
eval set -- "${args}"
|
||||
while true; do
|
||||
case "${1}" in
|
||||
--formatter)
|
||||
FORMATTER="${2}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown parameter '${1}'"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
DB_BACKUP_LIST='/etc/ngcp-backup-tools/db-backup.conf'
|
||||
if [[ ! -r "${DB_BACKUP_LIST}" ]]; then
|
||||
echo "Cannot read mandatory config file ${DB_BACKUP_LIST}" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
MYSQL_CREDENTIALS='/etc/mysql/sipwise_extra.cnf'
|
||||
if [[ ! -r "${MYSQL_CREDENTIALS}" ]]; then
|
||||
echo "Cannot read mandatory config file '${MYSQL_CREDENTIALS}'" 2>&1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
. "${DB_BACKUP_LIST}"
|
||||
declare -a opts
|
||||
if [[ -n "${FORMATTER}" ]]; then
|
||||
opts+=(--formatter="${FORMATTER}")
|
||||
fi
|
||||
/usr/share/ngcp-system-tests/compare_dbs.pl \
|
||||
--schemes="${NGCP_DB_BACKUP_FINAL_LIST[*]}" \
|
||||
"${opts[@]}" || true
|
Loading…
Reference in new issue