summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2004-07-30 23:13:45 +0000
committerpjd <pjd@FreeBSD.org>2004-07-30 23:13:45 +0000
commitadaa0482b446a8db32a6bb1f2986d1a743c769dd (patch)
treee04bc051596e48d58d986a0c7491de41c9fd0a31 /tools
parente2709c0cfc5e69512e4b685e5cbad68aed790fa2 (diff)
downloadFreeBSD-src-adaa0482b446a8db32a6bb1f2986d1a743c769dd.zip
FreeBSD-src-adaa0482b446a8db32a6bb1f2986d1a743c769dd.tar.gz
Add GEOM_MIRROR class which provide RAID1 functionality and has many useful
features. The gmirror(8) utility should be used for control of this class. There is no manual page yet, but I'm working on it with keramida@. Many useful tests provided by: simon (thank you!) Some ideas from: scottl, simon, phk
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/geom_mirror/Makefile8
-rw-r--r--tools/regression/geom_mirror/runtests.sh10
-rw-r--r--tools/regression/geom_mirror/test-1.sh32
-rw-r--r--tools/regression/geom_mirror/test-2.sh57
-rw-r--r--tools/regression/geom_mirror/test-3.sh68
-rw-r--r--tools/regression/geom_mirror/test-4.sh68
-rw-r--r--tools/regression/geom_mirror/test-5.sh68
-rw-r--r--tools/regression/geom_mirror/test-6.sh50
8 files changed, 361 insertions, 0 deletions
diff --git a/tools/regression/geom_mirror/Makefile b/tools/regression/geom_mirror/Makefile
new file mode 100644
index 0000000..88687b1
--- /dev/null
+++ b/tools/regression/geom_mirror/Makefile
@@ -0,0 +1,8 @@
+#
+# $FreeBSD$
+#
+# Regression tests for geom_mirror.
+#
+
+test:
+ @sh runtests.sh
diff --git a/tools/regression/geom_mirror/runtests.sh b/tools/regression/geom_mirror/runtests.sh
new file mode 100644
index 0000000..7e30b95
--- /dev/null
+++ b/tools/regression/geom_mirror/runtests.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# $FreeBSD$
+
+dir=`dirname $0`
+
+gmirror load >/dev/null 2>&1
+for ts in `dirname $0`/test-*.sh; do
+ sh $ts
+done
+gmirror unload >/dev/null 2>&1
diff --git a/tools/regression/geom_mirror/test-1.sh b/tools/regression/geom_mirror/test-1.sh
new file mode 100644
index 0000000..e521564
--- /dev/null
+++ b/tools/regression/geom_mirror/test-1.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# $FreeBSD$
+
+name="test"
+base=`basename $0`
+us0=45
+us1=`expr $us0 + 1`
+us2=`expr $us0 + 2`
+
+mdconfig -a -t malloc -s 1M -u $us0 || exit 1
+mdconfig -a -t malloc -s 2M -u $us1 || exit 1
+mdconfig -a -t malloc -s 3M -u $us2 || exit 1
+sleep 1
+
+gmirror label $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+
+# Size of created device should be 1MB - 512b.
+
+size=`diskinfo /dev/mirror/${name} | awk '{print $3}'`
+
+if [ $size -eq 1048064 ]; then
+ echo "PASS"
+else
+ echo "FAIL"
+fi
+
+gmirror remove $name md${us0}
+gmirror remove $name md${us1}
+gmirror remove $name md${us2}
+mdconfig -d -u $us0
+mdconfig -d -u $us1
+mdconfig -d -u $us2
diff --git a/tools/regression/geom_mirror/test-2.sh b/tools/regression/geom_mirror/test-2.sh
new file mode 100644
index 0000000..89bfdd4
--- /dev/null
+++ b/tools/regression/geom_mirror/test-2.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# $FreeBSD$
+
+name="test"
+base=`basename $0`
+balance="round-robin"
+us0=45
+us1=`expr $us0 + 1`
+us2=`expr $us0 + 2`
+ddbs=2048
+nblocks1=1024
+nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
+src=`mktemp /tmp/$base.XXXXXX` || exit 1
+dst=`mktemp /tmp/$base.XXXXXX` || exit 1
+
+dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+sleep 1
+
+gmirror label -b $balance $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+
+dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+dd if=/dev/md${us0} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+dd if=/dev/md${us1} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+dd if=/dev/md${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us0} md${us1} md${us2}
+mdconfig -d -u $us0
+mdconfig -d -u $us1
+mdconfig -d -u $us2
+rm -f ${src} ${dst}
diff --git a/tools/regression/geom_mirror/test-3.sh b/tools/regression/geom_mirror/test-3.sh
new file mode 100644
index 0000000..67a4151
--- /dev/null
+++ b/tools/regression/geom_mirror/test-3.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# $FreeBSD$
+
+name="test"
+base=`basename $0`
+balance="round-robin"
+us0=45
+us1=`expr $us0 + 1`
+us2=`expr $us0 + 2`
+ddbs=2048
+nblocks1=1024
+nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
+src=`mktemp /tmp/$base.XXXXXX` || exit 1
+dst=`mktemp /tmp/$base.XXXXXX` || exit 1
+
+dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+sleep 1
+
+gmirror label -b $balance $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+
+dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us0}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us1}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us2}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+# mirror/${name} should be removed.
+if [ -c /dev/${name} ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+mdconfig -d -u $us0
+mdconfig -d -u $us1
+mdconfig -d -u $us2
+rm -f ${src} ${dst}
diff --git a/tools/regression/geom_mirror/test-4.sh b/tools/regression/geom_mirror/test-4.sh
new file mode 100644
index 0000000..0b764ca
--- /dev/null
+++ b/tools/regression/geom_mirror/test-4.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# $FreeBSD$
+
+name="test"
+base=`basename $0`
+balance="load"
+us0=45
+us1=`expr $us0 + 1`
+us2=`expr $us0 + 2`
+ddbs=2048
+nblocks1=1024
+nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
+src=`mktemp /tmp/$base.XXXXXX` || exit 1
+dst=`mktemp /tmp/$base.XXXXXX` || exit 1
+
+dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+sleep 1
+
+gmirror label -b $balance $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+
+dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us0}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us1}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us2}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+# mirror/${name} should be removed.
+if [ -c /dev/${name} ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+mdconfig -d -u $us0
+mdconfig -d -u $us1
+mdconfig -d -u $us2
+rm -f ${src} ${dst}
diff --git a/tools/regression/geom_mirror/test-5.sh b/tools/regression/geom_mirror/test-5.sh
new file mode 100644
index 0000000..d1958d5
--- /dev/null
+++ b/tools/regression/geom_mirror/test-5.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# $FreeBSD$
+
+name="test"
+base=`basename $0`
+balance="split"
+us0=45
+us1=`expr $us0 + 1`
+us2=`expr $us0 + 2`
+ddbs=8192
+nblocks1=1024
+nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
+src=`mktemp /tmp/$base.XXXXXX` || exit 1
+dst=`mktemp /tmp/$base.XXXXXX` || exit 1
+
+dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+sleep 1
+
+gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/md${us0} /dev/md${us1} /dev/md${us2} || exit 1
+
+dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us0}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us1}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us2}
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+# mirror/${name} should be removed.
+if [ -c /dev/${name} ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+mdconfig -d -u $us0
+mdconfig -d -u $us1
+mdconfig -d -u $us2
+rm -f ${src} ${dst}
diff --git a/tools/regression/geom_mirror/test-6.sh b/tools/regression/geom_mirror/test-6.sh
new file mode 100644
index 0000000..db36726
--- /dev/null
+++ b/tools/regression/geom_mirror/test-6.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# $FreeBSD$
+
+name="test"
+base=`basename $0`
+balance="split"
+us0=45
+us1=`expr $us0 + 1`
+us2=`expr $us0 + 2`
+ddbs=8192
+nblocks1=1024
+nblocks2=`expr $nblocks1 / \( $ddbs / 512 \)`
+src=`mktemp /tmp/$base.XXXXXX` || exit 1
+dst=`mktemp /tmp/$base.XXXXXX` || exit 1
+
+dd if=/dev/random of=${src} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us0 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us1 || exit 1
+mdconfig -a -t malloc -s `expr $nblocks1 + 1` -u $us2 || exit 1
+sleep 1
+
+gmirror label -b $balance -s `expr $ddbs / 2` $name /dev/md${us0} /dev/md${us1} || exit 1
+
+dd if=${src} of=/dev/mirror/${name} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+dd if=/dev/zero of=/dev/md${us2} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+
+dd if=/dev/mirror/${name} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+# Connect disk to the mirror.
+gmirror insert ${name} md${us2}
+# Wait for synchronization.
+sleep 1
+dd if=/dev/md${us2} of=${dst} bs=$ddbs count=$nblocks2 >/dev/null 2>&1
+if [ `md5 -q ${src}` != `md5 -q ${dst}` ]; then
+ echo "FAIL"
+else
+ echo "PASS"
+fi
+
+gmirror remove $name md${us0} md${us1} md${us2}
+mdconfig -d -u $us0
+mdconfig -d -u $us1
+mdconfig -d -u $us2
+rm -f ${src} ${dst}
OpenPOWER on IntegriCloud