From: zzou zzou@redhat.com
In order to test the different kdump.config options and different test cases ,so we create a autotest framework.By runing test.sh ,the test cases can run one by one automatically. For more infomation ,please refer to the readme.
Signed-off-by: arthur zzou@redhat.com --- kdump_auto_test/TEST-01_BASIC/autokdump.service | 14 ++++++ kdump_auto_test/TEST-01_BASIC/autorun.sh | 33 ++++++++++++++ kdump_auto_test/TEST-01_BASIC/inst.sh | 16 +++++++ kdump_auto_test/TEST-01_BASIC/ks.cfg | 50 +++++++++++++++++++++ kdump_auto_test/TEST-01_BASIC/modify.sh | 10 +++++ kdump_auto_test/TEST-01_BASIC/prekdump.service | 14 ++++++ kdump_auto_test/TEST-01_BASIC/test.sh | 59 +++++++++++++++++++++++++ kdump_auto_test/readme | 18 ++++++++ kdump_auto_test/test.sh | 15 +++++++ 9 files changed, 229 insertions(+) create mode 100644 kdump_auto_test/TEST-01_BASIC/autokdump.service create mode 100755 kdump_auto_test/TEST-01_BASIC/autorun.sh create mode 100755 kdump_auto_test/TEST-01_BASIC/inst.sh create mode 100755 kdump_auto_test/TEST-01_BASIC/ks.cfg create mode 100755 kdump_auto_test/TEST-01_BASIC/modify.sh create mode 100644 kdump_auto_test/TEST-01_BASIC/prekdump.service create mode 100755 kdump_auto_test/TEST-01_BASIC/test.sh create mode 100755 kdump_auto_test/readme create mode 100755 kdump_auto_test/test.sh
diff --git a/kdump_auto_test/TEST-01_BASIC/autokdump.service b/kdump_auto_test/TEST-01_BASIC/autokdump.service new file mode 100644 index 0000000..e6ff786 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/autokdump.service @@ -0,0 +1,14 @@ +[Unit] +Description=auto crash after kdump +After=kdump.service + +[Service] +Type=oneshot +ExecStart=/mnt/autorun.sh -autotest +RemainAfterExit=yes +StandardOutput=tty +TTYPath=/dev/ttyS0 + +[Install] +WantedBy=multi-user.target + diff --git a/kdump_auto_test/TEST-01_BASIC/autorun.sh b/kdump_auto_test/TEST-01_BASIC/autorun.sh new file mode 100755 index 0000000..7aedbe9 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/autorun.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +setup() +{ + systemctl | grep kdump + echo *********************************************autorun.sh +} +autotest() +{ + if [[ `ls -A /var/crash` = "" ]] + then + echo trigger >>/mnt/log + echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + sync + echo c > /proc/sysrq-trigger + else + mv -f /var/crash /mnt + #rm -rf /var/crash/* + echo successed>>/mnt/log + systemctl poweroff + fi +} + + +case $1 in + -setup) + setup + ;; + -autotest) + autotest + ;; +esac + diff --git a/kdump_auto_test/TEST-01_BASIC/inst.sh b/kdump_auto_test/TEST-01_BASIC/inst.sh new file mode 100755 index 0000000..dbaa038 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/inst.sh @@ -0,0 +1,16 @@ +#!/bin/bash +domname=Fedora +dir=`dirname $0` +virt-install \ + --debug \ + --extra-args="console=tty0 console=ttyS0,115200 ks=file:/ks.cfg" \ + --name=$domname \ + --disk path=$dir/Fedora-19.img,size=20,cache=none \ + --disk path=$dir/Fedora-19-extra.img,size=1,cache=none \ + --ram 2048 \ + --vcpus=2 \ + --hvm \ + --location=http://download.englab.nay.redhat.com/pub/fedora/linux/releases/19/Fedora/x8... \ + --nographics \ + --force \ + --initrd-inject=$dir/ks.cfg diff --git a/kdump_auto_test/TEST-01_BASIC/ks.cfg b/kdump_auto_test/TEST-01_BASIC/ks.cfg new file mode 100755 index 0000000..c166b9f --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/ks.cfg @@ -0,0 +1,50 @@ +#version=DEVEL +# System authorization information +auth --enableshadow --passalgo=sha512 + +# Use network installation +url --url="http://download.englab.nay.redhat.com/pub/fedora/linux/releases/19/Fedora/x8..." +# Run the Setup Agent on first boot +firstboot --enable +ignoredisk --only-use=vda +# Keyboard layouts +keyboard --vckeymap=us --xlayouts='us' +# System language +lang en_US.UTF-8 + +# Network information +network --hostname=localhost.localdomain +# Root password +rootpw --iscrypted $6$PmkDe6Zv0qko0zLL$zuXIvzy7g.hh7mX5weGyngpthVvpEXMr2sQEsaBF86ilmIsr.krTbqlozx1JowUxwf6LUPA9R1j3paUfygrqQ. +# System timezone +timezone Etc/GMT --isUtc +# X Window System configuration information +xconfig --startxonboot +# System bootloader configuration +bootloader --location=mbr --boot-drive=vda +autopart --type=lvm +# Partition clearing information +clearpart --all --initlabel --drives=vda + + +%post +mount -t ext3 /dev/vdb /mnt +/mnt/modify.sh +echo 'helloooo' > /log.txt +%end + +%packages +@base-x +@core +@dial-up +@firefox +@fonts +@gnome-desktop +@guest-desktop-agents +@hardware-support +@input-methods +@multimedia +@printing +@standard +%end +reboot diff --git a/kdump_auto_test/TEST-01_BASIC/modify.sh b/kdump_auto_test/TEST-01_BASIC/modify.sh new file mode 100755 index 0000000..dbb8de9 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/modify.sh @@ -0,0 +1,10 @@ +#!/bin/bash +echo "/dev/vdb /mnt ext3 defaults 1 2" >> /etc/fstab +grubby --args="crashkernel=128M" --update-kernel=/boot/vmlinuz-`uname -r` +yum -y install kexec-tools +cp /mnt/prekdump.service /lib/systemd/system +cp /mnt/autokdump.service /lib/systemd/system + +systemctl enable kdump.service +systemctl enable prekdump.service +systemctl enable autokdump.service diff --git a/kdump_auto_test/TEST-01_BASIC/prekdump.service b/kdump_auto_test/TEST-01_BASIC/prekdump.service new file mode 100644 index 0000000..7fdc0cf --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/prekdump.service @@ -0,0 +1,14 @@ +[Unit] +Description=set kdump enviroment +Before=kdump.service +After=network.target + +[Service] +Type=oneshot +ExecStart=/mnt/autorun.sh -setup +RemainAfterExit=yes +StandardOutput=tty +TTYPath=/dev/ttyS0 + +[Install] +WantedBy=multi-user.target diff --git a/kdump_auto_test/TEST-01_BASIC/test.sh b/kdump_auto_test/TEST-01_BASIC/test.sh new file mode 100755 index 0000000..2d91f8d --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/test.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +#!/bin/bash +check_root() { + if (( $EUID != 0 )); then + echo "Tests must be run as root! Please use 'sudo'." + exit 1 + fi +} + +check_root + +dir=`dirname $0` +echo this is test for basic kdump auto test! + +exec 1>$dir/log +exec 2>$dir/log.error + +qemu-img create $dir/Fedora-19-extra.img 1G +yes | mkfs.ext3 $dir/Fedora-19-extra.img +chmod 777 $dir/Fedora-19-extra.img + +mount -o loop $dir/Fedora-19-extra.img /mnt +cp $dir/modify.sh /mnt +cp $dir/autokdump.service /mnt +cp $dir/prekdump.service /mnt +cp $dir/autorun.sh /mnt +cp $dir/test.sh /mnt +umount /mnt + +$dir/inst.sh + +mount -o loop $dir/Fedora-19-extra.img /mnt + +cat /mnt/log | grep successed +if [[ $? = 0 ]] +then +result=ok +rm -f $dir/Fedora-19.img +rm -f $dir/Fedora-19-extra.img +rm -f $dir/log +rm -f $dir/log.error +virsh shutdown Fedora +virsh undefine Fedora +else +result=failure +virsh shutdown Fedora +virsh undefine Fedora +fi +umount /mnt + +exec 1>&0 +exec 2>&0 +if [[ $result = "ok" ]] +then +echo OK! +else +echo FAILURE +fi diff --git a/kdump_auto_test/readme b/kdump_auto_test/readme new file mode 100755 index 0000000..87b2fa6 --- /dev/null +++ b/kdump_auto_test/readme @@ -0,0 +1,18 @@ + Using kdump auto test by run test.sh. It will invoke every test.sh in subdiredtory. + For a typical test case. There must be a autotest.sh, a modify.sh ,a test.sh and two services, +One is prekdump.service,anther is autokdmup.service + test.sh run in the host .It's the controller of a test case + modify.sh and autorun.sh and other essential file will be copy to vdb and mount at /mnt in guest. + modify.sh runs at the end of installation.It's role is to modify the original system +to make that suitable for our test case. For example ,it will install kexec-tools in qemu ,append +crashkernel=128M in the boot parameter for the qemu ,mount vdb at /mnt automatically ,enable prekdump.service +and autokdump.service and so on. + + autorun.sh runs at the system boot up .While the system has been installed and modified +unattendly by kickstart,System will reboot automatically.Beacuse vdb has mounted at /mnt and prekdump.service +and autokdump.service has enabled . prekdump.service will call /mnt/autorun.sh -setup,so the function in +autorun.sh will be executed , we use this to do something before we start kdump.service. After prekdump.servece +and kdump.service has started ,autokdump.service start ,it will call /mnt/autorun.sh -autotest,so the +funtion in autorun.sh will be executed.What it must do is Crash running kernel by echo c > /proc/sysrq-trigger. + + diff --git a/kdump_auto_test/test.sh b/kdump_auto_test/test.sh new file mode 100755 index 0000000..005fb6d --- /dev/null +++ b/kdump_auto_test/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +check_root() { + if (( $EUID != 0 )); then + echo "Tests must be run as root! Please use 'sudo'." + exit 1 + fi +} + + +check_root +dir=`dirname $0` +for i in $dir/TEST-* +do + $i/test.sh; +done
On 10/11/13 at 05:13pm, Zhi Zou wrote:
From: zzou zzou@redhat.com
In order to test the different kdump.config options and different test cases ,so we create a autotest framework.By runing test.sh ,the test cases can run one by one automatically. For more infomation ,please refer to the readme.
Signed-off-by: arthur zzou@redhat.com
I got following warning when applying the patch:
# git am ~/Mail/zzou/cur/* Applying: autotest framework /home/chaowang/development/src/kexec-tools/.git/rebase-apply/patch:231: trailing whitespace. $dir/inst.sh /home/chaowang/development/src/kexec-tools/.git/rebase-apply/patch:272: trailing whitespace. to make that suitable for our test case. For example ,it will install kexec-tools in qemu ,append /home/chaowang/development/src/kexec-tools/.git/rebase-apply/patch:276: trailing whitespace. autorun.sh runs at the system boot up .While the system has been installed and modified /home/chaowang/development/src/kexec-tools/.git/rebase-apply/patch:280: trailing whitespace. and kdump.service has started ,autokdump.service start ,it will call /mnt/autorun.sh -autotest,so the /home/chaowang/development/src/kexec-tools/.git/rebase-apply/patch:283: trailing whitespace.
warning: squelched 3 whitespace errors warning: 8 lines add whitespace errors.
But the good news is despite the warings, the test works on my workstation:
# sudo ./test.sh this is test for basic kdump auto test! OK!
The readme is really needed to re-organize. If you really want to put all the details here, you need to write down section by section. Maybe you can start with how to run this test, and describe the internal stuff later.
Thanks WANG Chao
kdump_auto_test/TEST-01_BASIC/autokdump.service | 14 ++++++ kdump_auto_test/TEST-01_BASIC/autorun.sh | 33 ++++++++++++++ kdump_auto_test/TEST-01_BASIC/inst.sh | 16 +++++++ kdump_auto_test/TEST-01_BASIC/ks.cfg | 50 +++++++++++++++++++++ kdump_auto_test/TEST-01_BASIC/modify.sh | 10 +++++ kdump_auto_test/TEST-01_BASIC/prekdump.service | 14 ++++++ kdump_auto_test/TEST-01_BASIC/test.sh | 59 +++++++++++++++++++++++++ kdump_auto_test/readme | 18 ++++++++ kdump_auto_test/test.sh | 15 +++++++ 9 files changed, 229 insertions(+) create mode 100644 kdump_auto_test/TEST-01_BASIC/autokdump.service create mode 100755 kdump_auto_test/TEST-01_BASIC/autorun.sh create mode 100755 kdump_auto_test/TEST-01_BASIC/inst.sh create mode 100755 kdump_auto_test/TEST-01_BASIC/ks.cfg create mode 100755 kdump_auto_test/TEST-01_BASIC/modify.sh create mode 100644 kdump_auto_test/TEST-01_BASIC/prekdump.service create mode 100755 kdump_auto_test/TEST-01_BASIC/test.sh create mode 100755 kdump_auto_test/readme create mode 100755 kdump_auto_test/test.sh
diff --git a/kdump_auto_test/TEST-01_BASIC/autokdump.service b/kdump_auto_test/TEST-01_BASIC/autokdump.service new file mode 100644 index 0000000..e6ff786 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/autokdump.service @@ -0,0 +1,14 @@ +[Unit] +Description=auto crash after kdump +After=kdump.service
+[Service] +Type=oneshot +ExecStart=/mnt/autorun.sh -autotest +RemainAfterExit=yes +StandardOutput=tty +TTYPath=/dev/ttyS0
+[Install] +WantedBy=multi-user.target
diff --git a/kdump_auto_test/TEST-01_BASIC/autorun.sh b/kdump_auto_test/TEST-01_BASIC/autorun.sh new file mode 100755 index 0000000..7aedbe9 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/autorun.sh @@ -0,0 +1,33 @@ +#!/bin/bash
+setup() +{
- systemctl | grep kdump
- echo *********************************************autorun.sh
+} +autotest() +{
- if [[ `ls -A /var/crash` = "" ]]
- then
echo trigger >>/mnt/logecho xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxsyncecho c > /proc/sysrq-trigger- else
mv -f /var/crash /mnt#rm -rf /var/crash/*echo successed>>/mnt/logsystemctl powerofffi+}
+case $1 in
- -setup)
setup;;- -autotest)
autotest;;+esac
diff --git a/kdump_auto_test/TEST-01_BASIC/inst.sh b/kdump_auto_test/TEST-01_BASIC/inst.sh new file mode 100755 index 0000000..dbaa038 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/inst.sh @@ -0,0 +1,16 @@ +#!/bin/bash +domname=Fedora +dir=`dirname $0` +virt-install \
- --debug \
- --extra-args="console=tty0 console=ttyS0,115200 ks=file:/ks.cfg" \
- --name=$domname \
- --disk path=$dir/Fedora-19.img,size=20,cache=none \
- --disk path=$dir/Fedora-19-extra.img,size=1,cache=none \
- --ram 2048 \
- --vcpus=2 \
- --hvm \
- --location=http://download.englab.nay.redhat.com/pub/fedora/linux/releases/19/Fedora/x8... \
- --nographics \
- --force \
- --initrd-inject=$dir/ks.cfg
diff --git a/kdump_auto_test/TEST-01_BASIC/ks.cfg b/kdump_auto_test/TEST-01_BASIC/ks.cfg new file mode 100755 index 0000000..c166b9f --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/ks.cfg @@ -0,0 +1,50 @@ +#version=DEVEL +# System authorization information +auth --enableshadow --passalgo=sha512
+# Use network installation +url --url="http://download.englab.nay.redhat.com/pub/fedora/linux/releases/19/Fedora/x8..." +# Run the Setup Agent on first boot +firstboot --enable +ignoredisk --only-use=vda +# Keyboard layouts +keyboard --vckeymap=us --xlayouts='us' +# System language +lang en_US.UTF-8
+# Network information +network --hostname=localhost.localdomain +# Root password +rootpw --iscrypted $6$PmkDe6Zv0qko0zLL$zuXIvzy7g.hh7mX5weGyngpthVvpEXMr2sQEsaBF86ilmIsr.krTbqlozx1JowUxwf6LUPA9R1j3paUfygrqQ. +# System timezone +timezone Etc/GMT --isUtc +# X Window System configuration information +xconfig --startxonboot +# System bootloader configuration +bootloader --location=mbr --boot-drive=vda +autopart --type=lvm +# Partition clearing information +clearpart --all --initlabel --drives=vda
+%post +mount -t ext3 /dev/vdb /mnt +/mnt/modify.sh +echo 'helloooo' > /log.txt +%end
+%packages +@base-x +@core +@dial-up +@firefox +@fonts +@gnome-desktop +@guest-desktop-agents +@hardware-support +@input-methods +@multimedia +@printing +@standard +%end +reboot diff --git a/kdump_auto_test/TEST-01_BASIC/modify.sh b/kdump_auto_test/TEST-01_BASIC/modify.sh new file mode 100755 index 0000000..dbb8de9 --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/modify.sh @@ -0,0 +1,10 @@ +#!/bin/bash +echo "/dev/vdb /mnt ext3 defaults 1 2" >> /etc/fstab +grubby --args="crashkernel=128M" --update-kernel=/boot/vmlinuz-`uname -r` +yum -y install kexec-tools +cp /mnt/prekdump.service /lib/systemd/system +cp /mnt/autokdump.service /lib/systemd/system
+systemctl enable kdump.service +systemctl enable prekdump.service +systemctl enable autokdump.service diff --git a/kdump_auto_test/TEST-01_BASIC/prekdump.service b/kdump_auto_test/TEST-01_BASIC/prekdump.service new file mode 100644 index 0000000..7fdc0cf --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/prekdump.service @@ -0,0 +1,14 @@ +[Unit] +Description=set kdump enviroment +Before=kdump.service +After=network.target
+[Service] +Type=oneshot +ExecStart=/mnt/autorun.sh -setup +RemainAfterExit=yes +StandardOutput=tty +TTYPath=/dev/ttyS0
+[Install] +WantedBy=multi-user.target diff --git a/kdump_auto_test/TEST-01_BASIC/test.sh b/kdump_auto_test/TEST-01_BASIC/test.sh new file mode 100755 index 0000000..2d91f8d --- /dev/null +++ b/kdump_auto_test/TEST-01_BASIC/test.sh @@ -0,0 +1,59 @@ +#!/bin/bash
+#!/bin/bash +check_root() {
- if (( $EUID != 0 )); then
echo "Tests must be run as root! Please use 'sudo'."exit 1- fi
+}
+check_root
+dir=`dirname $0` +echo this is test for basic kdump auto test!
+exec 1>$dir/log +exec 2>$dir/log.error
+qemu-img create $dir/Fedora-19-extra.img 1G +yes | mkfs.ext3 $dir/Fedora-19-extra.img +chmod 777 $dir/Fedora-19-extra.img
+mount -o loop $dir/Fedora-19-extra.img /mnt +cp $dir/modify.sh /mnt +cp $dir/autokdump.service /mnt +cp $dir/prekdump.service /mnt +cp $dir/autorun.sh /mnt +cp $dir/test.sh /mnt +umount /mnt
+$dir/inst.sh
+mount -o loop $dir/Fedora-19-extra.img /mnt
+cat /mnt/log | grep successed +if [[ $? = 0 ]] +then +result=ok +rm -f $dir/Fedora-19.img +rm -f $dir/Fedora-19-extra.img +rm -f $dir/log +rm -f $dir/log.error +virsh shutdown Fedora +virsh undefine Fedora +else +result=failure +virsh shutdown Fedora +virsh undefine Fedora +fi +umount /mnt
+exec 1>&0 +exec 2>&0 +if [[ $result = "ok" ]] +then +echo OK! +else +echo FAILURE +fi diff --git a/kdump_auto_test/readme b/kdump_auto_test/readme new file mode 100755 index 0000000..87b2fa6 --- /dev/null +++ b/kdump_auto_test/readme @@ -0,0 +1,18 @@
- Using kdump auto test by run test.sh. It will invoke every test.sh in subdiredtory.
- For a typical test case. There must be a autotest.sh, a modify.sh ,a test.sh and two services,
+One is prekdump.service,anther is autokdmup.service
- test.sh run in the host .It's the controller of a test case
- modify.sh and autorun.sh and other essential file will be copy to vdb and mount at /mnt in guest.
- modify.sh runs at the end of installation.It's role is to modify the original system
+to make that suitable for our test case. For example ,it will install kexec-tools in qemu ,append +crashkernel=128M in the boot parameter for the qemu ,mount vdb at /mnt automatically ,enable prekdump.service +and autokdump.service and so on.
- autorun.sh runs at the system boot up .While the system has been installed and modified
+unattendly by kickstart,System will reboot automatically.Beacuse vdb has mounted at /mnt and prekdump.service +and autokdump.service has enabled . prekdump.service will call /mnt/autorun.sh -setup,so the function in +autorun.sh will be executed , we use this to do something before we start kdump.service. After prekdump.servece +and kdump.service has started ,autokdump.service start ,it will call /mnt/autorun.sh -autotest,so the +funtion in autorun.sh will be executed.What it must do is Crash running kernel by echo c > /proc/sysrq-trigger.
diff --git a/kdump_auto_test/test.sh b/kdump_auto_test/test.sh new file mode 100755 index 0000000..005fb6d --- /dev/null +++ b/kdump_auto_test/test.sh @@ -0,0 +1,15 @@ +#!/bin/bash +check_root() {
- if (( $EUID != 0 )); then
echo "Tests must be run as root! Please use 'sudo'."exit 1- fi
+}
+check_root +dir=`dirname $0` +for i in $dir/TEST-* +do
$i/test.sh;+done
1.8.3.1
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec