From a99554ab24fb05b3acb5fadd5f9916e6a1ca49a5 Mon Sep 17 00:00:00 2001 From: Aron Xu Date: Mon, 25 Apr 2016 21:09:12 +0800 Subject: [PATCH] Adding smoke testing scripts from Ubuntu --- debian/tests/control | 3 + debian/tests/kernel-smoke-test | 48 +++++++ debian/tests/kernel-smoke-test-clone | 96 ++++++++++++++ debian/tests/kernel-smoke-test-filesystem | 99 ++++++++++++++ .../tests/kernel-smoke-test-pool-2x2-mirror | 55 ++++++++ .../tests/kernel-smoke-test-pool-4x1-mirror | 55 ++++++++ .../kernel-smoke-test-pool-nested-raidz3 | 63 +++++++++ debian/tests/kernel-smoke-test-pool-raidz1 | 55 ++++++++ debian/tests/kernel-smoke-test-pool-raidz2 | 55 ++++++++ debian/tests/kernel-smoke-test-pool-raidz3 | 55 ++++++++ debian/tests/kernel-smoke-test-pool-striped | 55 ++++++++ debian/tests/kernel-smoke-test-scrub | 114 +++++++++++++++++ debian/tests/kernel-smoke-test-send-receive | 109 ++++++++++++++++ debian/tests/kernel-smoke-test-snapshot | 121 ++++++++++++++++++ debian/tests/kernel-smoke-test-zil | 76 +++++++++++ 15 files changed, 1059 insertions(+) create mode 100644 debian/tests/control create mode 100755 debian/tests/kernel-smoke-test create mode 100755 debian/tests/kernel-smoke-test-clone create mode 100755 debian/tests/kernel-smoke-test-filesystem create mode 100755 debian/tests/kernel-smoke-test-pool-2x2-mirror create mode 100755 debian/tests/kernel-smoke-test-pool-4x1-mirror create mode 100755 debian/tests/kernel-smoke-test-pool-nested-raidz3 create mode 100755 debian/tests/kernel-smoke-test-pool-raidz1 create mode 100755 debian/tests/kernel-smoke-test-pool-raidz2 create mode 100755 debian/tests/kernel-smoke-test-pool-raidz3 create mode 100755 debian/tests/kernel-smoke-test-pool-striped create mode 100755 debian/tests/kernel-smoke-test-scrub create mode 100755 debian/tests/kernel-smoke-test-send-receive create mode 100755 debian/tests/kernel-smoke-test-snapshot create mode 100755 debian/tests/kernel-smoke-test-zil diff --git a/debian/tests/control b/debian/tests/control new file mode 100644 index 00000000..f0197e68 --- /dev/null +++ b/debian/tests/control @@ -0,0 +1,3 @@ +Tests: kernel-smoke-test +Restrictions: needs-root +Depends: @ diff --git a/debian/tests/kernel-smoke-test b/debian/tests/kernel-smoke-test new file mode 100755 index 00000000..8edf18f8 --- /dev/null +++ b/debian/tests/kernel-smoke-test @@ -0,0 +1,48 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +# +# We run all the tests in this specific order from this +# main script so that we don't have to go through the +# pain of checking and rebuilding installing and removing +# the modules for each test. A good smoke test will +# exercise all the base functionality with the same +# instance of the ZFS spl and zfs drivers to see what +# the cumulative testing of each scenario does to the +# environment. +# +TESTS="kernel-smoke-test-pool-2x2-mirror kernel-smoke-test-pool-4x1-mirror kernel-smoke-test-pool-nested-raidz3 kernel-smoke-test-pool-raidz1 kernel-smoke-test-pool-raidz2 kernel-smoke-test-pool-raidz3 kernel-smoke-test-pool-striped kernel-smoke-test-zil kernel-smoke-test-filesystem kernel-smoke-test-snapshot kernel-smoke-test-clone kernel-smoke-test-send-receive kernel-smoke-test-scrub" +rc=0 +# +# We only test on 64 bit arches for the moment +# as these are the ones that ZFS supports. +# +if [ `getconf LONG_BIT` = "32" ] +then + echo "Testing on 32 bit architectures not possible." + exit 0 +fi + +for t in ${TESTS} +do + ./debian/tests/$t + if [ $? -ne 0 ]; then + rc=1 + fi +done +exit $rc diff --git a/debian/tests/kernel-smoke-test-clone b/debian/tests/kernel-smoke-test-clone new file mode 100755 index 00000000..eaa2c239 --- /dev/null +++ b/debian/tests/kernel-smoke-test-clone @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, ZFS clone: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +POOL=pool-smoke-$$ +DATA=/${POOL}/test/data +DATA_CLONE=/${POOL}/test-clone/data + +dd if=/dev/zero of=${VDEV0} bs=1M count=128 > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=128 > /dev/null 2>&1 + +zpool create ${POOL} ${VDEV0} ${VDEV1} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zfs create ${POOL}/test +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs create failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Populate with files.. +# +cp -rp /etc /${POOL}/test +dd if=/dev/urandom of=${DATA} bs=1M count=64 > /dev/null 2>&1 +sum1=$(md5sum ${DATA} | awk '{print $1}') + +# +# Make a snapshot +# +zfs snapshot -r ${POOL}/test@snap +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs snapshot failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Clone +# +zfs clone ${POOL}/test@snap ${POOL}/test-clone + +# +# Checksums must agree +# +sum2=$(md5sum ${DATA_CLONE} | awk '{print $1}') +if [ x"$sum1" != x"$sum2" ]; then + echo "FAILED: cloned data different from original" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-filesystem b/debian/tests/kernel-smoke-test-filesystem new file mode 100755 index 00000000..d8fd8348 --- /dev/null +++ b/debian/tests/kernel-smoke-test-filesystem @@ -0,0 +1,99 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy ZFS filesystems: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +POOL=pool-smoke-$$ +ZFSFS="test tmp example data1 data2 data3" + +dd if=/dev/zero of=${VDEV0} bs=1M count=512 > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=512 > /dev/null 2>&1 + +zpool create ${POOL} ${VDEV0} ${VDEV1} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# And populate with ZFS file systems +# +for fs in ${ZFSFS} +do + zfs create ${POOL}/$fs + ret=$? + if [ $ret -ne 0 ]; then + echo "FAILED: zfs create filesystem $fs failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 + fi + + zfs set quota=128M ${POOL}/$fs + ret=$? + if [ $ret -ne 0 ]; then + echo "FAILED: zfs set quota on $fs failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 + fi + + zfs set compression=on ${POOL}/$fs + ret=$? + if [ $ret -ne 0 ]; then + echo "FAILED: zfs set compression on $fs failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 + fi +done + +# +# And destroy ZFS file systems +# +for fs in ${ZFSFS} +do + zfs destroy ${POOL}/$fs + ret=$? + if [ $ret -ne 0 ]; then + echo "FAILED: zfs destroy filesystem $fs failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 + fi +done + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-pool-2x2-mirror b/debian/tests/kernel-smoke-test-pool-2x2-mirror new file mode 100755 index 00000000..7728f885 --- /dev/null +++ b/debian/tests/kernel-smoke-test-pool-2x2-mirror @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy pool, 2x2 mirror: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV_SZ=128 +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} mirror ${VDEV0} ${VDEV1} mirror ${VDEV2} ${VDEV3} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-pool-4x1-mirror b/debian/tests/kernel-smoke-test-pool-4x1-mirror new file mode 100755 index 00000000..b48f8689 --- /dev/null +++ b/debian/tests/kernel-smoke-test-pool-4x1-mirror @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy pool, 4x1 mirror: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV_SZ=128 +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} mirror ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-pool-nested-raidz3 b/debian/tests/kernel-smoke-test-pool-nested-raidz3 new file mode 100755 index 00000000..5f233a59 --- /dev/null +++ b/debian/tests/kernel-smoke-test-pool-nested-raidz3 @@ -0,0 +1,63 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy pool, nested raidz3: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV4=${TMP}/pool4-$$.img +VDEV5=${TMP}/pool5-$$.img +VDEV6=${TMP}/pool6-$$.img +VDEV7=${TMP}/pool7-$$.img +VDEV_SZ=64 +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV4} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV5} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV6} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV7} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} raidz3 ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} raidz3 ${VDEV4} ${VDEV5} ${VDEV6} ${VDEV7} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} ${VDEV4} ${VDEV5} ${VDEV6} ${VDEV7} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} ${VDEV4} ${VDEV5} ${VDEV6} ${VDEV7} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} ${VDEV4} ${VDEV5} ${VDEV6} ${VDEV7} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-pool-raidz1 b/debian/tests/kernel-smoke-test-pool-raidz1 new file mode 100755 index 00000000..cf8d04b3 --- /dev/null +++ b/debian/tests/kernel-smoke-test-pool-raidz1 @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy pool, raidz1: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV_SZ=128 +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} raidz ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-pool-raidz2 b/debian/tests/kernel-smoke-test-pool-raidz2 new file mode 100755 index 00000000..236aa290 --- /dev/null +++ b/debian/tests/kernel-smoke-test-pool-raidz2 @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy pool, raidz2: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV_SZ=128 +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} raidz2 ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-pool-raidz3 b/debian/tests/kernel-smoke-test-pool-raidz3 new file mode 100755 index 00000000..15835bf0 --- /dev/null +++ b/debian/tests/kernel-smoke-test-pool-raidz3 @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy pool, raidz3: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV_SZ=128 +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} raidz3 ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-pool-striped b/debian/tests/kernel-smoke-test-pool-striped new file mode 100755 index 00000000..d035f067 --- /dev/null +++ b/debian/tests/kernel-smoke-test-pool-striped @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy pool, striped: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV_SZ=128 +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-scrub b/debian/tests/kernel-smoke-test-scrub new file mode 100755 index 00000000..a330715b --- /dev/null +++ b/debian/tests/kernel-smoke-test-scrub @@ -0,0 +1,114 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, corrupt data and clean with a scrub: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +VDEV2=${TMP}/pool2-$$.img +VDEV3=${TMP}/pool3-$$.img +VDEV_SZ=128 +POOL=pool-smoke-$$ +DATA=/${POOL}/random.dat +ZFSFS="test tmp example data1 data2 data3" + +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV2} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV3} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 + +zpool create ${POOL} mirror ${VDEV0} ${VDEV1} mirror ${VDEV2} ${VDEV3} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +# +# Create a file +# +dd if=/dev/urandom of=$DATA bs=1M count=64 > /dev/null 2>&1 +sum1=$(md5sum ${DATA} | awk '{print $1}') + +# +# Corrupt VDEV0 +# +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +sync + +# +# Offline "corrupted" VDEV +# +zpool detach ${POOL} ${VDEV0} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool detach failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +# +# Zero corrupted VDEV and re-attach +# +dd if=/dev/zero of=${VDEV0} bs=1M count=${VDEV_SZ} > /dev/null 2>&1 +zpool attach ${POOL} ${VDEV1} ${VDEV0} -f +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool attach failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool scrub ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool scrub failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +sum2=$(md5sum ${DATA} | awk '{print $1}') +# +# Checksums must agree +# +if [ x"$sum1" != x"$sum2" ]; then + echo "FAILED: corrupted data on scrubbed pool" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} ${VDEV2} ${VDEV3} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-send-receive b/debian/tests/kernel-smoke-test-send-receive new file mode 100755 index 00000000..b1f6668e --- /dev/null +++ b/debian/tests/kernel-smoke-test-send-receive @@ -0,0 +1,109 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, ZFS send and receive: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +POOL=pool-smoke-$$ +SNAP=${TMP}/snapshot-$$.zfs +DATA=/${POOL}/test/data + +dd if=/dev/zero of=${VDEV0} bs=1M count=512 > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=512 > /dev/null 2>&1 + +zpool create ${POOL} ${VDEV0} ${VDEV1} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zfs create ${POOL}/test +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs create failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Populate with files.. +# +cp -rp /etc /${POOL}/test +dd if=/dev/urandom of=${DATA} bs=1M count=64 > /dev/null 2>&1 +sum1=$(md5sum ${DATA} | awk '{print $1}') + +# +# Make a snapshot +# +zfs snapshot -r ${POOL}/test@snap +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs snapshot failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Make snapshot +# +zfs send ${POOL}/test@snap > ${SNAP} + +rm -rf ${POOL}/test + +zfs destroy ${POOL}/test@snap +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs destroy snapshot failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Receive it back.. +# +zfs receive -F ${POOL}/test < ${SNAP} + +sum2=$(md5sum ${DATA} | awk '{print $1}') +if [ x"$sum1" != x"$sum2" ]; then + echo "FAILED: received data different from original" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-snapshot b/debian/tests/kernel-smoke-test-snapshot new file mode 100755 index 00000000..62e10c26 --- /dev/null +++ b/debian/tests/kernel-smoke-test-snapshot @@ -0,0 +1,121 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, ZFS snapshot: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +POOL=pool-smoke-$$ +MARKER=/${POOL}/test/marker + +dd if=/dev/zero of=${VDEV0} bs=1M count=512 > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=512 > /dev/null 2>&1 + +zpool create ${POOL} ${VDEV0} ${VDEV1} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zfs create ${POOL}/test +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs create failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Populate with files.. +# +cp -rp /etc /${POOL}/test +echo $$ > ${MARKER} + +# +# Make a snapshot +# +zfs snapshot -r ${POOL}/test@snap +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs snapshot failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Remove files +# +rm -rf /${POOL}/test/etc ${MARKER} + +# +# Roll back +# +zfs rollback ${POOL}/test@snap +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs rollback failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# Check rolled back marker contains sane data +# +if [ ! -e ${MARKER} ]; then + echo "FAILED: zfs rollback failed, ${MARKER} not restored" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi +data=$(cat ${MARKER}) +if [ $data -ne $$ ]; then + echo "FAILED: zfs rollback failed, ${MARKER} contained unexpected data" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zfs destroy ${POOL}/test@snap +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zfs destroy snapshot failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} +echo "PASSED" +exit 0 diff --git a/debian/tests/kernel-smoke-test-zil b/debian/tests/kernel-smoke-test-zil new file mode 100755 index 00000000..42af87a5 --- /dev/null +++ b/debian/tests/kernel-smoke-test-zil @@ -0,0 +1,76 @@ +#!/bin/sh +# +# Copyright (C) 2016 Canonical +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty 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. +# +echo -n "kernel smoke test, create and destroy ZFS Intent Log: " +TMP=/tmp +VDEV0=${TMP}/pool0-$$.img +VDEV1=${TMP}/pool1-$$.img +POOL=pool-smoke-$$ + +dd if=/dev/zero of=${VDEV0} bs=1M count=512 > /dev/null 2>&1 +dd if=/dev/zero of=${VDEV1} bs=1M count=512 > /dev/null 2>&1 + +zpool create ${POOL} ${VDEV0} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool create failed, exit code=$ret" + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +# +# And add the ZIL +# +zpool add ${POOL} log ${VDEV1} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: ZIL add failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +sync + +# +# And now remove ZIL +# +zpool remove ${POOL} ${VDEV1} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: ZIL remove failed, exit code=$ret" + zpool destroy ${POOL} + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +zpool destroy ${POOL} +ret=$? +if [ $ret -ne 0 ]; then + echo "FAILED: zpool destroy failed, exit code=$ret" + # + # destroy failed, try to clean up, but this + # wil probably fail + # + rm ${VDEV0} ${VDEV1} + exit 1 +fi + +rm ${VDEV0} ${VDEV1} +echo "PASSED" +exit 0 -- 2.39.5