Skip to content

Commit bbb5955

Browse files
grooverdanRazvanLiviuVarzaru
authored andcommitted
MDBF-1130 Collect selinux, pam and systemd logs on test failure
1 parent 1217187 commit bbb5955

File tree

6 files changed

+30
-1
lines changed

6 files changed

+30
-1
lines changed

scripts/bash_lib.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,25 @@ err() {
4040
exit 1
4141
}
4242

43+
collect_logs() {
44+
exit_code=$?
45+
if [[ $exit_code -ne 0 ]]; then
46+
set +e
47+
bb_log_info "systemd service information"
48+
sudo journalctl --boot --unit mariadb.service mariadb-columnstore.service
49+
if [ -f /etc/selinux/config ]; then
50+
bb_log_info "selinux denial information"
51+
sudo ausearch -i -m avc,user_avc,selinux_err,user_selinux_err -ts boot
52+
fi
53+
bb_log_info "PAM information"
54+
sudo grep -i pam /var/log/secure /var/log/auth.log
55+
set -e
56+
else
57+
bb_log_info "Test(s) ran successfully"
58+
fi
59+
exit $exit_code
60+
}
61+
4362
# mariadb < 10.4 the client binary was mysql
4463
# needed in distro upgrade tests. Remove after rhel7, rocky/alma/rhel 8 are no longer supported
4564
get_db_client() {

scripts/deb-install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ set -e
1111
# shellcheck disable=SC1091
1212
. ./bash_lib.sh
1313

14+
trap 'collect_logs' EXIT
15+
1416
# load OS variables
1517
# shellcheck disable=SC1091
1618
. /etc/os-release

scripts/deb-upgrade.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ set -e
1111
# shellcheck disable=SC1091
1212
. ./bash_lib.sh
1313

14+
trap 'collect_logs' EXIT
15+
1416
# function to be able to run the script manually (see bash_lib.sh)
1517
manual_run_switch "$1"
1618

scripts/pam-test.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ set -e
66
# shellcheck disable=SC1091
77
. ./bash_lib.sh
88

9+
trap 'collect_logs' EXIT
10+
911
bb_print_env
1012

1113
control_mariadb_server restart
@@ -97,4 +99,4 @@ fi
9799
set +e
98100
if ((res != 0)); then
99101
exit $res
100-
fi
102+
fi

scripts/rpm-install.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ set -e
1111
# shellcheck disable=SC1091
1212
. ./bash_lib.sh
1313

14+
trap 'collect_logs' EXIT
15+
1416
# yum/dnf switch
1517
pkg_cmd=$(rpm_pkg)
1618

scripts/rpm-upgrade.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ set -e
1111
# shellcheck disable=SC1091
1212
. ./bash_lib.sh
1313

14+
trap 'collect_logs' EXIT
15+
1416
# function to be able to run the script manually (see bash_lib.sh)
1517
manual_run_switch "$1"
1618

0 commit comments

Comments
 (0)