diff --git a/tests/plans/local.fmf b/tests/plans/local.fmf new file mode 100644 index 0000000..f193197 --- /dev/null +++ b/tests/plans/local.fmf @@ -0,0 +1,14 @@ +summary: Kdump local dumping +# Disable this plan due to https://bugzilla.redhat.com/show_bug.cgi?id=2270423 +enabled: false +discover: + how: fmf + test: + - /setup/default_crashkernel + - /setup/trigger_crash + - /tests/check_vmcore/local + +provision: + - name: client + how: virtual + connection: system diff --git a/tests/plans/main.fmf b/tests/plans/main.fmf new file mode 100644 index 0000000..16dbd83 --- /dev/null +++ b/tests/plans/main.fmf @@ -0,0 +1,34 @@ +provision: + - name: server + how: virtual + connection: system + + - name: client + how: virtual + connection: system + + +prepare: + # Set root password to log in as root in the console + - name: Set root password + how: shell + script: + - echo root:kdump | chpasswd + + - name: Use custom mirror + how: shell + script: + - test -v CUSTOM_MIRROR && sed -e 's/^metalink=/#metalink=/g' -e "s|^#baseurl=http://download.example/pub/fedora/linux|baseurl=${CUSTOM_MIRROR}|g" -i.bak /etc/yum.repos.d/fedora*.repo || true + - dnf config-manager --set-disabled fedora-cisco-openh264 || true + + - name: Install built RPM + how: install + package: + - "$KDUMP_UTILS_RPM" + where: + - client + + +execute: + how: tmt + exit-first: true diff --git a/tests/plans/nfs.fmf b/tests/plans/nfs.fmf index 2931116..0dd5f6b 100644 --- a/tests/plans/nfs.fmf +++ b/tests/plans/nfs.fmf @@ -12,6 +12,12 @@ discover: - setup/nfs_server where: - server + - name: Setup NFS client + how: fmf + test: + - setup/nfs_client + where: + - client - name: Panic kernel how: fmf test: @@ -21,39 +27,6 @@ discover: - name: Check VM Core how: fmf test: - - /tests/check_vmcore + - /tests/check_vmcore/nfs where: - server - -provision: - - name: server - how: virtual - connection: system - - - name: client - how: virtual - connection: system - -prepare: - # Set root password to log in as root in the console - - name: Set root password - how: shell - script: - - echo root:kdump | chpasswd - - - name: Use custom mirror - how: shell - script: - - test -v CUSTOM_MIRROR && sed -e 's/^metalink=/#metalink=/g' -e "s|^#baseurl=http://download.example/pub/fedora/linux|baseurl=${CUSTOM_MIRROR}|g" -i.bak /etc/yum.repos.d/fedora*.repo || true - - dnf config-manager --set-disabled fedora-cisco-openh264 || true - - - name: Install built RPM - how: install - package: - - "$KDUMP_UTILS_RPM" - where: - - client - -execute: - how: tmt - exit-first: true diff --git a/tests/setup/nfs_client/main.fmf b/tests/setup/nfs_client/main.fmf new file mode 100644 index 0000000..d65fd84 --- /dev/null +++ b/tests/setup/nfs_client/main.fmf @@ -0,0 +1,3 @@ +summary: Set up NFS dumping target +require: +- nfs-utils diff --git a/tests/setup/nfs_client/test.sh b/tests/setup/nfs_client/test.sh new file mode 100755 index 0000000..26c423f --- /dev/null +++ b/tests/setup/nfs_client/test.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +function get_IP() { + if echo $1 | grep -E -q '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then + echo $1 + else + host $1 | sed -n -e 's/.*has address //p' | head -n 1 + fi +} + +function assign_server_roles() { + if [ -n "${TMT_TOPOLOGY_BASH}" ] && [ -f ${TMT_TOPOLOGY_BASH} ]; then + # assign roles based on tmt topology data + cat ${TMT_TOPOLOGY_BASH} + . ${TMT_TOPOLOGY_BASH} + + export CLIENT=${TMT_GUESTS["client.hostname"]} + export SERVER=${TMT_GUESTS["server.hostname"]} + MY_IP="${TMT_GUEST['hostname']}" + elif [ -n "$SERVERS" ]; then + # assign roles using SERVERS and CLIENTS variables + export SERVER=$( echo "$SERVERS $CLIENTS" | awk '{ print $1 }') + export CLIENT=$( echo "$SERVERS $CLIENTS" | awk '{ print $2 }') + fi + + [ -z "$MY_IP" ] && MY_IP=$( hostname -I | awk '{ print $1 }' ) + [ -n "$SERVER" ] && export SERVER_IP=$( get_IP $SERVER ) + [ -n "$CLIENT" ] && export CLIENT_IP=$( get_IP $CLIENT ) +} + +rlJournalStart + + rlPhaseStartSetup + assign_server_roles + rlLog "SERVER: $SERVER ${SERVER_IP}" + rlLog "CLIENT: ${CLIENT} ${CLIENT}" + rlLog "This system is: $(hostname) ${MY_IP}" + rlPhaseEnd + + rlPhaseStartTest + rlRun "echo nfs $SERVER:/var/tmp/nfsshare >> /etc/kdump.conf" + rlPhaseEnd +rlJournalEnd diff --git a/tests/setup/trigger_crash/main.fmf b/tests/setup/trigger_crash/main.fmf index 6e78ed5..ac2f41f 100644 --- a/tests/setup/trigger_crash/main.fmf +++ b/tests/setup/trigger_crash/main.fmf @@ -1,3 +1 @@ -summary: Dump kernel crash to an NFS server -require: -- nfs-utils +summary: Trigger a kernel panic diff --git a/tests/setup/trigger_crash/test.sh b/tests/setup/trigger_crash/test.sh index 5fdad0b..8b23ff8 100755 --- a/tests/setup/trigger_crash/test.sh +++ b/tests/setup/trigger_crash/test.sh @@ -2,45 +2,9 @@ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k . /usr/share/beakerlib/beakerlib.sh || exit 1 -function get_IP() { - if echo $1 | grep -E -q '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+'; then - echo $1 - else - host $1 | sed -n -e 's/.*has address //p' | head -n 1 - fi -} - -function assign_server_roles() { - if [ -n "${TMT_TOPOLOGY_BASH}" ] && [ -f ${TMT_TOPOLOGY_BASH} ]; then - # assign roles based on tmt topology data - cat ${TMT_TOPOLOGY_BASH} - . ${TMT_TOPOLOGY_BASH} - - export CLIENT=${TMT_GUESTS["client.hostname"]} - export SERVER=${TMT_GUESTS["server.hostname"]} - MY_IP="${TMT_GUEST['hostname']}" - elif [ -n "$SERVERS" ]; then - # assign roles using SERVERS and CLIENTS variables - export SERVER=$( echo "$SERVERS $CLIENTS" | awk '{ print $1 }') - export CLIENT=$( echo "$SERVERS $CLIENTS" | awk '{ print $2 }') - fi - - [ -z "$MY_IP" ] && MY_IP=$( hostname -I | awk '{ print $1 }' ) - [ -n "$SERVER" ] && export SERVER_IP=$( get_IP $SERVER ) - [ -n "$CLIENT" ] && export CLIENT_IP=$( get_IP $CLIENT ) -} - rlJournalStart if [ $TMT_REBOOT_COUNT == 0 ]; then - rlPhaseStartSetup - assign_server_roles - rlLog "SERVER: $SERVER ${SERVER_IP}" - rlLog "CLIENT: ${CLIENT} ${CLIENT_IP}" - rlLog "This system is: $(hostname) ${MY_IP}" - rlRun "echo nfs ${SERVER}:/var/tmp/nfsshare >> /etc/kdump.conf" - rlPhaseEnd - rlPhaseStartTest rlRun "kdumpctl restart" || rlDie "Failed to restart kdump" rlRun "sync" diff --git a/tests/tests/check_vmcore/main.fmf b/tests/tests/check_vmcore/main.fmf index 922868b..bfcbae8 100644 --- a/tests/tests/check_vmcore/main.fmf +++ b/tests/tests/check_vmcore/main.fmf @@ -1,3 +1,11 @@ -summary: Check vmcore on NFS server +framework: shell require: - makedumpfile + +/nfs: + summary: Check vmcore on NFS server + environment: + VMCORE_PATH: /var/tmp/nfsshare/var/crash + +/local: + summary: Check vmcore locally diff --git a/tests/tests/check_vmcore/test.sh b/tests/tests/check_vmcore/test.sh index 27dfa2f..64a47c5 100755 --- a/tests/tests/check_vmcore/test.sh +++ b/tests/tests/check_vmcore/test.sh @@ -1,5 +1,4 @@ #!/bin/sh -eux - has_valid_vmcore_dir() { local path=$1 local vmcore_dir @@ -48,7 +47,9 @@ has_valid_vmcore_dir() { return 0 } -if ! has_valid_vmcore_dir "/var/tmp/nfsshare/var/crash/"; then +[[ -n $VMCORE_PATH ]] || VMCORE_PATH=/var/crash + +if ! has_valid_vmcore_dir "$VMCORE_PATH"; then echo "No Vmcore found!" 1>&2 exit 1 fi