]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
tests: add some simple data integrity tests for raid5/raid6
authorNeilBrown <neilb@suse.de>
Tue, 14 Apr 2009 00:19:05 +0000 (10:19 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 14 Apr 2009 00:19:05 +0000 (10:19 +1000)
Make sure the data is preserved even when the array is degraded.

Signed-off-by: NeilBrown <neilb@suse.de>
tests/01r5integ [new file with mode: 0644]
tests/01raid6integ [new file with mode: 0644]

diff --git a/tests/01r5integ b/tests/01r5integ
new file mode 100644 (file)
index 0000000..714a57f
--- /dev/null
@@ -0,0 +1,29 @@
+
+# Check integrity of raid5 in degraded mode
+# Create a 4 disk raid5, create a filesystem and
+# sh1sum it with each device failed
+
+for layout in ls rs la ra
+do
+  mdadm -CR $md0 -l5 --layout $layout -n4 $dev0 $dev1 $dev2 $dev3
+  check wait
+  tar cf - /etc > $md0
+  sum=`sha1sum $md0`
+
+  for i in $dev0 $dev1 $dev2 $dev3
+  do
+    mdadm $md0 -f $i
+    mdadm $md0 -r $i
+    blockdev --flushbufs $md0
+    sum1=`sha1sum $md0`
+    if [ $sum != $sum1 ]
+    then
+     echo $sum does not matc $sum1 with $i missing
+     exit 1
+    fi
+    mdadm $md0 -a $i
+   check wait
+  done
+  mdadm -S $md0
+done
+
diff --git a/tests/01raid6integ b/tests/01raid6integ
new file mode 100644 (file)
index 0000000..ed7cec5
--- /dev/null
@@ -0,0 +1,53 @@
+
+# Check integrity of raid6 in degraded modes
+# Create a 5 disk raid6, dump some data to it, then
+# sh1sum it with different pairs of devices failed
+
+layouts='ls rs la ra'
+lv=`uname -r`
+if expr $lv '>=' 2.6.30 > /dev/null
+then
+  layouts="$layouts parity-first dd-zero-restart ddf-N-restart ddf-N-continue \
+       left-asymmetric-6 right-asymmetric-6 left-symmetric-6 right-symmetric-6 parity-first-6"
+fi
+echo $layouts
+for layout in $layouts
+do
+  mdadm -CR $md0 -l6 --layout $layout -n5 $dev0 $dev1 $dev2 $dev3 $dev4
+  check wait
+  tar cf - /etc > $md0
+  sum=`sha1sum $md0`
+
+  totest=
+  for second in $dev0 $dev1 $dev2 $dev3 $dev4
+  do
+    mdadm $md0 -f $second
+    mdadm $md0 -r $second
+    blockdev --flushbufs $md0
+    sum1=`sha1sum $md0`
+    if [ $sum != $sum1 ]
+    then
+      echo $sum does not matc $sum1 with $second missing
+      exit 1
+    fi
+    for first in $totest
+    do
+       mdadm $md0 -f $first
+       mdadm $md0 -r $first
+       blockdev --flushbufs $md0
+       sum1=`sha1sum $md0`
+       if [ $sum != $sum1 ]
+       then
+         echo $sum does not matc $sum1 with $first and $second missing
+         exit 1
+       fi
+       mdadm $md0 -a $first
+       check wait
+    done
+    mdadm $md0 -a $second
+    check wait
+    totest="$totest $second"
+  done
+  mdadm -S $md0
+done
+