[master 2/2] Add kickstart test for RAID1

bcl installerbot-noreply at redhat.com
Thu Jul 2 21:11:35 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

This adds a test that creates a 2 disk RAID1 and confirms that /, swap
and /boot are properly mounted. The ks uses numbered md devices to make
checking /proc/mounts easier.

The results checking depends on virt-cat ordering the /dev/mdXXX the
same every time. So far that has proven true.
---
 tests/kickstart_tests/raid-1.ks | 109 ++++++++++++++++++++++++++++++++++++++++
 tests/kickstart_tests/raid-1.sh |  49 ++++++++++++++++++
 2 files changed, 158 insertions(+)
 create mode 100644 tests/kickstart_tests/raid-1.ks
 create mode 100755 tests/kickstart_tests/raid-1.sh

diff --git a/tests/kickstart_tests/raid-1.ks b/tests/kickstart_tests/raid-1.ks
new file mode 100644
index 0000000..efcd754
--- /dev/null
+++ b/tests/kickstart_tests/raid-1.ks
@@ -0,0 +1,109 @@
+#version=DEVEL
+url --url="http://dl.fedoraproject.org/pub/fedora/linux/development/$releasever/$basearch/os/"
+install
+network --bootproto=dhcp
+
+bootloader --timeout=1
+clearpart --all --initlabel
+
+part raid.01 --size=500 --ondisk=sda --asprimary
+part raid.02 --size=500 --ondisk=sdb --asprimary
+part raid.11 --size=4000 --ondisk=sda
+part raid.12 --size=4000 --ondisk=sdb
+part raid.21 --size=1024 --ondisk=sda
+part raid.22 --size=1024 --ondisk=sdb
+
+# Yes, using 0,1,2 is wrong, but /proc/mounts uses /dev/mdX not /dev/md/X
+raid /boot --level=1 --device=0 --fstype=ext4 raid.01 raid.02
+raid swap  --level=1 --device=1 --fstype=swap raid.21 raid.22
+raid /     --level=1 --device=2 --fstype=ext4 raid.11 raid.12
+
+keyboard us
+lang en_US.UTF-8
+timezone America/New_York --utc
+rootpw testcase
+shutdown
+
+%packages
+%end
+
+%post
+# Verify the / raid level
+root_raidlevel="$(grep ^md2.*active\\sraid1 /proc/mdstat)"
+if [ -z  "$root_raidlevel" ]; then
+    echo "*** mdraid 'root' is not a RAID1" >> /root/RESULT
+fi
+
+root_md="/dev/md2"
+root_uuid="UUID=$(blkid -o value -s UUID $root_md)"
+
+# verify root md is mounted at /mnt/sysimage
+root_mount="$(grep ^$root_md\\s/\\s /proc/mounts)"
+if [ -z  "$root_mount" ]; then
+    echo "*** mdraid 'root' is not mounted at /" >> /root/RESULT
+fi
+
+root_fstype="$(echo $root_mount | cut -d' ' -f3)"
+if [ $root_fstype != "ext4" ]; then
+    echo "*** mdraid 'root' does not contain an ext4 fs" >> /root/RESULT
+fi
+
+# verify root entry in /etc/fstab is correct
+root_md_entry="$(grep ^$root_md\\s/\\s /etc/fstab)"
+root_uuid_entry="$(grep ^$root_uuid\\s/\\s /etc/fstab)"
+if [ -z "$root_md_entry" -a -z "$root_uuid_entry" ] ; then
+    echo "*** root md is not the root entry in /etc/fstab" >> /root/RESULT
+fi
+
+# Verify the swap raid level
+swap_raidlevel="$(grep ^md1.*active\\sraid1 /proc/mdstat)"
+if [ -z  "$swap_raidlevel" ]; then
+    echo "*** mdraid 'swap' is not a RAID1" >> /root/RESULT
+fi
+
+# verify swap on md is active
+swap_md="/dev/md1"
+swap_uuid="UUID=$(blkid -o value -s UUID $swap_md)"
+if ! grep -q $swap_md /proc/swaps ; then
+    echo "*** mdraid 'swap' is not active as swap space" >> /root/RESULT
+fi
+
+# verify swap entry in /etc/fstab is correct
+swap_md_entry="$(grep ^$swap_md\\sswap\\s /etc/fstab)"
+swap_uuid_entry="$(grep ^$swap_uuid\\sswap\\s /etc/fstab)"
+if [ -z "$swap_md_entry" -a -z "$swap_uuid_entry" ] ; then
+    echo "*** swap md is not in /etc/fstab" >> /root/RESULT
+fi
+
+# Verify the boot raid level
+boot_raidlevel="$(grep ^md0.*active\\sraid1 /proc/mdstat)"
+if [ -z  "$boot_raidlevel" ]; then
+    echo "*** mdraid 'boot' is not a RAID1" >> /root/RESULT
+fi
+
+boot_md="/dev/md0"
+boot_uuid="UUID=$(blkid -o value -s UUID $boot_md)"
+
+# verify boot md is mounted at /mnt/sysimage/boot
+boot_mount="$(grep ^$boot_md\\s/boot\\s /proc/mounts)"
+if [ -z "$boot_mount" ]; then
+    echo "*** mdraid 'boot' is not mounted at /boot" >> /root/RESULT
+fi
+
+boot_fstype="$(echo $boot_mount | cut -d' ' -f3)"
+if [ $boot_fstype != "ext4" ]; then
+    echo "*** mdraid 'boot' does not contain an ext4 fs" >> /root/RESULT
+fi
+
+# verify boot entry in /etc/fstab is correct
+boot_md_entry="$(grep ^$boot_md\\s/boot\\s /etc/fstab)"
+boot_uuid_entry="$(grep ^$boot_uuid\\s/boot\\s /etc/fstab)"
+if [ -z "$boot_md_entry" -a -z "$boot_uuid_entry" ] ; then
+    echo "*** boot md is not the root entry in /etc/fstab" >> /root/RESULT
+fi
+
+if [ ! -e /root/RESULT ]; then
+    echo SUCCESS > /root/RESULT
+fi
+sleep 9999999999999
+%end
diff --git a/tests/kickstart_tests/raid-1.sh b/tests/kickstart_tests/raid-1.sh
new file mode 100755
index 0000000..4ed81ed
--- /dev/null
+++ b/tests/kickstart_tests/raid-1.sh
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2015  Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.  You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): Chris Lumens <clumens at redhat.com>
+
+. ${KSTESTDIR}/functions.sh
+
+prepare_disks() {
+    tmpdir=$1
+
+    qemu-img create -q -f qcow2 ${tmpdir}/disks/a.img 10G
+    qemu-img create -q -f qcow2 ${tmpdir}/disks/b.img 10G
+    echo ${tmpdir}/disks/a.img ${tmpdir}/disks/b.img
+}
+
+validate() {
+    disksdir=$1
+    args=$(for d in ${disksdir}/*img; do echo -a ${d}; done)
+
+    # virt-cat doesn't setup /dev/md/* links so cross our fingers that
+    # / always ends up on /dev/md126
+    # There should be a /root/RESULT file with results in it.  Check
+    # its contents and decide whether the test finally succeeded or
+    # not.
+    result=$(virt-cat ${args} -m /dev/md126 /root/RESULT)
+    if [[ $? != 0 ]]; then
+        status=1
+        echo '*** /root/RESULT does not exist in VM image.'
+    elif [[ "${result}" != SUCCESS* ]]; then
+        status=1
+        echo "${result}"
+    fi
+
+    return ${status}
+}


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/1b549f238b65de298e6e4368b5cfa3ac3b1a4119


More information about the anaconda-patches mailing list