Skip to content

Commit 240131f

Browse files
Merge pull request coreos#72 from jbtrystram/kdump-rt-test
COS-1410: test: add a kdump+kernel-rt test
2 parents 5911273 + 427c81c commit 240131f

File tree

5 files changed

+138
-0
lines changed

5 files changed

+138
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
variant: fcos
2+
version: 1.4.0
3+
kernel_arguments:
4+
should_exist:
5+
# We need to make sure we have a large enough crashkernel for FCOS
6+
# and RHCOS here. Currently the worst case output of `kdumpctl estimate`
7+
# is aarch64 RHCOS where the it says "Recommended crashkernel: 448M".
8+
# Though for some reason when we set crashkernel=448M ppc64le complains
9+
# and wants 512M so let's set it to 512M here.
10+
- crashkernel=512M
11+
systemd:
12+
units:
13+
- name: kdump.service
14+
enabled: false
15+
dropins:
16+
- name: debug.conf
17+
contents: |
18+
[Service]
19+
Environment="debug=1"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../rpm-ostree/replace-rt-kernel/data/c10s.repo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../rpm-ostree/replace-rt-kernel/data/c9s.repo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../../fedora-coreos-config/tests/kola/data/commonlib.sh
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
## kola:
3+
## tags: "needs-internet skip-base-checks"
4+
## timeoutMin: 15
5+
## # We've seen some OOM when 1024M is used in similar tests:
6+
## # https://github.com/coreos/fedora-coreos-tracker/issues/1506
7+
## minMemory: 2048
8+
## architectures: x86_64
9+
## description: Verify kdump successfuly generates vmcore even after
10+
## replacing the kernel with kernel-rt.
11+
12+
set -euo pipefail
13+
14+
. $KOLA_EXT_DATA/commonlib.sh
15+
16+
# Execute a command verbosely, i.e. echoing its arguments to stderr
17+
runv () {
18+
( set -x ; "${@}" )
19+
}
20+
21+
basearch=$(arch)
22+
23+
case "${AUTOPKGTEST_REBOOT_MARK:-}" in
24+
# first boot : install kernel-rt
25+
"")
26+
27+
# in prow there isn't any repos in the image, so we use the centos stream repos
28+
if [ -z "$(ls -A /etc/yum.repos.d/)" ]; then
29+
if match_maj_ver "9"; then
30+
repo_name=c9s.repo
31+
if [ ! -e /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official ]; then
32+
runv curl -sSLf https://centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-Official
33+
fi
34+
elif match_maj_ver "10"; then
35+
repo_name=c10s.repo
36+
if [ ! -e /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial-SHA256 ]; then
37+
runv curl -sSLf https://centos.org/keys/RPM-GPG-KEY-CentOS-Official-SHA256 -o /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial-SHA256
38+
fi
39+
else
40+
fatal "Unhandled major RHEL/SCOS VERSION"
41+
fi
42+
43+
runv cp "$KOLA_EXT_DATA/$repo_name" /etc/yum.repos.d/cs.repo
44+
fi
45+
# Enable nfv and rt repos
46+
runv sed -i '/\[nfv\]/,/^ *\[/ s/enabled=0/enabled=1/' /etc/yum.repos.d/*.repo
47+
runv sed -i '/\[rt\]/,/^ *\[/ s/enabled=0/enabled=1/' /etc/yum.repos.d/*.repo
48+
runv sed -i '/\[extras\-common\]/,/^ *\[/ s/enabled=1/enabled=0/' /etc/yum.repos.d/*.repo
49+
kernel_pkgs=("kernel-rt-core" "kernel-rt-modules" "kernel-rt-modules-extra" "kernel-rt-modules-core")
50+
args=()
51+
for x in ${kernel_pkgs}; do
52+
args+=(--install "${x}")
53+
done
54+
runv rpm-ostree override remove kernel{,-core,-modules,-modules-extra,-modules-core} "${args[@]}"
55+
# enable kdump and reboot
56+
# we don't enable kdump for the first boot to avoid building the initramfs twice
57+
systemctl enable kdump.service
58+
runv /tmp/autopkgtest-reboot 1
59+
;;
60+
# first reboot : confirm we have kernel-rt and kdump is active
61+
1)
62+
case $(uname -r) in
63+
*".${basearch}+rt") echo "ok kernel-rt" ;;
64+
*)
65+
runv uname -r
66+
runv rpm -q kernel-rt
67+
fatal "Failed to apply rt kernel override"
68+
;;
69+
esac
70+
71+
# use 240s for this since kdump can take a while to build its initramfs,
72+
# especially if the system is loaded
73+
if ! is_service_active kdump.service 240; then
74+
fatal "kdump.service failed to start"
75+
fi
76+
# Verify that the crashkernel reserved memory is large enough
77+
output=$(kdumpctl estimate)
78+
if grep -q "WARNING: Current crashkernel size is lower than recommended size" <<< "$output"; then
79+
fatal "The reserved crashkernel size is lower than recommended."
80+
fi
81+
82+
kdump_path="/var/lib/kdump/initramfs-$(uname -r)kdump.img"
83+
84+
if [[ ! -f "${kdump_path}" ]]; then
85+
fatal "kdump initrd not found at path ${kdump_path}"
86+
fi
87+
88+
/tmp/autopkgtest-reboot-prepare 2
89+
90+
# Now we can crash the kernel
91+
echo "Triggering sysrq"
92+
sync
93+
echo 1 > /proc/sys/kernel/sysrq
94+
# This one will trigger kdump, which will write the kernel core, then reboot.
95+
echo c > /proc/sysrq-trigger
96+
# We shouldn't reach this point
97+
sleep 5
98+
fatal "failed to invoke sysrq"
99+
;;
100+
# second reboot : check for the memory dump
101+
2)
102+
kcore=$(find /var/crash -type f -name vmcore)
103+
if test -z "${kcore}"; then
104+
fatal "No kcore found in /var/crash"
105+
fi
106+
info=$(file "${kcore}")
107+
if ! [[ "${info}" =~ 'vmcore: Kdump'.*'system Linux' ]]; then
108+
fatal "vmcore does not appear to be a Kdump?"
109+
fi
110+
;;
111+
*)
112+
fatal "Unhandled reboot mark ${AUTOPKGTEST_REBOOT_MARK:-}"
113+
;;
114+
esac
115+
116+
echo ok

0 commit comments

Comments
 (0)