Skip to content

Commit

Permalink
Add local dumping test plan
Browse files Browse the repository at this point in the history
For local vmcore dumping, we only need to trigger a kernel crash and
check if vmcore exists and it can re-use some setups and tests from NFS
dumping.

Note
1. plans/main.fmf is created for NFS and local dumping test plans to
   inherit .
2. Virtual tests [1] are created so local dumping can re-use the code of
   checking vmcore on an NFS server
3. The local test is disabled for now due to [2]
4. exit-first=true [3] is to make the executor stop executing tests once
   a test failure is encountered. But TMT currently has the problem of
   exit-first not applying across discover phase boundaries [4]. So for local
   dumping test plan, simply remove multiple discover phases [5].

[1] https://tmt.readthedocs.io/en/stable/guide.html#virtual-tests
[2] https://bugzilla.redhat.com/show_bug.cgi?id=2270423
[3] https://tmt.readthedocs.io/en/stable/spec/plans.html#exit-first
[4] teemtee/tmt#3116
[5] https://tmt.readthedocs.io/en/stable/guide.html#multihost-testing

Signed-off-by: Coiby Xu <[email protected]>
  • Loading branch information
coiby committed Jul 30, 2024
1 parent e94478b commit 17f2eb4
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 76 deletions.
14 changes: 14 additions & 0 deletions tests/plans/local.fmf
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions tests/plans/main.fmf
Original file line number Diff line number Diff line change
@@ -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
41 changes: 7 additions & 34 deletions tests/plans/nfs.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
3 changes: 3 additions & 0 deletions tests/setup/nfs_client/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
summary: Set up NFS dumping target
require:
- nfs-utils
45 changes: 45 additions & 0 deletions tests/setup/nfs_client/test.sh
Original file line number Diff line number Diff line change
@@ -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
4 changes: 1 addition & 3 deletions tests/setup/trigger_crash/main.fmf
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
summary: Dump kernel crash to an NFS server
require:
- nfs-utils
summary: Trigger a kernel panic
36 changes: 0 additions & 36 deletions tests/setup/trigger_crash/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 9 additions & 1 deletion tests/tests/check_vmcore/main.fmf
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions tests/tests/check_vmcore/test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/sh -eux

has_valid_vmcore_dir() {
local path=$1
local vmcore_dir
Expand Down Expand Up @@ -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

0 comments on commit 17f2eb4

Please sign in to comment.