Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Oct 2017 23:08:36 +0000 (UTC)
From:      Ngie Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r324403 - stable/11/tests/sys/geom/class/mirror
Message-ID:  <201710072308.v97N8aef032228@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Oct  7 23:08:36 2017
New Revision: 324403
URL: https://svnweb.freebsd.org/changeset/base/324403

Log:
  MFC r317713:
  r317713 (by markj):
  
  Add regression tests for r317712 and r306743.

Added:
  stable/11/tests/sys/geom/class/mirror/8_test.sh
     - copied unchanged from r317713, head/tests/sys/geom/class/mirror/8_test.sh
  stable/11/tests/sys/geom/class/mirror/9_test.sh
     - copied unchanged from r317713, head/tests/sys/geom/class/mirror/9_test.sh
Modified:
  stable/11/tests/sys/geom/class/mirror/Makefile
Directory Properties:
  stable/11/   (props changed)

Copied: stable/11/tests/sys/geom/class/mirror/8_test.sh (from r317713, head/tests/sys/geom/class/mirror/8_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/tests/sys/geom/class/mirror/8_test.sh	Sat Oct  7 23:08:36 2017	(r324403, copy of r317713, head/tests/sys/geom/class/mirror/8_test.sh)
@@ -0,0 +1,53 @@
+#!/bin/sh
+# $FreeBSD$
+
+# Regression test for r317712.
+
+. `dirname $0`/conf.sh
+
+echo 1..1
+
+ddbs=2048
+m1=`mktemp $base.XXXXXX` || exit 1
+m2=`mktemp $base.XXXXXX` || exit 1
+
+dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
+dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
+
+us0=$(mdconfig -t vnode -f $m1) || exit 1
+us1=$(mdconfig -t vnode -f $m2) || exit 1
+
+gmirror label $name /dev/$us0 /dev/$us1 || exit 1
+devwait
+
+# Ensure that the mirrors are marked dirty, and then disconnect them.
+# We need to have the gmirror provider open when destroying the MDs since
+# gmirror will automatically mark the mirrors clean when the provider is closed.
+exec 9>/dev/mirror/$name
+dd if=/dev/zero bs=$ddbs count=1 >&9 2>/dev/null
+mdconfig -d -u ${us0#md} -o force || exit 1
+mdconfig -d -u ${us1#md} -o force || exit 1
+exec 9>&-
+
+dd if=/dev/random of=$m1 bs=$ddbs count=1 conv=notrunc >/dev/null 2>&1
+us0=$(attach_md -t vnode -f $m1) || exit 1
+devwait # This will take kern.geom.mirror.timeout seconds.
+
+# Re-attach the second mirror and wait for it to synchronize.
+us1=$(attach_md -t vnode -f $m2) || exit 1
+while [ $(gmirror status $name | grep ACTIVE | wc -l) -ne 2 ]; do
+    sleep 1
+done
+
+# Verify the two mirrors are identical. Destroy the gmirror first so that
+# the mirror metadata is wiped; otherwise the metadata blocks will fail
+# the comparison. It would be nice to do this with a "gmirror verify"
+# command instead.
+gmirror destroy $name
+if cmp -s ${m1} ${m2}; then
+    echo "ok 1"
+else
+    echo "not ok 1"
+fi
+
+rm -f $m1 $m2

Copied: stable/11/tests/sys/geom/class/mirror/9_test.sh (from r317713, head/tests/sys/geom/class/mirror/9_test.sh)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/11/tests/sys/geom/class/mirror/9_test.sh	Sat Oct  7 23:08:36 2017	(r324403, copy of r317713, head/tests/sys/geom/class/mirror/9_test.sh)
@@ -0,0 +1,62 @@
+#!/bin/sh
+# $FreeBSD$
+
+# Regression test for r306743.
+
+. `dirname $0`/conf.sh
+
+echo 1..1
+
+ddbs=2048
+m1=`mktemp $base.XXXXXX` || exit 1
+m2=`mktemp $base.XXXXXX` || exit 1
+m3=`mktemp $base.XXXXXX` || exit 1
+
+dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
+dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
+dd if=/dev/zero of=$m3 bs=$ddbs count=1024 >/dev/null 2>&1
+
+us0=$(attach_md -t vnode -f $m1) || exit 1
+us1=$(attach_md -t vnode -f $m2) || exit 1
+us2=$(attach_md -t vnode -f $m3) || exit 1
+
+gmirror label $name /dev/$us0 /dev/$us1 || exit 1
+devwait
+
+# Break one of the mirrors by forcing a single metadata write error.
+# When dd closes the mirror provider, gmirror will attempt to mark the mirrors
+# clean, and will kick one of the mirrors out upon hitting the error.
+sysctl debug.fail_point.g_mirror_metadata_write='1*return(5)' || exit 1
+dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1
+sysctl debug.fail_point.g_mirror_metadata_write='off' || exit 1
+
+# Replace the broken mirror, and then stop the gmirror.
+gmirror forget $name || exit 1
+gmirror insert $name /dev/$us2 || exit 1
+while [ $(gmirror status $name | grep ACTIVE | wc -l) -ne 2 ]; do
+    sleep 1
+done
+gmirror stop $name || exit 1
+
+# Restart the gmirror on the original two mirrors. One of them is broken,
+# so we should end up with a degraded gmirror.
+gmirror activate $name /dev/$us0 /dev/$us1 || exit 1
+devwait
+dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1
+
+# Re-add the replacement mirror and verify the two mirrors are synchronized.
+# Destroy the gmirror first so that the mirror metadata is wiped; otherwise
+# the metadata blocks will fail the comparison. It would be nice to do this
+# with a "gmirror verify" command instead.
+gmirror activate $name /dev/$us2 || exit 1
+while [ $(gmirror status $name | grep ACTIVE | wc -l) -ne 2 ]; do
+    sleep 1
+done
+gmirror destroy $name || exit 1
+if cmp -s $m1 $m3; then
+    echo "ok 1"
+else
+    echo "not ok 1"
+fi
+
+rm -f $m1 $m2 $m3

Modified: stable/11/tests/sys/geom/class/mirror/Makefile
==============================================================================
--- stable/11/tests/sys/geom/class/mirror/Makefile	Sat Oct  7 23:06:49 2017	(r324402)
+++ stable/11/tests/sys/geom/class/mirror/Makefile	Sat Oct  7 23:08:36 2017	(r324403)
@@ -11,6 +11,8 @@ TAP_TESTS_SH+=	4_test
 TAP_TESTS_SH+=	5_test
 TAP_TESTS_SH+=	6_test
 TAP_TESTS_SH+=	7_test
+TAP_TESTS_SH+=	8_test
+TAP_TESTS_SH+=	9_test
 
 ${PACKAGE}FILES+=		conf.sh
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710072308.v97N8aef032228>